#33 Add labels to the issue creation.
Merged 4 years ago by mohanboddu. Opened 4 years ago by cverna.
releng/ cverna/compose-tracker add_labels_to_issue  into  master

file modified
+3 -5
@@ -245,13 +245,11 @@ 

                  content+= f"Compose phase {p}: FAILED.\n"

          logger.debug(content)

  

-         # pull only part of the compose ID for the label to set

-         label = re.search('(.*)-\d{8}', msg['compose_id']).group(1)

-         #TODO set labels on issues when functionality is in ogr

-         # https://github.com/packit-service/ogr/issues/147

+         labels = [msg.get("release_name"), msg.get("release_version"), msg.get("status")]

+         logger.debug(f"Adding Labels {labels}")

  

          if self.token:

-             issue = self.gitproject.create_issue(title=title, body=content)

+             issue = self.gitproject.create_issue(title=title, body=content, labels=labels)

              logger.info('Opened issue: %s' % issue.url)

  

  

file modified
+21
@@ -165,3 +165,24 @@ 

      con.process(msg)

      assert "Ostree (variant Silverblue, arch x86_64) failed, but going on anyway." in caplog.text

      assert "Ostree (variant Silverblue, arch ppc64le) failed, but going on anyway." in caplog.text

+ 

+ def test_adding_labels(mocker, caplog):

+     "Test that we get the correct labels from the fedora-messaging message."

+ 

+     mocker.patch("compose_tracker.PagureService")

+ 

+     # set logs at DEBUG and capture this level

+     caplog.set_level(logging.DEBUG)

+     mocker.patch("compose_tracker.logger.level", logging.DEBUG)

+ 

+     req = mocker.patch("compose_tracker.requests.get", autospec=True)

+     text_mock = mocker.MagicMock()

+     text_mock.text.splitlines.return_value = EXAMPLE_PUNGI_LOG_INCOMPLETE.splitlines()

+     req.return_value = text_mock

+ 

+     con = Consumer()

+     msg = fedora_messaging.api.Message(

+         topic="org.fedoraproject.prod.pungi.compose.status.change", body=EXAMPLE_MESSAGE_BODY,

+     )

+     con.process(msg)

+     assert "Adding Labels ['Fedora', 'Rawhide', 'DOOMED']" in caplog.text

The consumer get the release_name, release_version and status from
the fedora-messaging message and use these as labels when creating
the issue in pagure.

Signed-off-by: Clement Verna cverna@tutanota.com

Fixes #16.

This will need a new release of ogr before we can merge and deploy in stg and prod.

The current ogr release is 0.10.0 (https://github.com/packit-service/ogr/releases).

Do we really need release_name?

Do we really need release_name?

Ha in some cases it will be Fedora Cloud, Fedora Container, etc ... So maybe we want to keep it ? I don't mind :)

https://apps.fedoraproject.org/datagrepper/id?id=2020-55f8ee4c-6a0a-4a39-859b-982d9c1ad51a&is_raw=true&size=extra-large

python-ogr-0.11.0-1.fc31 is now available we can now merge this.

rebased onto b92a3a5

4 years ago

Pull-Request has been merged by mohanboddu

4 years ago
Metadata