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

Fix mismatch between hook events and github event types #24048

Merged
merged 12 commits into from
Apr 12, 2023

Conversation

Zettat123
Copy link
Contributor

@Zettat123 Zettat123 commented Apr 11, 2023

Some workflow trigger events can have multiple activity types, such as issues and pull_request, and user can specify which types can trigger the workflow. See GitHub documentation: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

Now some hook events cannot match the workflow trigger events correctly because we don't check the activity types. For example, pull_request_label is an individual hook event. But there isn't a pull_request_label workflow trigger event, we can only use pull_request event's label activity type. If we don't check the activity types, the workflows without the label activity type may be triggered by the pull_request_label event by mistake. We need to improve the match logic.

@Zettat123 Zettat123 added type/bug pr/wip This PR is not ready for review labels Apr 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2023

Codecov Report

Merging #24048 (7a9f777) into main (f521e88) will decrease coverage by 0.07%.
The diff coverage is 38.28%.

❗ Current head 7a9f777 differs from pull request most recent head 62c910b. Consider uploading reports for the commit 62c910b to get more accurate results

@@            Coverage Diff             @@
##             main   #24048      +/-   ##
==========================================
- Coverage   47.14%   47.08%   -0.07%     
==========================================
  Files        1149     1163      +14     
  Lines      151446   153848    +2402     
==========================================
+ Hits        71397    72433    +1036     
- Misses      71611    72895    +1284     
- Partials     8438     8520      +82     
Impacted Files Coverage Δ
cmd/dump.go 0.64% <0.00%> (-0.03%) ⬇️
cmd/mailer.go 0.00% <0.00%> (ø)
cmd/manager.go 0.00% <0.00%> (ø)
cmd/manager_logging.go 0.00% <0.00%> (ø)
cmd/migrate_storage.go 5.76% <0.00%> (-0.12%) ⬇️
cmd/restore_repo.go 0.00% <0.00%> (ø)
cmd/web.go 0.00% <0.00%> (ø)
models/actions/run.go 1.63% <0.00%> (-0.10%) ⬇️
models/actions/runner.go 1.44% <ø> (ø)
models/asymkey/ssh_key_parse.go 60.18% <ø> (+1.54%) ⬆️
... and 62 more

... and 130 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.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 12, 2023
modules/actions/workflows.go Outdated Show resolved Hide resolved
@Zettat123 Zettat123 changed the title WIP: Fix mismatch between hook events and github event types Fix mismatch between hook events and github event types Apr 12, 2023
@Zettat123 Zettat123 removed the pr/wip This PR is not ready for review label Apr 12, 2023
@lunny lunny added the outdated/backport/v1.19 This PR should be backported to Gitea 1.19 label Apr 12, 2023
@lunny lunny modified the milestones: 1.19.1, 1.20.0 Apr 12, 2023
@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 Apr 12, 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 Apr 12, 2023
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 12, 2023
@lunny lunny enabled auto-merge (squash) April 12, 2023 14:04
@lunny
Copy link
Member

lunny commented Apr 12, 2023

L-G-T-M bot

@lunny lunny merged commit 2d91afa into go-gitea:main Apr 12, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 12, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Apr 12, 2023
Some workflow trigger events can have multiple activity types, such as
`issues` and `pull_request`, and user can specify which types can
trigger the workflow. See GitHub documentation:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

Now some hook events cannot match the workflow trigger events correctly
because we don't check the activity types. For example,
`pull_request_label` is an individual hook event. But there isn't a
`pull_request_label` workflow trigger event, we can only use
`pull_request` event's `label` activity type. If we don't check the
activity types, the workflows without the `label` activity type may be
triggered by the `pull_request_label` event by mistake. We need to
improve the match logic.

- [x] [`issues`
](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues)
- [x]
[`issue_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment)
- [x]
[`pull_request`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
- [x]
[`pull_request_review`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review)
- [x]
[`pull_request_review_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment)
- [x]
[`release`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release)
- [x]
[`registry_package`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package)
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Apr 12, 2023
@yardenshoham yardenshoham added backport/manual No power to the bots! Create your backport yourself! and removed backport/done All backports for this PR have been created labels Apr 12, 2023
@yardenshoham
Copy link
Member

Needs manual backport

Zettat123 added a commit to Zettat123/gitea that referenced this pull request Apr 13, 2023
Some workflow trigger events can have multiple activity types, such as
`issues` and `pull_request`, and user can specify which types can
trigger the workflow. See GitHub documentation:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

Now some hook events cannot match the workflow trigger events correctly
because we don't check the activity types. For example,
`pull_request_label` is an individual hook event. But there isn't a
`pull_request_label` workflow trigger event, we can only use
`pull_request` event's `label` activity type. If we don't check the
activity types, the workflows without the `label` activity type may be
triggered by the `pull_request_label` event by mistake. We need to
improve the match logic.

- [x] [`issues`
](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues)
- [x]
[`issue_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment)
- [x]
[`pull_request`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
- [x]
[`pull_request_review`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review)
- [x]
[`pull_request_review_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment)
- [x]
[`release`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release)
- [x]
[`registry_package`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package)
@Zettat123
Copy link
Contributor Author

