Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix targets override identifier in check rerun and failed builds related test retriggering #2665

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packit_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ def create(
build.web_url = web_url
build.target = target
build.task_accepted_time = task_accepted_time
build.identifier = identifier or ""
build.identifier = identifier
session.add(build)

copr_build_group.copr_build_targets.append(build)
Expand Down
11 changes: 10 additions & 1 deletion packit_service/worker/events/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ def comment_object(self) -> Optional[Comment]:

@property
def build_targets_override(self) -> Optional[set[tuple[str, str]]]:
if not self._build_targets_override and "rebuild-failed" in self.comment:
# If we do not override the failing builds for the retest-failed comment
# we will later submit all tests.
# Overriding builds for the retest-failed comment will let the test jobs
# see that something has failed and only for those targets the
# tests will be submitted.
if (
not self._build_targets_override
and "rebuild-failed" in self.comment
or "retest-failed" in self.comment
):
self._build_targets_override = (
super().get_all_build_targets_by_status(
statuses_to_filter_with=[BuildStatus.failure],
Expand Down
12 changes: 2 additions & 10 deletions packit_service/worker/events/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,16 @@ def __init__(
)
self.job_identifier = job_identifier

def _parse_target_and_identifier(self, target_string: str) -> tuple[str, str]:
"""Parse target and identifier from check name target string."""
if ":" in target_string:
target, identifier = target_string.split(":")
else:
target, identifier = target_string, ""
return target, identifier

@property
def build_targets_override(self) -> Optional[set[tuple[str, str]]]:
if self.check_name_job in {"rpm-build", "production-build", "koji-build"}:
return {self._parse_target_and_identifier(self.check_name_target)}
return {(self.check_name_target, self.job_identifier)}
return None

@property
def tests_targets_override(self) -> Optional[set[tuple[str, str]]]:
if self.check_name_job == "testing-farm":
return {self._parse_target_and_identifier(self.check_name_target)}
return {(self.check_name_target, self.job_identifier)}
return None

@property
Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/handlers/copr.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def handle_testing_farm(self):
in self.copr_build_helper.build_targets_for_test_job(job_config)
):
event_dict["tests_targets_override"] = [
(target, job_config.identifier or "")
(target, job_config.identifier)
for target in self.copr_build_helper.build_target2test_targets_for_test_job(
self.copr_event.chroot,
job_config,
Expand Down
2 changes: 1 addition & 1 deletion packit_service/worker/handlers/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def copr_build_helper(self) -> CoprBuildJobHelper:
# when reporting state of SRPM build built in Copr
build_targets_override = (
{
(build.target, build.identifier or "")
(build.target, build.identifier)
for build in CoprBuildTargetModel.get_all_by_build_id(
str(self.copr_event.build_id),
)
Expand Down
10 changes: 4 additions & 6 deletions packit_service/worker/helpers/build/build_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def build_targets_for_test_job(self, test_job_config: JobConfig) -> set[str]:
[
target
for (target, identifier) in self.build_targets_override
if identifier == (test_job_config.identifier or "")
if identifier == test_job_config.identifier
]
)

Expand All @@ -285,8 +285,7 @@ def build_targets_for_test_job(self, test_job_config: JobConfig) -> set[str]:
for t in [
target
for (target, identifier) in self.tests_targets_override
if identifier
== (test_job_config.identifier if test_job_config.identifier else "")
if identifier == test_job_config.identifier
]
)

Expand Down Expand Up @@ -326,7 +325,7 @@ def tests_targets_for_test_job(self, test_job_config: JobConfig) -> set[str]:
if self.build_targets_override:
logger.debug(f"Build targets override: {self.build_targets_override}")
for target, identifier in self.build_targets_override:
if identifier == (test_job_config.identifier if test_job_config.identifier else ""):
if identifier == test_job_config.identifier:
targets_override.update(
self.build_target2test_targets_for_test_job(target, test_job_config),
)
Expand All @@ -337,8 +336,7 @@ def tests_targets_for_test_job(self, test_job_config: JobConfig) -> set[str]:
[
target
for target, identifier in self.tests_targets_override
if identifier
== (test_job_config.identifier if test_job_config.identifier else "")
if identifier == test_job_config.identifier
]
)

Expand Down
284 changes: 284 additions & 0 deletions tests/data/webhooks/github/checkrun_rerequested_with_identifier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
{
"action": "rerequested",
"check_run": {
"id": 33642804556,
"name": "testing-farm:fedora-rawhide-x86_64:lint-rawhide",
"node_id": "CR_kwDOCwFO9M8AAAAH1UR1TA",
"head_sha": "b8167b97e3cf94f19aa70037708894e0bff7ac95",
"external_id": "123456",
"url": "https://api.github.com/repos/packit/hello-world/check-runs/33642804556",
"html_url": "https://github.com/packit/hello-world/runs/33642804556",
"details_url": "https://dashboard.stg.packit.dev/jobs/testing-farm/41181",
"status": "completed",
"conclusion": "failure",
"started_at": "2024-11-28T08:15:56Z",
"completed_at": "2024-11-28T08:15:56Z",
"output": {
"title": "Tests failed ...",
"summary": "| Name/Job | URL |\n| --- | --- |\n| Dashboard | https://dashboard.stg.packit.dev/jobs/testing-farm/41181 |\n| Testing Farm | https://artifacts.dev.testing-farm.io/7e58098a-227d-489b-a22b-cde36fda7858 |\n\n\n\n---\n*Curious how Packit handles the Release field during propose-downstream? Take a look [here](https://packit.dev/posts/release-field-handling/) to know more.*",
"text": null,
"annotations_count": 0,
"annotations_url": "https://api.github.com/repos/packit/hello-world/check-runs/33642804556/annotations"
},
"check_suite": {
"id": 31430964947,
"node_id": "CS_kwDOCwFO9M8AAAAHUW520w",
"head_branch": null,
"head_sha": "b8167b97e3cf94f19aa70037708894e0bff7ac95",
"status": "queued",
"conclusion": null,
"url": "https://api.github.com/repos/packit/hello-world/check-suites/31430964947",
"before": null,
"after": null,
"pull_requests": [],
"app": {
"id": 29180,
"client_id": "Iv1.44a7cbb2c22dc368",
"slug": "packit-as-a-service",
"node_id": "MDM6QXBwMjkxODA=",
"owner": {
"login": "packit",
"id": 46870917,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ2ODcwOTE3",
"avatar_url": "https://avatars.githubusercontent.com/u/46870917?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/packit",
"html_url": "https://github.com/packit",
"followers_url": "https://api.github.com/users/packit/followers",
"following_url": "https://api.github.com/users/packit/following{/other_user}",
"gists_url": "https://api.github.com/users/packit/gists{/gist_id}",
"starred_url": "https://api.github.com/users/packit/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/packit/subscriptions",
"organizations_url": "https://api.github.com/users/packit/orgs",
"repos_url": "https://api.github.com/users/packit/repos",
"events_url": "https://api.github.com/users/packit/events{/privacy}",
"received_events_url": "https://api.github.com/users/packit/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"name": "Packit-as-a-Service-stg",
"description": "Packit service (staging). This is a development version! Use only at your own risk. For stable use of packit, use the official app - https://github.com/marketplace/packit-as-a-service",
"external_url": "https://stg.packit.dev",
"html_url": "https://github.com/apps/packit-as-a-service-stg",
"created_at": "2019-04-17T17:25:29Z",
"updated_at": "2024-10-14T10:24:20Z",
"permissions": {
"checks": "write",
"contents": "read",
"issues": "write",
"metadata": "read",
"pull_requests": "write",
"statuses": "write"
},
"events": [
"check_run",
"commit_comment",
"issue_comment",
"pull_request",
"push",
"release"
]
},
"created_at": "2024-11-28T08:06:27Z",
"updated_at": "2024-11-28T08:17:16Z"
},
"app": {
"id": 29180,
"client_id": "Iv1.44a7cbb2c22dc368",
"slug": "packit-as-a-service",
"node_id": "MDM6QXBwMjkxODA=",
"owner": {
"login": "packit",
"id": 46870917,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ2ODcwOTE3",
"avatar_url": "https://avatars.githubusercontent.com/u/46870917?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/packit",
"html_url": "https://github.com/packit",
"followers_url": "https://api.github.com/users/packit/followers",
"following_url": "https://api.github.com/users/packit/following{/other_user}",
"gists_url": "https://api.github.com/users/packit/gists{/gist_id}",
"starred_url": "https://api.github.com/users/packit/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/packit/subscriptions",
"organizations_url": "https://api.github.com/users/packit/orgs",
"repos_url": "https://api.github.com/users/packit/repos",
"events_url": "https://api.github.com/users/packit/events{/privacy}",
"received_events_url": "https://api.github.com/users/packit/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"name": "Packit-as-a-Service-stg",
"description": "Packit service (staging). This is a development version! Use only at your own risk. For stable use of packit, use the official app - https://github.com/marketplace/packit-as-a-service",
"external_url": "https://stg.packit.dev",
"html_url": "https://github.com/apps/packit-as-a-service-stg",
"created_at": "2019-04-17T17:25:29Z",
"updated_at": "2024-10-14T10:24:20Z",
"permissions": {
"checks": "write",
"contents": "read",
"issues": "write",
"metadata": "read",
"pull_requests": "write",
"statuses": "write"
},
"events": [
"check_run",
"commit_comment",
"issue_comment",
"pull_request",
"push",
"release"
]
},
"pull_requests": []
},
"repository": {
"id": 184635124,
"node_id": "MDEwOlJlcG9zaXRvcnkxODQ2MzUxMjQ=",
"name": "hello-world",
"full_name": "packit/hello-world",
"private": false,
"owner": {
"login": "packit",
"id": 46870917,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ2ODcwOTE3",
"avatar_url": "https://avatars.githubusercontent.com/u/46870917?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/packit",
"html_url": "https://github.com/packit",
"followers_url": "https://api.github.com/users/packit/followers",
"following_url": "https://api.github.com/users/packit/following{/other_user}",
"gists_url": "https://api.github.com/users/packit/gists{/gist_id}",
"starred_url": "https://api.github.com/users/packit/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/packit/subscriptions",
"organizations_url": "https://api.github.com/users/packit/orgs",
"repos_url": "https://api.github.com/users/packit/repos",
"events_url": "https://api.github.com/users/packit/events{/privacy}",
"received_events_url": "https://api.github.com/users/packit/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"html_url": "https://github.com/packit/hello-world",
"description": "The most progresive command-line tool in the world.",
"fork": false,
"url": "https://api.github.com/repos/packit/hello-world",
"forks_url": "https://api.github.com/repos/packit/hello-world/forks",
"keys_url": "https://api.github.com/repos/packit/hello-world/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/packit/hello-world/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/packit/hello-world/teams",
"hooks_url": "https://api.github.com/repos/packit/hello-world/hooks",
"issue_events_url": "https://api.github.com/repos/packit/hello-world/issues/events{/number}",
"events_url": "https://api.github.com/repos/packit/hello-world/events",
"assignees_url": "https://api.github.com/repos/packit/hello-world/assignees{/user}",
"branches_url": "https://api.github.com/repos/packit/hello-world/branches{/branch}",
"tags_url": "https://api.github.com/repos/packit/hello-world/tags",
"blobs_url": "https://api.github.com/repos/packit/hello-world/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/packit/hello-world/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/packit/hello-world/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/packit/hello-world/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/packit/hello-world/statuses/{sha}",
"languages_url": "https://api.github.com/repos/packit/hello-world/languages",
"stargazers_url": "https://api.github.com/repos/packit/hello-world/stargazers",
"contributors_url": "https://api.github.com/repos/packit/hello-world/contributors",
"subscribers_url": "https://api.github.com/repos/packit/hello-world/subscribers",
"subscription_url": "https://api.github.com/repos/packit/hello-world/subscription",
"commits_url": "https://api.github.com/repos/packit/hello-world/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/packit/hello-world/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/packit/hello-world/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/packit/hello-world/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/packit/hello-world/contents/{+path}",
"compare_url": "https://api.github.com/repos/packit/hello-world/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/packit/hello-world/merges",
"archive_url": "https://api.github.com/repos/packit/hello-world/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/packit/hello-world/downloads",
"issues_url": "https://api.github.com/repos/packit/hello-world/issues{/number}",
"pulls_url": "https://api.github.com/repos/packit/hello-world/pulls{/number}",
"milestones_url": "https://api.github.com/repos/packit/hello-world/milestones{/number}",
"notifications_url": "https://api.github.com/repos/packit/hello-world/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/packit/hello-world/labels{/name}",
"releases_url": "https://api.github.com/repos/packit/hello-world/releases{/id}",
"deployments_url": "https://api.github.com/repos/packit/hello-world/deployments",
"created_at": "2019-05-02T18:54:46Z",
"updated_at": "2023-01-31T17:16:23Z",
"pushed_at": "2024-11-28T05:17:29Z",
"git_url": "git://github.com/packit/hello-world.git",
"ssh_url": "[email protected]:packit/hello-world.git",
"clone_url": "https://github.com/packit/hello-world.git",
"svn_url": "https://github.com/packit/hello-world",
"homepage": null,
"size": 187,
"stargazers_count": 4,
"watchers_count": 4,
"language": "Python",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"has_discussions": false,
"forks_count": 23,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 98,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [],
"visibility": "public",
"forks": 23,
"open_issues": 98,
"watchers": 4,
"default_branch": "main",
"custom_properties": {}
},
"organization": {
"login": "packit",
"id": 46870917,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ2ODcwOTE3",
"url": "https://api.github.com/orgs/packit",
"repos_url": "https://api.github.com/orgs/packit/repos",
"events_url": "https://api.github.com/orgs/packit/events",
"hooks_url": "https://api.github.com/orgs/packit/hooks",
"issues_url": "https://api.github.com/orgs/packit/issues",
"members_url": "https://api.github.com/orgs/packit/members{/member}",
"public_members_url": "https://api.github.com/orgs/packit/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/46870917?v=4",
"description": "Packit service: package it in an automated way."
},
"sender": {
"login": "majamassarini",
"id": 2678400,
"node_id": "MDQ6VXNlcjI2Nzg0MDA=",
"avatar_url": "https://avatars.githubusercontent.com/u/2678400?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/majamassarini",
"html_url": "https://github.com/majamassarini",
"followers_url": "https://api.github.com/users/majamassarini/followers",
"following_url": "https://api.github.com/users/majamassarini/following{/other_user}",
"gists_url": "https://api.github.com/users/majamassarini/gists{/gist_id}",
"starred_url": "https://api.github.com/users/majamassarini/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/majamassarini/subscriptions",
"organizations_url": "https://api.github.com/users/majamassarini/orgs",
"repos_url": "https://api.github.com/users/majamassarini/repos",
"events_url": "https://api.github.com/users/majamassarini/events{/privacy}",
"received_events_url": "https://api.github.com/users/majamassarini/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"installation": {
"id": 1924121,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTkyNDEyMQ=="
}
}
Loading
Loading