Skip to content

Commit 19bab6f

Browse files
authored
Merge branch 'main' into rebase/forgejo
2 parents e2278a3 + 56dc679 commit 19bab6f

11 files changed

Lines changed: 179 additions & 19 deletions

File tree

.github/workflows/check-release-notes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ on:
1010
jobs:
1111
check_release_notes:
1212
name: Notes are either written, or there are none
13-
uses: packit/.github/.github/workflows/check-release-notes.yml@main
13+
uses: packit/.github/.github/workflows/check-release-notes.yml@2837c96caf71966609451ad0323552ef4be11a23
1414
with:
1515
description: ${{ github.event.pull_request.body }}

.github/workflows/opened-prs-to-the-board.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
if: github.event.pull_request.draft == false
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/add-to-project@v0.3.0
11+
- uses: actions/add-to-project@a9f041ddd462ed185893ea1024cec954f50dbe42 # v0.3.0
1212
with:
1313
project-url: https://github.com/orgs/packit/projects/14
1414
github-token: ${{ secrets.RELEASEBOT_GITHUB_TOKEN }}

.github/workflows/rebuild-and-push-images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
image: packit-service-tests
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
2626

2727
- name: Install QEMU dependency
2828
run: |
@@ -50,7 +50,7 @@ jobs:
5050
- name: Build Image
5151
id: build-image
5252
# https://github.com/marketplace/actions/buildah-build
53-
uses: redhat-actions/buildah-build@v2
53+
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
5454
with:
5555
dockerfiles: ${{ matrix.dockerfile }}
5656
image: ${{ matrix.image }}
@@ -63,7 +63,7 @@ jobs:
6363
6464
- name: Push To Quay
6565
# https://github.com/marketplace/actions/push-to-registry
66-
uses: redhat-actions/push-to-registry@v2
66+
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2
6767
with:
6868
image: ${{ steps.build-image.outputs.image }}
6969
tags: ${{ steps.build-image.outputs.tags }}

.pre-commit-config.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
repos:
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.14.6
7+
rev: 6fec9b7edb08fd9989088709d864a7826dc74e80 # frozen: v0.15.12
88
hooks:
99
- id: ruff
1010
args: [--fix, --exit-non-zero-on-fix]
1111
- id: ruff-format
12+
# 1.18.2 is the last mypy version compatible with Python 3.9
1213
- repo: https://github.com/pre-commit/mirrors-mypy
13-
rev: v1.18.2
14+
rev: 9f70dc58c23dfcca1b97af99eaeee3140a807c7e # frozen: v1.18.2
1415
hooks:
1516
- id: mypy
1617
args: [
@@ -36,12 +37,12 @@ repos:
3637
]
3738
exclude: files/scripts/
3839
- repo: https://github.com/pre-commit/mirrors-prettier
39-
rev: v4.0.0-alpha.8
40+
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
4041
hooks:
4142
- id: prettier
4243
exclude: tests_openshift/openshift_integration/test_data/
4344
- repo: https://github.com/pre-commit/pre-commit-hooks
44-
rev: v6.0.0
45+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
4546
hooks:
4647
- id: check-added-large-files
4748
- id: check-ast
@@ -60,18 +61,18 @@ repos:
6061
- id: mixed-line-ending
6162
- id: trailing-whitespace
6263
- repo: https://github.com/shellcheck-py/shellcheck-py
63-
rev: v0.11.0.1
64+
rev: 745eface02aef23e168a8afb6b5737818efbea95 # frozen: v0.11.0.1
6465
hooks:
6566
- id: shellcheck
6667
- repo: https://github.com/packit/pre-commit-hooks
67-
rev: v1.3.0
68+
rev: ce4b530e5913c1b8651127ace81996464975ef48 # frozen: v1.3.0
6869
hooks:
6970
- id: check-rebase
7071
args:
7172
- https://github.com/packit/packit-service.git
7273
stages: [manual, pre-push]
7374
- repo: https://github.com/packit/requre
74-
rev: 0.9.1
75+
rev: 5b8a0a853928a9bb6204f3a66c510a62cf53fcb7 # frozen: 0.9.1
7576
hooks:
7677
- id: requre-purge
7778
name: Requre response files cleanup
@@ -96,19 +97,19 @@ repos:
9697
files: /tests_openshift.*\.yaml$
9798
stages: [manual, pre-push]
9899
- repo: https://github.com/gitleaks/gitleaks
99-
rev: v8.29.1
100+
rev: 2ca41cc1372d1e939a6a879f18cdc19fc1cac1ce # frozen: v8.30.0
100101
hooks:
101102
- id: gitleaks
102103
# The hook runs 'gitleaks protect --staged' which parses output of
103104
# 'git diff --staged', i.e. always passes in pre-push/manual stage.
104105
stages: [pre-commit]
105106
- repo: https://github.com/python-jsonschema/check-jsonschema
106-
rev: 0.35.0
107+
rev: 943377262562a12b57292fc98fabd7dbf81451fe # frozen: 0.37.2
107108
hooks:
108109
- id: check-github-workflows
109110
args: ["--verbose"]
110111
- repo: https://github.com/Lucas-C/pre-commit-hooks
111-
rev: v1.5.5
112+
rev: ad1b27d73581aa16cca06fc4a0761fc563ffe8e8 # frozen: v1.5.6
112113
hooks:
113114
- id: insert-license
114115
files: \.py$

