From ddcdda5ac883ac00f50ac449af47546c0049a9e8 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Mon, 5 Jan 2026 09:00:06 +0100 Subject: [PATCH 1/2] update packit_forge_projects_allowed to be a list in tests See https://github.com/fedora-copr/copr/pull/4092 for details --- tests/integration/test_handler.py | 2 +- tests/unit/test_build_helper.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_handler.py b/tests/integration/test_handler.py index 7e21321c8..f3d4366f7 100644 --- a/tests/integration/test_handler.py +++ b/tests/integration/test_handler.py @@ -224,7 +224,7 @@ def test_precheck_push(github_push_event): config={"username": "nobody"}, project_proxy=flexmock( get=lambda owner, project: { - "packit_forge_projects_allowed": "github.com/packit-service/hello-world", + "packit_forge_projects_allowed": ["github.com/packit-service/hello-world"], }, ), ), diff --git a/tests/unit/test_build_helper.py b/tests/unit/test_build_helper.py index 0f2dc1c32..3b7fbaee2 100644 --- a/tests/unit/test_build_helper.py +++ b/tests/unit/test_build_helper.py @@ -2679,7 +2679,7 @@ def test_copr_project_and_namespace( ), }, ), - "", + [], False, id="empty", ), @@ -2694,7 +2694,7 @@ def test_copr_project_and_namespace( ), }, ), - "something/different", + ["something/different"], False, id="not-present", ), @@ -2709,7 +2709,7 @@ def test_copr_project_and_namespace( ), }, ), - "git.instance.io/the/example/namespace/the-example-repo", + ["git.instance.io/the/example/namespace/the-example-repo"], True, id="present", ), @@ -2724,7 +2724,7 @@ def test_copr_project_and_namespace( ), }, ), - "something/different\ngit.instance.io/the/example/namespace/the-example-repo", + ["something/different", "git.instance.io/the/example/namespace/the-example-repo"], True, id="present-more-values", ), From 382505edcf13bbac65b089cc9becf4ecddae2362 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Mon, 15 Dec 2025 08:45:16 +0100 Subject: [PATCH 2/2] Support wildcards in COPR allowed list Fixes: #2906 --- .../worker/helpers/build/copr_build.py | 3 +- tests/unit/test_build_helper.py | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packit_service/worker/helpers/build/copr_build.py b/packit_service/worker/helpers/build/copr_build.py index c3dae6905..b788f516d 100644 --- a/packit_service/worker/helpers/build/copr_build.py +++ b/packit_service/worker/helpers/build/copr_build.py @@ -1,6 +1,7 @@ # Copyright Contributors to the Packit project. # SPDX-License-Identifier: MIT +import fnmatch import logging import re from collections.abc import Iterable @@ -392,7 +393,7 @@ def is_forge_project_allowed_to_build_in_copr(self) -> bool: self.job_project, ) allowed_projects = copr_project["packit_forge_projects_allowed"] - allowed = self.forge_project in allowed_projects + allowed = any(fnmatch.fnmatch(self.forge_project, pattern) for pattern in allowed_projects) if not allowed: logger.warning( f"git-forge project {self.forge_project} " diff --git a/tests/unit/test_build_helper.py b/tests/unit/test_build_helper.py index 3b7fbaee2..3b049dfa4 100644 --- a/tests/unit/test_build_helper.py +++ b/tests/unit/test_build_helper.py @@ -2713,6 +2713,21 @@ def test_copr_project_and_namespace( True, id="present", ), + pytest.param( + JobConfig( + type=JobType.copr_build, + trigger=JobConfigTriggerType.pull_request, + packages={ + "package": CommonPackageConfig( + owner="the-owner", + project="the-project", + ), + }, + ), + ["git.instance.io/the/example/namespace/*"], + True, + id="wildcard", + ), pytest.param( JobConfig( type=JobType.copr_build, @@ -2728,6 +2743,21 @@ def test_copr_project_and_namespace( True, id="present-more-values", ), + pytest.param( + JobConfig( + type=JobType.copr_build, + trigger=JobConfigTriggerType.pull_request, + packages={ + "package": CommonPackageConfig( + owner="the-owner", + project="the-project", + ), + }, + ), + ["something/different", "git.instance.io/the/example/namespace/*"], + True, + id="wildcard-more-values", + ), ], ) def test_check_if_custom_copr_can_be_used_and_report(