Skip to content

fix(workflows): branch protection status checks fail when workflow uses on: paths filter - #38237

Merged
bircni merged 9 commits into
go-gitea:mainfrom
Exgene:fix/#36895-skip-status-filter
Jul 1, 2026
Merged

bircni merged 9 commits into
go-gitea:mainfrom
Exgene:fix/#36895-skip-status-filter

Conversation

@Exgene

@Exgene Exgene commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #36895

Problem

When a workflow's event matches (e.g. pull_request or push) but it is excluded by paths, paths-ignore, branches, or branches-ignore, no run was created. Because no run existed, no commit status was emitted, leaving required checks stuck at CommitStatusPending.

Solution

  • Create result enum for detectWorkflows named detectNotApplicable, detectFilteredOut and detectMatched to differentiate between filters and not applicable.
  • Create filtered job list from these enums.
  • Capture these filtered jobs in DetectWorkflows
  • Create commit status with CommitStatusSkipped for the filtered workflows to make required checks pass

Testing

Performed manual testing and skipped status check is shown
image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 27, 2026
@bircni

bircni commented Jun 30, 2026

Copy link
Copy Markdown
Member

could you fix the tests and conflicts?

@Exgene

Exgene commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

oh wonder why the tests are failing will report back

@Exgene

Exgene commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

could you fix the tests and conflicts?

Conflicts, should i create a merge commit? or any other workflow to be followed

@bircni

bircni commented Jun 30, 2026

Copy link
Copy Markdown
Member

could you fix the tests and conflicts?

Conflicts, should i create a merge commit? or any other workflow to be followed

yes please

Exgene added 2 commits June 30, 2026 22:10
…status-filter

# Conflicts:
#	services/actions/notifier_helper.go
#	services/actions/run.go
@Exgene

Exgene commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@bircni made the changes, I have updated test cases accordingly as well so let me know if you want any behavioral changes

@bircni bircni added the backport/v1.27 This PR should be backported to Gitea 1.27 label Jun 30, 2026
@bircni
bircni requested a review from Zettat123 June 30, 2026 16:55
@bircni

bircni commented Jun 30, 2026

Copy link
Copy Markdown
Member

will check

@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 Jun 30, 2026
@Exgene

Exgene commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

right the grep did not find detectWorkflow, and maybe missed that change while merging

@Zettat123

Copy link
Copy Markdown
Contributor

Some logic related to scoped workflows needs to be adjusted. I will check it and make some updates.

@Zettat123

Copy link
Copy Markdown
Contributor

Made some updates in 44c5c28:

  • Check filtered scoped workflows.
  • Directly create commit status to avoid creating extra runs/attempts/jobs

@Exgene @bircni Please review the updates. Feel free to fix or revert if there are any issues :)

@Exgene

Exgene commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

looks good to me, I went with the approach to create skipped status runs because i thought github also did that, apparently not.

@Zettat123

Copy link
Copy Markdown
Contributor

looks good to me, I went with the approach to create skipped status runs because i thought github also did that, apparently not.

Seems like GitHub still hasn't addressed this issue😆

@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 Jul 1, 2026
@bircni
bircni merged commit 6240d8b into go-gitea:main Jul 1, 2026
27 of 28 checks passed
@GiteaBot GiteaBot added this to the 1.27.0 milestone Jul 1, 2026
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Jul 1, 2026
bircni pushed a commit that referenced this pull request Jul 1, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 4, 2026
* 'main' of https://github.com/go-gitea/gitea: (24 commits)
  [skip ci] Updated translations via Crowdin
  fix(actions): make runner list pagination order deterministic (go-gitea#38313)
  fix(release): gate draft release attachments on web download endpoints (go-gitea#38318)
  ci(snap): build snaps natively instead of on launchpad (go-gitea#38312)
  chore: update `eslint-plugin-unicorn` to v70 (go-gitea#38310)
  feat(webhook): support Telegram Bot API 10.1 Rich Messages (go-gitea#38298)
  chore(snap): drop `armhf` build (go-gitea#38311)
  fix(actions): prevent chevron overlap with log text when timestamps are enabled (go-gitea#38227)
  chore: upgrade `go-swagger` to v0.35.0 and enforce zero swagger warnings (go-gitea#38299)
  fix: Improve since/until when counting commits for X-Total-Count (go-gitea#38243)
  chore: remove eslint-plugin-array-func (go-gitea#38294)
  docs: Welcome Zettat to TOC (go-gitea#38303)
  fix(workflows): branch protection status checks fail when workflow uses on: paths filter (go-gitea#38237)
  chore: update node.js to v26 (go-gitea#38285)
  refactor: replace `vue-bar-graph` dependency with inlined SVG chart (go-gitea#38292)
  feat(auth): add `disable-2fa` command (go-gitea#38275)
  fix(oauth2): persist linkAccountData during auto-link 2FA flow (go-gitea#38274)
  fix(actions): allow Actions bot to push to protected branches (go-gitea#38284)
  [skip ci] Updated translations via Crowdin
  feat: extend <video> tag allowed attributes (go-gitea#38279)
  ...
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 4, 2026
* main: (24 commits)
  [skip ci] Updated translations via Crowdin
  fix(actions): make runner list pagination order deterministic (go-gitea#38313)
  fix(release): gate draft release attachments on web download endpoints (go-gitea#38318)
  ci(snap): build snaps natively instead of on launchpad (go-gitea#38312)
  chore: update `eslint-plugin-unicorn` to v70 (go-gitea#38310)
  feat(webhook): support Telegram Bot API 10.1 Rich Messages (go-gitea#38298)
  chore(snap): drop `armhf` build (go-gitea#38311)
  fix(actions): prevent chevron overlap with log text when timestamps are enabled (go-gitea#38227)
  chore: upgrade `go-swagger` to v0.35.0 and enforce zero swagger warnings (go-gitea#38299)
  fix: Improve since/until when counting commits for X-Total-Count (go-gitea#38243)
  chore: remove eslint-plugin-array-func (go-gitea#38294)
  docs: Welcome Zettat to TOC (go-gitea#38303)
  fix(workflows): branch protection status checks fail when workflow uses on: paths filter (go-gitea#38237)
  chore: update node.js to v26 (go-gitea#38285)
  refactor: replace `vue-bar-graph` dependency with inlined SVG chart (go-gitea#38292)
  feat(auth): add `disable-2fa` command (go-gitea#38275)
  fix(oauth2): persist linkAccountData during auto-link 2FA flow (go-gitea#38274)
  fix(actions): allow Actions bot to push to protected branches (go-gitea#38284)
  [skip ci] Updated translations via Crowdin
  feat: extend <video> tag allowed attributes (go-gitea#38279)
  ...
bircni pushed a commit that referenced this pull request Jul 9, 2026
… required contexts (#38371)

Follow #38237

#38237 posts "skipped" commit statuses for every workflow that is not
triggered due to a filter (e.g. `paths` or `branches`) mismatch.
However, for non-required workflows, creating "skipped" commit statuses
for them would generate a lot of noise.

To address this issue, this PR adds a check before creating commit
status:

- For the context that matches any required status check patterns, a
"skipped" commit status will be created. The `Required` label can inform
users that this status check is required, but has been skipped because
of a filter mismatch.
- For a non-required context, nothing will be created.

NOTE: Reducing noise is a best-effort approach and isn't entirely
accurate. When creating commit statuses, it is impossible to predict
which branch protection rule will take effect. Therefore, we have to
compare the commit status context against the required patterns from all
rules. If any rule matches, the context is considered "required".
bircni pushed a commit that referenced this pull request Jul 9, 2026
… required contexts (#38371) (#38385)

Backport #38371 by @Zettat123

Follow #38237

#38237 posts "skipped" commit statuses for every workflow that is not
triggered due to a filter (e.g. `paths` or `branches`) mismatch.
However, for non-required workflows, creating "skipped" commit statuses
for them would generate a lot of noise.

To address this issue, this PR adds a check before creating commit
status:

- For the context that matches any required status check patterns, a
"skipped" commit status will be created. The `Required` label can inform
users that this status check is required, but has been skipped because
of a filter mismatch.

<img width="800" alt="image"
src="/api/public/p/aHR0cHM6Ly9naXRodWIuY29tL2dvLWdpdGVhL2dpdGVhL3B1bGwvJTNDYSUyMGhyZWY9"/api/public/p/aHR0cHM6Ly9naXRodWIuY29tL3VzZXItYXR0YWNobWVudHMvYXNzZXRzLzI2NGZkNzE2LTQxM2MtNDU3ZC1hNWE2LTY3MTcxNzVkMzgwNw">https://github.com/user-attachments/assets/264fd716-413c-457d-a5a6-6717175d3807"
/>

- For a non-required context, nothing will be created.

NOTE: Reducing noise is a best-effort approach and isn't entirely
accurate. When creating commit statuses, it is impossible to predict
which branch protection rule will take effect. Therefore, we have to
compare the commit status context against the required patterns from all
rules. If any rule matches, the context is considered "required".
 
Closes #38351

Co-authored-by: Zettat123 <zettat123@gmail.com>
zeekay pushed a commit to hanzoai/forge that referenced this pull request Jul 26, 2026
zeekay pushed a commit to hanzoai/forge that referenced this pull request Jul 26, 2026
… required contexts (go-gitea#38371)

Follow go-gitea#38237

go-gitea#38237 posts "skipped" commit statuses for every workflow that is not
triggered due to a filter (e.g. `paths` or `branches`) mismatch.
However, for non-required workflows, creating "skipped" commit statuses
for them would generate a lot of noise.

To address this issue, this PR adds a check before creating commit
status:

- For the context that matches any required status check patterns, a
"skipped" commit status will be created. The `Required` label can inform
users that this status check is required, but has been skipped because
of a filter mismatch.
- For a non-required context, nothing will be created.

NOTE: Reducing noise is a best-effort approach and isn't entirely
accurate. When creating commit statuses, it is impossible to predict
which branch protection rule will take effect. Therefore, we have to
compare the commit status context against the required patterns from all
rules. If any rule matches, the context is considered "required".
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 18, 2026
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/v1.27 This PR should be backported to Gitea 1.27 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branch protection status checks fail when workflow uses on: paths filter

5 participants

⌂