packit_service/worker/checker/testing_farm.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import logging
55
import os
6+
from pathlib import PurePosixPath
67
from typing import Optional
78

89
from packit_service.constants import (
@@ -342,7 +343,14 @@ def pre_check(self) -> bool:
342343
commit_sha = self.data.event_dict.get("commit_sha")
343344

344345
self.project.get_file_content(
345-
path=".fmf/version",
346+
path=str(
347+
PurePosixPath(
348+
self.job_config.fmf_path.removeprefix("/")
349+
if self.job_config and self.job_config.fmf_path
350+
else "",
351+
".fmf/version",
352+
)
353+
),
346354
ref=commit_sha,
347355
)
348356
except FileNotFoundError:

packit_service/worker/helpers/testing_farm.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,10 @@ def is_fmf_configured(self) -> bool:
691691
return True
692692

693693
return IsFMFConfigPresent(
694-
package_config=None, job_config=None, event=self.metadata.event_dict, task_name=None
694+
package_config=None,
695+
job_config=self.job_config,
696+
event=self.metadata.event_dict,
697+
task_name=None,
695698
).pre_check()
696699

697700
def report_missing_build_chroot(self, chroot: str):

packit_service/worker/jobs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,12 @@ def process_fedora_ci_jobs(self) -> list[TaskResults]:
645645
handlers_triggered_by_job = None
646646
check_target = None
647647

648+
if self.event.db_project_event:
649+
self.event.cancel_cutoff_time = PipelineModel.get_latest_datetime_for_event(
650+
project_event_type=self.event.db_project_event.type,
651+
event_id=self.event.db_project_event.event_id,
652+
)
653+
648654
# [XXX] if there are ever monorepos in Fedora CI…
649655
# monorepo_package = None
650656
if isinstance(self.event, abstract.comment.CommentEvent):

packit_service/worker/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ def parse_logdetective_analysis_event(event) -> Optional[logdetective.Result]:
19281928
analysis_id=analysis_id
19291929
)
19301930
if not log_detective_run:
1931-
logger.error(
1931+
logger.info(
19321932
f"Received results Log Detective analysis: '{analysis_id}' "
19331933
"but no analysis with this id was requested."
19341934
)

tests/integration/test_dg_pr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ def test_downstream_koji_scratch_build(distgit_pr_event, target_branch, uid, che
122122
project=flexmock(project_url="https://src.fedoraproject.org/rpms/optee_os"),
123123
)
124124
db_project_event = (
125-
flexmock().should_receive("get_project_event_object").and_return(db_project_object).mock()
125+
flexmock(type=ProjectEventModelType.pull_request, event_id=9)
126+
.should_receive("get_project_event_object")
127+
.and_return(db_project_object)
128+
.mock()
126129
)
127130
flexmock(ProjectEventModel).should_receive("get_or_create").with_args(
128131
type=ProjectEventModelType.pull_request,

tests/integration/test_koji_build_cancel.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,73 @@ def test_downstream_koji_build_cancel_uses_event_based_filtering(monkeypatch):
517517
job_config=job_config,
518518
)
519519
assert first_dict_value(results["job"])["success"]
520+
521+
522+
def test_downstream_koji_scratch_build_cancel_uses_event_based_filtering(
523+
mock_distgit_pr_functionality,
524+
monkeypatch,
525+
):
526+
"""Test that cancel_cutoff_time is set for Fedora CI scratch builds.
527+
528+
The Fedora CI code path (process_fedora_ci_jobs) used to skip setting
529+
cancel_cutoff_time because it didn't call create_tasks(). This test
530+
verifies the fix: process_fedora_ci_jobs now queries
531+
PipelineModel.get_latest_datetime_for_event and serializes the cutoff
532+
into the event dict, so the handler can cancel stale builds.
533+
"""
534+
monkeypatch.setenv("CANCEL_RUNNING_JOBS", "1")
535+
536+
cutoff_time = datetime(2025, 1, 15, 10, 30, 0, tzinfo=timezone.utc)
537+
538+
# Override the autouse fixture mock — return a specific cutoff time
539+
flexmock(PipelineModel).should_receive("get_latest_datetime_for_event").with_args(
540+
project_event_type=ProjectEventModelType.pull_request,
541+
event_id=9,
542+
).and_return(cutoff_time).once()
543+
544+
# Mocks for the build execution flow inside _run()
545+
flexmock(PackitAPI).should_receive("init_kerberos_ticket")
546+
koji_build_target = flexmock(
547+
id=123,
548+
target="main",
549+
status="queued",
550+
set_status=lambda x: None,
551+
set_task_id=lambda x: None,
552+
set_web_url=lambda x: None,
553+
set_build_logs_urls=lambda x: None,
554+
set_data=lambda x: None,
555+
set_build_submission_stdout=lambda x: None,
556+
)
557+
flexmock(KojiBuildTargetModel).should_receive("create").and_return(koji_build_target)
558+
flexmock(KojiBuildGroupModel).should_receive("create").and_return(
559+
flexmock(grouped_targets=[koji_build_target]),
560+
)
561+
flexmock(commands).should_receive("run_command_remote").and_return(
562+
flexmock(stdout="some output"),
563+
)
564+
flexmock(distgit_handlers).should_receive("get_koji_task_id_and_url_from_stdout").and_return(
565+
(123, "koji-web-url"),
566+
)
567+
568+
# The key assertion: get_running must be called with event-based parameters
569+
flexmock(KojiBuildGroupModel).should_receive("get_running").with_args(
570+
project_event_type=ProjectEventModelType.pull_request,
571+
event_id=9,
572+
created_before=cutoff_time,
573+
targets=None,
574+
).and_return([]).once()
575+
576+
processing_results = SteveJobs().process_message(mock_distgit_pr_functionality)
577+
event_dict, _, job_config, package_config = get_parameters_from_results(
578+
processing_results[:1],
579+
)
580+
581+
# Verify that cancel_cutoff_time was serialized into the event dict
582+
assert event_dict.get("cancel_cutoff_time") == cutoff_time.timestamp()
583+
584+
results = run_downstream_koji_scratch_build_handler(
585+
package_config=package_config,
586+
event=event_dict,
587+
job_config=job_config,
588+
)
589+
assert first_dict_value(results["job"])["success"]

0 commit comments

Comments
 (0)