Backport lint failed because a function called by unit tests does not exist in v1.19. I add a backport #24091 manually.

@6543 6543 added the backport/done All backports for this PR have been created label Apr 13, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 13, 2023
* upstream/main:
  [skip ci] Updated translations via Crowdin
  Bump vm2 from 3.9.15 to 3.9.16 (go-gitea#24089)
  Fix difficult translation for other languages (go-gitea#24070)
  Fix mismatch between hook events and github event types (go-gitea#24048)
  Improve LFS error logs (go-gitea#24072)
  Update the value of the `diffEnd` when click `Show More` btn in the DiffFileTree (go-gitea#24069)
  Add tooltips to `Hide comment type` settings where necessary (go-gitea#21306)
  Use a general approach to access custom/static/builtin assets (go-gitea#24022)
  Make Release Download URLs predictable (go-gitea#23891)
  Expand selected file when clicking file tree (go-gitea#24041)
  Localize milestone related time strings (go-gitea#24051)
  update BSDmakefile to latest version from upstream (go-gitea#24063)
lunny pushed a commit that referenced this pull request Apr 13, 2023
)

Backport #24048

Some workflow trigger events can have multiple activity types, such as
`issues` and `pull_request`, and user can specify which types can
trigger the workflow. See GitHub documentation:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

Now some hook events cannot match the workflow trigger events correctly
because we don't check the activity types. For example,
`pull_request_label` is an individual hook event. But there isn't a
`pull_request_label` workflow trigger event, we can only use
`pull_request` event's `label` activity type. If we don't check the
activity types, the workflows without the `label` activity type may be
triggered by the `pull_request_label` event by mistake. We need to
improve the match logic.

- [x] [`issues`
](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues)
- [x]
[`issue_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment)
- [x]
[`pull_request`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
- [x]
[`pull_request_review`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review)
- [x]
[`pull_request_review_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment)
- [x]
[`release`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release)
- [x]
[`registry_package`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package)
silverwind pushed a commit that referenced this pull request Jul 7, 2023
Fix #25736 
Caused by #24048

Right now we only check the activity type for `pull_request` event when
`types` is specified or there are no `types` and filter. If a workflow
only specifies filters but no `types` like this:
```
on:
  pull_request:
    branches: [main]
```
the workflow will be triggered even if the activity type is not one of
`[opened, reopened, sync]`. We need to check the activity type in this
case.

Co-authored-by: Giteabot <[email protected]>
Zettat123 added a commit to Zettat123/gitea that referenced this pull request Jul 10, 2023
Fix go-gitea#25736
Caused by go-gitea#24048

Right now we only check the activity type for `pull_request` event when
`types` is specified or there are no `types` and filter. If a workflow
only specifies filters but no `types` like this:
```
on:
  pull_request:
    branches: [main]
```
the workflow will be triggered even if the activity type is not one of
`[opened, reopened, sync]`. We need to check the activity type in this
case.

Co-authored-by: Giteabot <[email protected]>
Zettat123 added a commit to Zettat123/gitea that referenced this pull request Jul 10, 2023
Fix go-gitea#25736
Caused by go-gitea#24048

Right now we only check the activity type for `pull_request` event when
`types` is specified or there are no `types` and filter. If a workflow
only specifies filters but no `types` like this:
```
on:
  pull_request:
    branches: [main]
```
the workflow will be triggered even if the activity type is not one of
`[opened, reopened, sync]`. We need to check the activity type in this
case.

Co-authored-by: Giteabot <[email protected]>
silverwind pushed a commit that referenced this pull request Jul 10, 2023
Backport #25746

Fix #25736
Caused by #24048

Right now we only check the activity type for `pull_request` event when
`types` is specified or there are no `types` and filter. If a workflow
only specifies filters but no `types` like this:
```
on:
  pull_request:
    branches: [main]
```
the workflow will be triggered even if the activity type is not one of
`[opened, reopened, sync]`. We need to check the activity type in this
case.

Co-authored-by: Giteabot <[email protected]>
lunny pushed a commit that referenced this pull request Jul 11, 2023
Backport #25746

Fix #25736
Caused by #24048

Right now we only check the activity type for `pull_request` event when
`types` is specified or there are no `types` and filter. If a workflow
only specifies filters but no `types` like this:
```
on:
  pull_request:
    branches: [main]
```
the workflow will be triggered even if the activity type is not one of
`[opened, reopened, sync]`. We need to check the activity type in this
case.
Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this pull request Jul 12, 2023
…o-gitea#25797)

Backport go-gitea#25746

Fix go-gitea#25736
Caused by go-gitea#24048

Right now we only check the activity type for `pull_request` event when
`types` is specified or there are no `types` and filter. If a workflow
only specifies filters but no `types` like this:
```
on:
  pull_request:
    branches: [main]
```
the workflow will be triggered even if the activity type is not one of
`[opened, reopened, sync]`. We need to check the activity type in this
case.

Co-authored-by: Giteabot <[email protected]>
(cherry picked from commit bd1946e)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jul 31, 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 backport/manual No power to the bots! Create your backport yourself! 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/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants