Fix workflow_run events not creating commit statuses#36616
Fix workflow_run events not creating commit statuses#36616davidetacchini wants to merge 5 commits intogo-gitea:mainfrom
Conversation
Workflows triggered by `workflow_run` events did not produce commit statuses because `getCommitStatusEventNameAndCommitID` had no case for `HookEventWorkflowRun`. The function returned empty strings, so `CreateCommitStatusForRunJobs` silently skipped status creation. Add a `workflow_run` case that walks up the parent run chain (up to 5 levels) to find the original triggering event's commit SHA and attaches the status there. This makes chained `workflow_run` workflows visible in the commit status popover alongside the root workflow.
There was a problem hiding this comment.
Pull request overview
Fixes missing commit statuses for Actions workflows triggered by workflow_run by resolving the original triggering commit SHA via the parent run chain.
Changes:
- Extend
getCommitStatusEventNameAndCommitIDto handleworkflow_runby walking parent runs (up to 5 levels) to find the originating commit SHA. - Update commit status creation to pass
context.Contextinto the helper. - Add unit tests covering direct parent, two-level chained parent, and nil payload handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
services/actions/commit_status.go |
Adds workflow_run support by resolving commit SHA from parent runs; updates helper signature to accept ctx. |
services/actions/commit_status_test.go |
Adds DB-backed unit tests validating commit SHA resolution for workflow_run chains. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Davide Tacchini <84925446+davidetacchini@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Davide Tacchini <84925446+davidetacchini@users.noreply.github.com>
Define MaxWorkflowRunDepth in services/actions and replace all hard-coded occurrences of the magic number 5 (and derived 6) with references to the constant, keeping both enforcement sites and the integration test in sync.
|
Comment authored by @silverwind via Claude Code. Code review notes: Overall: This is a clean fix for a real gap — Specifics:
Looks good. |
|
This was initially intentional to not have any commit status for workflow_run, based on my GitHub Actions knowledge (if this is not correct anymore, please point me to an example on GitHub)
If we do this, wouldn't we need to first fix that too many commit statuses, break Giteas branch protection and Pull Request Ui (if we reach the page size)?, could be also stale knowledge. At least I think the tests needs to be extended to assert for a context name (not only sha + event) to answer my concerns. |
I understand GitHub doesn't create commit statuses for workflow_run events, but I think having them in Gitea improves visibility — you can see at a glance on the commit whether all downstream workflows passed. Happy to hear if there's a strong reason to keep parity with GitHub here.
At each depth level the workflow has a different name, so the contexts are naturally unique (e.g. "after-push / build (workflow_run)" vs "after-after / deploy (workflow_run)"). The only collision would be if someone names two workflows identically at different depths, which seems unlikely. Do you see a realistic scenario I'm missing?
Yes it would — if a workflow triggers on both types: [requested, completed], both runs produce the same context name, so the second overwrites the first. But isn't the end result correct either way? The last run to finish sets the final status (green check or red X), which reflects the actual outcome. The intermediate clobber is transient. If you think this is a real problem, one option would be including the action in the context name (e.g. "Deploy / build (workflow_run / requested)" vs "Deploy / build (workflow_run / completed)"), but I'd rather not add that complexity if the current behavior is fine in practice.
Agreed. I'll add context name assertions to the tests regardless. |
Summary
workflow_runevents did not produce commit statuses becausegetCommitStatusEventNameAndCommitIDhad no case forHookEventWorkflowRun, causing it to return empty strings and silently skip status creation.workflow_runcase that walks up the parent run chain (up to 5 levels) to resolve the original triggering event's commit SHA, then attaches the status to that commit.Test plan
go test -run TestGetCommitStatusEventNameAndCommitID ./services/actions/— all 3 subtests passmake lint-go— 0 issuesworkflow_runworkflows (push → after-push → after-after) to a local Gitea instance built from this branch; all three commit statuses appear on the push commit in the status popover