Skip to content

Commit 6cafc40

Browse files
committed
Simplify fedora-ci jobs
All Fedora-CI jobs use consistent variables that Packit already provides in `_get_tf_base_payload` Signed-off-by: Cristian Le <git@lecris.dev>
1 parent 379f24d commit 6cafc40

2 files changed

Lines changed: 24 additions & 82 deletions

File tree

packit_service/worker/helpers/testing_farm.py

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
from ogr.abstract import GitProject, PullRequest
1111
from ogr.utils import RequestResponse
1212
from packit.config import JobConfig, PackageConfig
13-
from packit.exceptions import PackitConfigException, PackitException
14-
from packit.utils import commands, nested_get
13+
from packit.exceptions import PackitConfigException
14+
from packit.utils import nested_get
1515
from packit.utils.koji_helper import KojiHelper
1616

1717
from packit_service.config import Deployment, ServiceConfig
@@ -1525,49 +1525,15 @@ def prepare_and_send_tf_request(
15251525
)
15261526
def _payload_installability(self, distro: str, compose: str) -> dict:
15271527
git_repo = "https://github.com/fedora-ci/installability-pipeline.git"
1528-
git_ref = (
1529-
commands.run_command(["git", "ls-remote", git_repo, "HEAD"], output=True)
1530-
.stdout.strip()
1531-
.split()[0]
1532-
)
1533-
1534-
if distro == "fedora-rawhide":
1535-
# profile names are in "fedora-N" format
1536-
# extract current rawhide version number from its candidate tag
1537-
if not (candidate_tag := self.koji_helper.get_candidate_tag("rawhide")):
1538-
raise PackitException(f"Failed to get test profile for {distro}")
1539-
profile = re.sub(r"f(\d+)(-.*)?", r"fedora-\1", candidate_tag)
1540-
else:
1541-
profile = distro
1542-
1543-
# installability test requires a Koji build
1544-
# (it should be guaranteed by the `HasEventSuccessfulScratchBuild` checker)
1545-
assert self.koji_build
1546-
1547-
return {
1548-
"test": {
1549-
"tmt": {
1550-
"url": git_repo,
1551-
"ref": git_ref,
1552-
},
1553-
},
1554-
"environments": [
1555-
{
1556-
"arch": "x86_64",
1557-
"os": {"compose": compose},
1558-
"variables": {
1559-
"PROFILE_NAME": profile,
1560-
"TASK_ID": self.koji_build.task_id,
1561-
},
1562-
},
1563-
],
1564-
"notification": {
1565-
"webhook": {
1566-
"url": f"{self.api_url}/testing-farm/results",
1567-
"token": self.service_config.testing_farm_secret,
1568-
},
1528+
git_ref = "master"
1529+
payload = self._get_tf_base_payload(distro, compose)
1530+
payload["test"] = {
1531+
"tmt": {
1532+
"url": git_repo,
1533+
"ref": git_ref,
15691534
},
15701535
}
1536+
return payload
15711537

15721538
@implements_fedora_ci_test(
15731539
"rpminspect",

tests/integration/test_listen_to_fedmsg.py

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from packit.config.requirements import LabelRequirementsConfig, RequirementsConfig
2727
from packit.copr_helper import CoprHelper
2828
from packit.local_project import LocalProject, LocalProjectBuilder
29+
from packit.utils import commands
2930
from packit.utils.koji_helper import KojiHelper
3031

3132
import packit_service.service.urls as urls
@@ -65,7 +66,6 @@
6566
from packit_service.worker.helpers.testing_farm import (
6667
TestingFarmClient,
6768
TestingFarmJobHelper,
68-
commands,
6969
)
7070
from packit_service.worker.jobs import SteveJobs
7171
from packit_service.worker.monitoring import Pushgateway
@@ -2676,40 +2676,6 @@ def test_koji_build_end_downstream(
26762676
koji_build_pr_downstream.should_receive("set_status").with_args("success").once()
26772677
koji_build_pr_downstream.should_receive("set_build_logs_urls")
26782678
koji_build_pr_downstream.should_receive("set_web_url")
2679-
2680-
installability_repo = "https://github.com/fedora-ci/installability-pipeline.git"
2681-
installability_hash = "f6cd4a50476d9c8ffa36472c5ab2d2c8aad6cee1"
2682-
2683-
flexmock(commands).should_receive("run_command").with_args(
2684-
["git", "ls-remote", installability_repo, "HEAD"], output=True
2685-
).and_return(flexmock(stdout=f"{installability_hash}\tHEAD"))
2686-
2687-
payload_installability = {
2688-
"test": {
2689-
"tmt": {
2690-
"url": installability_repo,
2691-
"ref": installability_hash,
2692-
},
2693-
},
2694-
"environments": [
2695-
{
2696-
"arch": "x86_64",
2697-
"os": {"compose": compose},
2698-
"variables": {
2699-
"PROFILE_NAME": profile,
2700-
"TASK_ID": "1",
2701-
},
2702-
},
2703-
],
2704-
"notification": {
2705-
"webhook": {
2706-
"url": "https://stg.packit.dev/api/testing-farm/results",
2707-
"token": "secret token",
2708-
},
2709-
},
2710-
}
2711-
2712-
rpminspect_repo = "https://github.com/fedora-ci/rpminspect-pipeline.git"
27132679
common_payload_no_compose = {
27142680
"environments": [
27152681
{
@@ -2743,6 +2709,20 @@ def test_koji_build_end_downstream(
27432709
},
27442710
}
27452711

2712+
installability_repo = "https://github.com/fedora-ci/installability-pipeline.git"
2713+
payload_installability = {
2714+
"test": {
2715+
"tmt": {
2716+
"url": installability_repo,
2717+
"ref": "master",
2718+
},
2719+
},
2720+
**common_payload_no_compose,
2721+
}
2722+
payload_installability = copy.deepcopy(payload_installability)
2723+
payload_installability["environments"][0]["os"] = {"compose": compose}
2724+
2725+
rpminspect_repo = "https://github.com/fedora-ci/rpminspect-pipeline.git"
27462726
payload_rpminspect = {
27472727
"test": {
27482728
"tmt": {
@@ -2839,10 +2819,6 @@ def test_koji_build_end_downstream(
28392819
distro,
28402820
).and_return(compose)
28412821

2842-
flexmock(KojiHelper).should_receive("get_candidate_tag").with_args("rawhide").and_return(
2843-
"f43-updates-candidate"
2844-
)
2845-
28462822
pipeline_id = "5e8079d8-f181-41cf-af96-28e99774eb68"
28472823
flexmock(TestingFarmClient).should_receive(
28482824
"send_testing_farm_request",

0 commit comments

Comments
 (0)