Skip to content

Commit

Permalink
Expose Copr repo from all builds in the env var for TF (#2253)
Browse files Browse the repository at this point in the history
The PACKIT_COPR_PROJECT env var will now also include the name of the
Copr project from an additional build, if there is one provided in the
retrigger comment.

CC @inknos

---

RELEASE NOTES BEGIN
`PACKIT_COPR_PROJECT` env var that is exposed to Testing Farm now
includes the Copr project of the additional build specified in comment,
if present.
RELEASE NOTES END
  • Loading branch information
lbarcziova authored Nov 20, 2023
2 parents 40b97a9 + 9f03b5a commit 64504e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packit_service/worker/helpers/testing_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def _payload(
compose: str,
artifacts: Optional[List[Dict[str, Union[List[str], str]]]] = None,
build: Optional["CoprBuildTargetModel"] = None,
additional_build: Optional["CoprBuildTargetModel"] = None,
) -> dict:
"""Prepare a Testing Farm request payload.
Expand All @@ -443,6 +444,8 @@ def _payload(
distro, arch = target.rsplit("-", 1)
tmt = self._construct_test_payload()

packit_copr_projects = []

if build is not None:
build_log_url = build.build_logs_url
srpm_build = build.get_srpm_build()
Expand All @@ -452,9 +455,15 @@ def _payload(
nvr = f"{nvr_data['name']}-{nvr_data['version']}-{nvr_data['release']}"
else:
nvr = None
packit_copr_projects.append(f"{build.owner}/{build.project_name}")
else:
build_log_url = nvr = srpm_url = None

if additional_build is not None:
packit_copr_projects.append(
f"{additional_build.owner}/{additional_build.project_name}"
)

packit_copr_rpms = (
[
package
Expand Down Expand Up @@ -486,8 +495,8 @@ def _payload(
"PACKIT_SOURCE_URL": self.source_project_url,
"PACKIT_TARGET_URL": self.target_project_url,
"PACKIT_PR_ID": self.pr_id,
"PACKIT_COPR_PROJECT": f"{build.owner}/{build.project_name}"
if build
"PACKIT_COPR_PROJECT": " ".join(packit_copr_projects)
if packit_copr_projects
else None,
"PACKIT_COPR_RPMS": " ".join(packit_copr_rpms)
if packit_copr_rpms
Expand Down Expand Up @@ -917,6 +926,7 @@ def prepare_and_send_tf_request(
compose=compose,
artifacts=self._get_artifacts(chroot, build, additional_build),
build=build,
additional_build=additional_build,
)
elif not self.is_fmf_configured() and not self.skip_build:
payload = self._payload_install_test(
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/test_pr_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ def test_pr_test_command_handler_multiple_builds(
"PACKIT_SOURCE_URL": "https://github.com/someone/hello-world",
"PACKIT_TARGET_URL": "https://github.com/packit-service/hello-world",
"PACKIT_PR_ID": 9,
"PACKIT_COPR_PROJECT": "mf/tree",
"PACKIT_COPR_PROJECT": "mf/tree another-owner/another-repo",
"PACKIT_COPR_RPMS": "repo-0:0.1-1.noarch another-repo-0:0.1-1.noarch",
},
"artifacts": [
Expand Down Expand Up @@ -2256,6 +2256,8 @@ def test_pr_test_command_handler_multiple_builds(
"epoch": "0",
}
],
owner="another-owner",
project_name="another-repo",
runs=[run_model2],
)

Expand Down

0 comments on commit 64504e1

Please sign in to comment.