Skip to content

Commit ff132bc

Browse files
Make Fedora CI check names deployment-aware (#3016)
Make Fedora CI check names deployment-aware Add "stg" prefix to check names for staging environment Reviewed-by: gemini-code-assist[bot] Reviewed-by: Laura Barcziová Reviewed-by: Nikola Forró Reviewed-by: Maja Massarini
2 parents 5bd09bd + a62f0a6 commit ff132bc

File tree

10 files changed

+77
-51
lines changed

10 files changed

+77
-51
lines changed

packit_service/worker/handlers/abstract.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,27 @@ def __init__(
597597

598598

599599
class FedoraCIJobHandler(JobHandler):
600-
check_name: str = ""
600+
_check_name: str = ""
601+
602+
@staticmethod
603+
def get_check_name_prefix(service_config: ServiceConfig) -> str:
604+
"""Return the prefix for check names based on deployment environment."""
605+
return "Packit-stg" if service_config.deployment == Deployment.stg else "Packit"
606+
607+
@classmethod
608+
def get_check_name(cls, service_config: ServiceConfig) -> str:
609+
"""Return check name based on deployment environment."""
610+
prefix = cls.get_check_name_prefix(service_config)
611+
return f"{prefix} - {cls._check_name}" if cls._check_name else ""
612+
613+
@property
614+
def check_name(self) -> str:
615+
"""Return the check name."""
616+
return self.get_check_name(self.service_config)
601617

602618
@classmethod
603-
def get_check_names(
619+
def get_all_check_names(
604620
cls, service_config: ServiceConfig, project: GitProject, metadata: EventData
605621
) -> list[str]:
606-
return [cls.check_name] if cls.check_name else []
622+
"""Return check names."""
623+
return [cls.get_check_name(service_config)] if cls.get_check_name(service_config) else []

packit_service/worker/handlers/distgit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ class DownstreamKojiScratchBuildHandler(
790790
"""
791791

792792
task_name = TaskName.downstream_koji_scratch_build
793-
check_name = "Packit - scratch build"
793+
_check_name = "scratch build"
794794

795795
def __init__(
796796
self,

packit_service/worker/handlers/koji.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def push_metrics(self) -> None:
344344
@reacts_to_as_fedora_ci(event=koji.result.Task)
345345
class KojiTaskReportDownstreamHandler(AbstractKojiTaskReportHandler, FedoraCIJobHandler):
346346
task_name = TaskName.downstream_koji_scratch_build_report
347-
check_name = "Packit - scratch build"
347+
_check_name = "scratch build"
348348
_helper: Optional[FedoraCIHelper] = None
349349

350350
@property

packit_service/worker/handlers/testing_farm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ def filter_ci_tests(cls, tests: list[str]) -> list[str]:
400400
return tests
401401

402402
@classmethod
403-
def get_check_names(
403+
def get_all_check_names(
404404
cls, service_config: ServiceConfig, project: GitProject, metadata: EventData
405405
) -> list[str]:
406406
return [
407-
DownstreamTestingFarmJobHelper.get_check_name(t)
407+
DownstreamTestingFarmJobHelper.get_check_name_from_config(t, service_config)
408408
for t in cls.filter_ci_tests(
409409
DownstreamTestingFarmJobHelper.get_fedora_ci_tests(
410410
service_config, project, metadata

packit_service/worker/helpers/testing_farm.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from packit_service.service.urls import get_testing_farm_info_url
4242
from packit_service.utils import get_package_nvrs, get_packit_commands_from_comment
4343
from packit_service.worker.celery_task import CeleryTask
44+
from packit_service.worker.handlers.abstract import FedoraCIJobHandler
4445
from packit_service.worker.helpers.build import CoprBuildJobHelper
4546
from packit_service.worker.helpers.fedora_ci import FedoraCIHelper
4647
from packit_service.worker.helpers.testing_farm_client import TestingFarmClient
@@ -1363,9 +1364,15 @@ def pr(self) -> PullRequest:
13631364
self._pr = self.project.get_pr(self.metadata.pr_id)
13641365
return self._pr
13651366

1367+
def get_check_name(self, test_name: str) -> str:
1368+
"""Return check name based on deployment environment."""
1369+
return self.get_check_name_from_config(test_name, self.service_config)
1370+
13661371
@staticmethod
1367-
def get_check_name(test_name: str) -> str:
1368-
return f"Packit - {test_name}"
1372+
def get_check_name_from_config(test_name: str, service_config: ServiceConfig) -> str:
1373+
"""Static version for use in class methods."""
1374+
prefix = FedoraCIJobHandler.get_check_name_prefix(service_config)
1375+
return f"{prefix} - {test_name}"
13691376

13701377
def report(
13711378
self,

packit_service/worker/jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def report_task_accepted_for_fedora_ci(self, handler_kls: type[FedoraCIJobHandle
560560
)
561561

562562
first_status_reported = False
563-
for check_name in handler_kls.get_check_names(
563+
for check_name in handler_kls.get_all_check_names(
564564
self.service_config, self.event.project, metadata
565565
):
566566
helper.report(

tests/integration/test_dg_pr.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ def distgit_pr_event():
4545
[
4646
pytest.param(
4747
"rawhide",
48-
"da02b4ee9881488e777cd22bbb13987f",
49-
"Packit - scratch build - rawhide [889f07a]",
48+
"e7593c9ba1d17d1a4f366b6aa7f53e84",
49+
"Packit-stg - scratch build - rawhide [889f07a]",
5050
False,
5151
id="rawhide target branch",
5252
),
5353
pytest.param(
5454
"rawhide",
55-
"f4a160072a397b8fca2304d80f36fc76",
56-
"Packit - scratch build - eln [889f07a]",
55+
"07209e112c3135ab74e0da0bd0e321ca",
56+
"Packit-stg - scratch build - eln [889f07a]",
5757
True,
5858
id="rawhide branch, rawhide + eln target",
5959
),
6060
pytest.param(
6161
"f42",
62-
"44e52710e6df077ddc07e16df1cbf6b7",
63-
"Packit - scratch build - f42 [889f07a]",
62+
"4196b23fba5a53425b6f15a11fd2ef15",
63+
"Packit-stg - scratch build - f42 [889f07a]",
6464
False,
6565
id="f42 target branch",
6666
),
@@ -84,8 +84,8 @@ def test_downstream_koji_scratch_build(distgit_pr_event, target_branch, uid, che
8484
.mock()
8585
)
8686
if eln:
87-
check_name = "Packit - scratch build - rawhide [889f07a]"
88-
uid = "da02b4ee9881488e777cd22bbb13987f"
87+
check_name = "Packit-stg - scratch build - rawhide [889f07a]"
88+
uid = "e7593c9ba1d17d1a4f366b6aa7f53e84"
8989
(
9090
pr_object.should_receive("set_flag")
9191
.with_args(username=check_name, comment=str, url=str, status=CommitStatus, uid=uid)

tests/integration/test_listen_to_fedmsg.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,63 +2957,63 @@ def test_koji_build_end_downstream(
29572957
state=BaseCommitStatus.success,
29582958
description="RPM build succeeded.",
29592959
url=url,
2960-
check_name="Packit - scratch build",
2960+
check_name="Packit-stg - scratch build",
29612961
target_branch="rawhide",
29622962
).once()
29632963
flexmock(StatusReporter).should_receive("set_status").with_args(
29642964
state=BaseCommitStatus.running,
29652965
description="Submitting the tests ...",
29662966
url="https://dashboard.localhost/jobs/testing-farm/5",
2967-
check_name="Packit - installability",
2967+
check_name="Packit-stg - installability",
29682968
target_branch="rawhide",
29692969
).once()
29702970
flexmock(StatusReporter).should_receive("set_status").with_args(
29712971
state=BaseCommitStatus.running,
29722972
description="Tests have been submitted ...",
29732973
url="https://dashboard.localhost/jobs/testing-farm/5",
2974-
check_name="Packit - installability",
2974+
check_name="Packit-stg - installability",
29752975
target_branch="rawhide",
29762976
).once()
29772977
flexmock(StatusReporter).should_receive("set_status").with_args(
29782978
state=BaseCommitStatus.running,
29792979
description="Submitting the tests ...",
29802980
url="https://dashboard.localhost/jobs/testing-farm/6",
2981-
check_name="Packit - custom",
2981+
check_name="Packit-stg - custom",
29822982
target_branch="rawhide",
29832983
).once()
29842984
flexmock(StatusReporter).should_receive("set_status").with_args(
29852985
state=BaseCommitStatus.running,
29862986
description="Tests have been submitted ...",
29872987
url="https://dashboard.localhost/jobs/testing-farm/6",
2988-
check_name="Packit - custom",
2988+
check_name="Packit-stg - custom",
29892989
target_branch="rawhide",
29902990
).once()
29912991
flexmock(StatusReporter).should_receive("set_status").with_args(
29922992
state=BaseCommitStatus.running,
29932993
description="Submitting the tests ...",
29942994
url="https://dashboard.localhost/jobs/testing-farm/7",
2995-
check_name="Packit - rpminspect",
2995+
check_name="Packit-stg - rpminspect",
29962996
target_branch="rawhide",
29972997
).once()
29982998
flexmock(StatusReporter).should_receive("set_status").with_args(
29992999
state=BaseCommitStatus.running,
30003000
description="Tests have been submitted ...",
30013001
url="https://dashboard.localhost/jobs/testing-farm/7",
3002-
check_name="Packit - rpminspect",
3002+
check_name="Packit-stg - rpminspect",
30033003
target_branch="rawhide",
30043004
).once()
30053005
flexmock(StatusReporter).should_receive("set_status").with_args(
30063006
state=BaseCommitStatus.running,
30073007
description="Submitting the tests ...",
30083008
url="https://dashboard.localhost/jobs/testing-farm/8",
3009-
check_name="Packit - rpmlint",
3009+
check_name="Packit-stg - rpmlint",
30103010
target_branch="rawhide",
30113011
).once()
30123012
flexmock(StatusReporter).should_receive("set_status").with_args(
30133013
state=BaseCommitStatus.running,
30143014
description="Tests have been submitted ...",
30153015
url="https://dashboard.localhost/jobs/testing-farm/8",
3016-
check_name="Packit - rpmlint",
3016+
check_name="Packit-stg - rpmlint",
30173017
target_branch="rawhide",
30183018
).once()
30193019

@@ -3430,7 +3430,7 @@ def test_pagure_pr_updated(pagure_pr_updated, project_namespace, project_repo):
34303430
state=BaseCommitStatus.running,
34313431
description="RPM build was submitted ...",
34323432
url="https://dashboard.localhost/jobs/koji/123",
3433-
check_name="Packit - scratch build",
3433+
check_name="Packit-stg - scratch build",
34343434
target_branch="rawhide",
34353435
).once()
34363436
else:
@@ -3518,14 +3518,14 @@ def test_pagure_pr_updated(pagure_pr_updated, project_namespace, project_repo):
35183518
state=BaseCommitStatus.running,
35193519
description="Submitting the tests ...",
35203520
url="https://dashboard.localhost/jobs/testing-farm/6",
3521-
check_name="Packit - custom",
3521+
check_name="Packit-stg - custom",
35223522
target_branch="rawhide",
35233523
).once()
35243524
flexmock(StatusReporter).should_receive("set_status").with_args(
35253525
state=BaseCommitStatus.running,
35263526
description="Tests have been submitted ...",
35273527
url="https://dashboard.localhost/jobs/testing-farm/6",
3528-
check_name="Packit - custom",
3528+
check_name="Packit-stg - custom",
35293529
target_branch="rawhide",
35303530
).once()
35313531

tests/integration/test_pr_comment.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,14 +2461,14 @@ def test_koji_build_retrigger_via_dist_git_pr_comment(pagure_pr_comment_added):
24612461
[
24622462
pytest.param(
24632463
"rawhide",
2464-
"45f8d1e6ef3ca9f57d9ed4dc82919216",
2465-
"Packit - scratch build - rawhide [beaf90b]",
2464+
"7f6d17aef35c10b4429b018288140d2e",
2465+
"Packit-stg - scratch build - rawhide [beaf90b]",
24662466
id="rawhide target branch",
24672467
),
24682468
pytest.param(
24692469
"f42",
2470-
"436202b02405a83e4f8cf57ed908c0cc",
2471-
"Packit - scratch build - f42 [beaf90b]",
2470+
"71105829c34639d62676a5e5b5cf2a61",
2471+
"Packit-stg - scratch build - f42 [beaf90b]",
24722472
id="f42 target branch",
24732473
),
24742474
],
@@ -3471,16 +3471,16 @@ def _test_downstream_tf_retrigger_common(
34713471
"rawhide",
34723472
[
34733473
(
3474-
"d6180f0168d35be241dd9502ccebf427",
3475-
"Packit - installability - rawhide [beaf90b]",
3474+
"be4571bd828a699b35ed3102fc7e88f5",
3475+
"Packit-stg - installability - rawhide [beaf90b]",
34763476
),
34773477
(
3478-
"2c980bef6257ac6f3e40d09151218997",
3479-
"Packit - rpminspect - rawhide [beaf90b]",
3478+
"9b6239fe5ed9fd065540810c5591f352",
3479+
"Packit-stg - rpminspect - rawhide [beaf90b]",
34803480
),
34813481
(
3482-
"251118c3a3695047d34973df58f099f1",
3483-
"Packit - rpmlint - rawhide [beaf90b]",
3482+
"cafe8a3fb7c24f7534a6157514dda0f3",
3483+
"Packit-stg - rpmlint - rawhide [beaf90b]",
34843484
),
34853485
],
34863486
id="rawhide target branch",
@@ -3489,11 +3489,11 @@ def _test_downstream_tf_retrigger_common(
34893489
"f42",
34903490
[
34913491
(
3492-
"7d0be14827d57f19280b3e08ef7a0aca",
3493-
"Packit - installability - f42 [beaf90b]",
3492+
"c39c286752c4b7987058134bc3b16683",
3493+
"Packit-stg - installability - f42 [beaf90b]",
34943494
),
3495-
("ef105a8a3c47785c5827647dcfd6ce31", "Packit - rpminspect - f42 [beaf90b]"),
3496-
("2f36dd43d50caa95f0e40c7365f9e4d2", "Packit - rpmlint - f42 [beaf90b]"),
3495+
("d6df09a49152552c196c4d06f286abef", "Packit-stg - rpminspect - f42 [beaf90b]"),
3496+
("6901e099dadbb89822e6a64c411ceb8c", "Packit-stg - rpmlint - f42 [beaf90b]"),
34973497
],
34983498
id="f42 target branch",
34993499
),
@@ -3519,22 +3519,22 @@ def test_downstream_testing_farm_retrigger_via_dist_git_pr_comment(
35193519
pytest.param(
35203520
"/packit-ci test installability",
35213521
"rawhide",
3522-
"d6180f0168d35be241dd9502ccebf427",
3523-
"Packit - installability - rawhide [beaf90b]",
3522+
"be4571bd828a699b35ed3102fc7e88f5",
3523+
"Packit-stg - installability - rawhide [beaf90b]",
35243524
id="installability - rawhide target branch",
35253525
),
35263526
pytest.param(
35273527
"/packit-ci test installability",
35283528
"f42",
3529-
"7d0be14827d57f19280b3e08ef7a0aca",
3530-
"Packit - installability - f42 [beaf90b]",
3529+
"c39c286752c4b7987058134bc3b16683",
3530+
"Packit-stg - installability - f42 [beaf90b]",
35313531
id="installability - f42 target branch",
35323532
),
35333533
pytest.param(
35343534
"/packit-ci test rpminspect",
35353535
"rawhide",
3536-
"2c980bef6257ac6f3e40d09151218997",
3537-
"Packit - rpminspect - rawhide [beaf90b]",
3536+
"9b6239fe5ed9fd065540810c5591f352",
3537+
"Packit-stg - rpminspect - rawhide [beaf90b]",
35383538
id="rpminspect - rawhide target branch",
35393539
),
35403540
],

tests/unit/test_testing_farm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
JobType,
1313
PackageConfig,
1414
)
15+
from packit.config.common_package_config import Deployment
1516
from packit.copr_helper import CoprHelper
1617
from packit.local_project import LocalProject
1718

@@ -265,6 +266,7 @@ def test_downstream_testing_farm_response(
265266
config = flexmock(
266267
command_handler_work_dir=flexmock(),
267268
comment_command_prefix="/packit",
269+
deployment=Deployment.stg,
268270
)
269271
flexmock(DownstreamTFResultsHandler).should_receive("service_config").and_return(config)
270272
flexmock(TFResultsEvent).should_receive("db_project_object").and_return(None)
@@ -301,7 +303,7 @@ def test_downstream_testing_farm_response(
301303
state=status_status,
302304
description=status_message,
303305
url="some url",
304-
check_name="Packit - installability",
306+
check_name="Packit-stg - installability",
305307
target_branch="rawhide",
306308
).once()
307309

0 commit comments

Comments
 (0)