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

A way to set specific branches triggered on push (commit). #664

Open
2 tasks
junaruga opened this issue Jun 5, 2023 · 7 comments
Open
2 tasks

A way to set specific branches triggered on push (commit). #664

junaruga opened this issue Jun 5, 2023 · 7 comments
Labels
area/general Related to whole service, not a specific part/integration. complexity/easy-fix No planning/thinking about design needed, should be finished in an hour. gain/low This doesn't bring that much value to users. impact/low This issue impacts only a few users. kind/documentation Documentation needs updates.

Comments

@junaruga
Copy link

junaruga commented Jun 5, 2023

Description

I want to run Packit as a service on push for the specific branches. I want to trigger any branches except master branch. Below is my current .packit.yml configuration. Is there a way to do it? I check the https://dashboard.packit.dev/pipelines page. But it seems nothing triggers in the push for a branch with the following configuration. Does the current branch: syntax support the regular expression?

jobs:
  - &copr
    job: copr_build
    trigger: pull_request
    enable_net: true
    targets:
      # https://packit.dev/docs/configuration/#available-copr-build-targets
      - fedora-rawhide-x86_64
      - fedora-rawhide-i386
      - fedora-rawhide-aarch64
      - fedora-rawhide-ppc64le
      - fedora-rawhide-s390x

  - <<: *copr
    # Run on push to any branch.
    trigger: commit

Benefit

Users can test their commit by running on CI before sending the PR to the target repository.

Importance

GitHub Actions have the feature to set the triggered branches using the wildcard by branches and branches-ignore syntax.
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#using-filters
https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-excluding-branches

Workaround

  • There is an existing workaround that can be used until this feature is implemented.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)
@mfocko
Copy link
Member

mfocko commented Jun 5, 2023

I have implemented a way to process regex for the branch option on trigger: commit. It was part of experiments with the merge queues on GitHub, so it is not yet documented and well tested.

I would suggest trying:

  - <<: *copr
    # Run on push to any branch.
    trigger: commit
    branch: '^(?!.*master)'

@junaruga junaruga changed the title A way to set specific branches triggered on push (cocmmit). A way to set specific branches triggered on push (commit). Jun 5, 2023
@junaruga
Copy link
Author

junaruga commented Jun 6, 2023

Thanks for the suggestion. Why is it the branch: '^(?!.*master)' rather than branch: '^(?!master)'?

@junaruga
Copy link
Author

junaruga commented Jun 6, 2023

Checking the Python regular expression syntax (?!...) at https://docs.python.org/3/library/re.html. If you trim the heading and tailing spaces of the value of the branch. I think we can omit the ^ in the '^(?!master)' too.

@junaruga
Copy link
Author

junaruga commented Jun 6, 2023

I experimented.

$ python3 --version
Python 3.11.3

$ python3
...
>>> import re
>>> p = re.compile('^(?!master)')
>>> print(p.match('master'))
None
>>> print(p.match(' master'))
<re.Match object; span=(0, 0), match=''>
>>> print(p.match('amaster'))
<re.Match object; span=(0, 0), match=''>
>>> print(p.match('mastera'))
None
>>> import re
>>> p = re.compile('(?!master)')
>>> print(p.match('master'))
None
>>> print(p.match('amaster'))
<re.Match object; span=(0, 0), match=''>
>>> print(p.match(' master'))
<re.Match object; span=(0, 0), match=''>
>>> print(p.match('mastera'))
None
>>> print(p.match('master '))
None

@junaruga
Copy link
Author

junaruga commented Jun 6, 2023

It seems I was able to run the CI on the push on a branch (wip/packit-copr-push).
https://dashboard.packit.dev/results/copr-builds/810710

+    branch: '(?!master)'

@mfocko
Copy link
Member

mfocko commented Jun 6, 2023

Thanks for letting me know, I'll transfer it to the repo with docs, so it can be properly documented.

ad the suggested regex, it was just a guess :)

@mfocko mfocko transferred this issue from packit/packit Jun 6, 2023
@junaruga
Copy link
Author

junaruga commented Jun 6, 2023

Okay. Thanks for implementing this!

@lachmanfrantisek lachmanfrantisek added kind/documentation Documentation needs updates. area/general Related to whole service, not a specific part/integration. complexity/easy-fix No planning/thinking about design needed, should be finished in an hour. gain/low This doesn't bring that much value to users. impact/low This issue impacts only a few users. labels Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/general Related to whole service, not a specific part/integration. complexity/easy-fix No planning/thinking about design needed, should be finished in an hour. gain/low This doesn't bring that much value to users. impact/low This issue impacts only a few users. kind/documentation Documentation needs updates.
Projects
Status: backlog
Development

No branches or pull requests

3 participants