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

Use GitHub Actions compatible globbing for branches, tag, path filter #22804

Merged
merged 6 commits into from
Mar 27, 2023

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Feb 7, 2023

Replaces the current globbing library with a https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet compatible one.

This adds support for

  • paths-ignore, tags-ignore and branches-ignore filters.
  • negative patterns in paths, tags and branches filters
  • using both tags and paths filter on the push event

Original PR https://gitea.com/gitea/act/pulls/13.
nektos/act PR nektos/act#1618 for the workflowpattern package (It can take some months for it to appear in https://gitea.com/gitea/act)

Related to #13539

@ChristopherHX ChristopherHX marked this pull request as ready for review February 7, 2023 16:09
@lunny
Copy link
Member

lunny commented Mar 15, 2023

Could you resolve the conflicts?
Since #23037 merged, maybe we can consider this PR.
One question is why not just use github.com/gobwas/glob?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 15, 2023
@lunny
Copy link
Member

lunny commented Mar 15, 2023

Looks like nektos/act#1618 merged, we can just use those functions with no duplicated copy.

@ChristopherHX ChristopherHX changed the title Fix use actions compatible globbing Use GitHub Actions compatible globbing for branches, tag, path filter Mar 15, 2023
@ChristopherHX
Copy link
Contributor Author

One question is why not just use github.com/gobwas/glob?

Do you mean instead of converting to regex or instead of a custom globbing implementation based on GitHub Actions docs?
I wrote my globbing implementation (workflowpattern is the go port) in c# to allow accurate simulation GitHub Actions locally aiming up to 99% compatibilty and a regex backend is highly portable across languages. I had used minimatch (a c# globbing library, like github.com/gobwas/glob for go but different) until I noticed how much it is different, then I decided to rewite it from scratch.

Looks like nektos/act#1618 merged, we can just use those functions with no duplicated copy.

Not merged in gitea/act, so I'm still waiting for the replicated changes. This was the initial reason to first include it in the act fork and delay gitea's integrations.

@codecov-commenter
Copy link

Codecov Report

Merging #22804 (9d884e8) into main (f521e88) will decrease coverage by 0.01%.
The diff coverage is 43.62%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main   #22804      +/-   ##
==========================================
- Coverage   47.14%   47.14%   -0.01%     
==========================================
  Files        1149     1156       +7     
  Lines      151446   152399     +953     
==========================================
+ Hits        71397    71843     +446     
- Misses      71611    72077     +466     
- Partials     8438     8479      +41     
Impacted Files Coverage Δ
cmd/dump.go 0.67% <0.00%> (ø)
models/actions/run.go 1.64% <0.00%> (-0.08%) ⬇️
models/packages/package.go 45.45% <0.00%> (-1.13%) ⬇️
modules/actions/github.go 0.00% <0.00%> (ø)
modules/actions/workflows.go 0.00% <0.00%> (ø)
modules/doctor/storage.go 31.93% <0.00%> (ø)
modules/setting/git.go 45.45% <ø> (ø)
modules/storage/minio.go 1.51% <0.00%> (-0.06%) ⬇️
modules/structs/user.go 100.00% <ø> (ø)
routers/api/v1/admin/email.go 0.00% <0.00%> (ø)
... and 35 more

... and 14 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lunny lunny added the type/enhancement An improvement of existing functionality label Mar 15, 2023
@lunny lunny added this to the 1.20.0 milestone Mar 15, 2023
@lunny lunny added the outdated/backport/v1.19 This PR should be backported to Gitea 1.19 label Mar 15, 2023
@lunny
Copy link
Member

lunny commented Mar 16, 2023

Since #23512 merged, now can reduce the duplicated code.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 16, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 27, 2023
@wolfogre wolfogre added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 27, 2023
@lunny lunny merged commit 6840258 into go-gitea:main Mar 27, 2023
@lunny lunny removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 27, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 27, 2023
…filter (go-gitea#22804)

Replaces the current globbing library with a
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
compatible one.

This adds support for
- `paths-ignore`, `tags-ignore` and `branches-ignore` filters.
- negative patterns in `paths`, `tags` and `branches` filters
- using both `tags` and `paths` filter on the push event

Original PR https://gitea.com/gitea/act/pulls/13.
nektos/act PR nektos/act#1618 for the
workflowpattern package (It can take some months for it to appear in
https://gitea.com/gitea/act)

Related to go-gitea#13539
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Mar 27, 2023
techknowlogick pushed a commit that referenced this pull request Mar 27, 2023
…filter (#22804) (#23740)

Backport #22804 by @ChristopherHX

Replaces the current globbing library with a
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
compatible one.

This adds support for
- `paths-ignore`, `tags-ignore` and `branches-ignore` filters.
- negative patterns in `paths`, `tags` and `branches` filters
- using both `tags` and `paths` filter on the push event

Original PR https://gitea.com/gitea/act/pulls/13.
nektos/act PR nektos/act#1618 for the
workflowpattern package (It can take some months for it to appear in
https://gitea.com/gitea/act)

Related to #13539

Co-authored-by: ChristopherHX <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 28, 2023
* upstream/main:
  Fix issue due date edit toggle bug (go-gitea#23723)
  Fix profile page email display, respect settings (go-gitea#23747)
  Update Gitea version in docs (go-gitea#23755)
  Fix SVG close tag, improve commit graph page UI alignment (go-gitea#23751)
  Remove incorrect HTML self close tag (go-gitea#23748)
  Refactor repo commit list (go-gitea#23690)
  Fix tags view (go-gitea#23243)
  Add commit info in action page (go-gitea#23210)
  Use GitHub Actions compatible globbing for `branches`, `tag`, `path` filter (go-gitea#22804)
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. outdated/backport/v1.19 This PR should be backported to Gitea 1.19 type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants