Skip to content
Open
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
3 changes: 2 additions & 1 deletion packit_service/worker/helpers/build/copr_build.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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} "
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
),
),
Expand Down
38 changes: 34 additions & 4 deletions tests/unit/test_build_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,7 @@ def test_copr_project_and_namespace(
),
},
),
"",
[],
False,
id="empty",
),
Expand All @@ -2694,7 +2694,7 @@ def test_copr_project_and_namespace(
),
},
),
"something/different",
["something/different"],
False,
id="not-present",
),
Expand All @@ -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",
),
Expand All @@ -2724,10 +2724,40 @@ def test_copr_project_and_namespace(
),
},
),
"something/different\ngit.instance.io/the/example/namespace/the-example-repo",
["git.instance.io/the/example/namespace/*"],
True,
id="wildcard",
),
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/the-example-repo"],
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(
Expand Down
Loading