fix(actions): make cancelled() work in job if evaluation (#38495)

Fix #38485

#37478 moved `if` evaluation from runner to server. But `NewInterpeter`
always provides a nil `JobContext` for the evaluator, which makes
[`cancelled()`](https://gitea.com/gitea/runner/src/commit/ad967330a8788c9b8ab723abbc1a86d53c3bc5e6/act/exprparser/functions.go#L299)
panic on `Job.Status` because `Job` is a nil pointer.
This commit is contained in:
Zettat123
2026-07-16 14:28:53 -06:00
committed by GitHub
parent f0d9af3a18
commit 2e0aa7ec74
2 changed files with 66 additions and 3 deletions
+8 -3
View File
@@ -57,9 +57,14 @@ func NewInterpeter(
}
ee := &exprparser.EvaluationEnvironment{
Github: gitCtx,
Env: nil, // no need
Job: nil, // no need
Github: gitCtx,
Env: nil, // no need
// Job must be non-nil because cancelled() dereferences Job.Status unconditionally.
// See: https://gitea.com/gitea/runner/src/commit/ad967330a8788c9b8ab723abbc1a86d53c3bc5e6/act/exprparser/functions.go#L299
// TODO: The empty JobContext.Status is right for now because Gitea never checks `if` condition when the workflow run is cancelled.
// This is an implementation gap in Gitea Actions. When a workflow run is cancelled, Gitea should check the job's `if` condition,
// and if the condition is met (e.g. `if: ${{ cancelled() }}` ), the job should be executed rather than cancelled.
Job: &model.JobContext{},
Steps: nil, // no need
Runner: nil, // no need
Secrets: nil, // no need