Skip to content

Support wildcards in COPR allowed list#2907

Merged
centosinfra-prod-github-app[bot] merged 2 commits into
packit:mainfrom
evgeni:wildcard
Jun 3, 2026
Merged

Support wildcards in COPR allowed list#2907
centosinfra-prod-github-app[bot] merged 2 commits into
packit:mainfrom
evgeni:wildcard

Conversation

@evgeni
Copy link
Copy Markdown
Contributor

@evgeni evgeni commented Dec 15, 2025

TODO:

  • Write new tests or update the old ones to cover new functionality.
  • Update doc-strings where appropriate.
  • Update or write new documentation in packit/packit.dev.

Fixes #2906

Related to fedora-copr/copr#3804

Merge before/after

RELEASE NOTES BEGIN

Packit now supports wildcards in COPR allow lists

RELEASE NOTES END

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @evgeni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to Packit's COPR integration by allowing the use of wildcards in the allowed list for forge projects. This change provides greater flexibility for users to define broader patterns for permitted projects, simplifying configuration and management, especially for large organizations or projects with consistent naming conventions. The update ensures that the system can now match project names against patterns like git.instance.io/the/example/namespace/* rather than requiring exact matches.

Highlights

  • Wildcard Support for COPR Allowed Lists: Packit now supports the use of wildcards in the packit_forge_projects_allowed configuration for COPR builds, enabling more flexible project matching.
  • Implementation of fnmatch: The fnmatch module has been integrated to provide Unix shell-style wildcard matching capabilities for forge project names against the allowed list.
  • Expanded Test Coverage: New unit tests have been added to validate the correct behavior of wildcard patterns in the COPR allowed list, ensuring the new functionality works as expected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for wildcards in the COPR allowed list, which is a great enhancement. The implementation looks correct, and the added tests cover the new functionality well.

I've added a couple of suggestions to improve the robustness of the code by handling cases where the allowed list might be None, and to add a corresponding test case.

Overall, this is a solid contribution.

)
allowed_projects = copr_project["packit_forge_projects_allowed"]
allowed = self.forge_project in allowed_projects
allowed = any(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The allowed_projects variable could be None if the packit_forge_projects_allowed field is not set in the Copr project settings. This would cause an AttributeError when splitlines() is called. To make this more robust, you can handle the None case.

Suggested change
allowed = any(
allowed = any(fnmatch.fnmatch(self.forge_project, pattern) for pattern in (allowed_projects or "").splitlines())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the API will ever return None here. And the old code wasn't accounting for that either (in doesn't work on None).

Comment on lines +2746 to +2760
pytest.param(
JobConfig(
type=JobType.copr_build,
trigger=JobConfigTriggerType.pull_request,
packages={
"package": CommonPackageConfig(
owner="the-owner",
project="the-project",
),
},
),
"something/different\ngit.instance.io/the/example/namespace/*",
True,
id="wildcard-more-values",
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve test coverage and ensure robustness, please consider adding a test case for when packit_forge_projects_allowed is None. This will verify that the application handles this edge case gracefully without raising an exception.

You could add a parameter like this:

        pytest.param(
            JobConfig(
                type=JobType.copr_build,
                trigger=JobConfigTriggerType.pull_request,
                packages={
                    "package": CommonPackageConfig(
                        owner="the-owner",
                        project="the-project",
                    ),
                },
            ),
            None,
            False,
            id="none-allowed-list",
        ),

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@softwarefactory-project-zuul
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot for the contribution!

Comment thread packit_service/worker/helpers/build/copr_build.py Outdated
Comment thread tests/unit/test_build_helper.py Outdated
@lbarcziova lbarcziova moved this from new to in-review in Packit Kanban Board Dec 17, 2025
lbarcziova added a commit to lbarcziova/copr that referenced this pull request Dec 18, 2025
Schema incorrectly defined field as String instead of List(String),
causing Flask-RESTX to stringify the list in API responses.
Context: packit/packit-service#2907 (comment)

Assisted-by: Cursor(Claude)
nikromen pushed a commit to fedora-copr/copr that referenced this pull request Dec 22, 2025
Schema incorrectly defined field as String instead of List(String),
causing Flask-RESTX to stringify the list in API responses.
Context: packit/packit-service#2907 (comment)

Assisted-by: Cursor(Claude)
@evgeni evgeni requested a review from mfocko as a code owner January 5, 2026 08:03
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@evgeni
Copy link
Copy Markdown
Contributor Author

evgeni commented Jun 3, 2026

@lbarcziova fedora-copr/copr#4092 was deployed, so we can continue this now :)

@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@evgeni evgeni requested a review from lbarcziova June 3, 2026 08:33
Copy link
Copy Markdown
Member

@nforro nforro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@nforro nforro added the mergeit Merge via Zuul label Jun 3, 2026
@centosinfra-prod-github-app
Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app centosinfra-prod-github-app Bot merged commit 379f24d into packit:main Jun 3, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Packit pull requests Jun 3, 2026
@evgeni evgeni deleted the wildcard branch June 3, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergeit Merge via Zuul

Projects

Status: in-review

Development

Successfully merging this pull request may close these issues.

Wildcard support in "Packit allowed forge projects"

5 participants