mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-06-10 02:54:23 +02:00
feat: upload job summary when supported (#917)
- Add GitHub-style Actions **job summaries** support (writes to `GITHUB_STEP_SUMMARY` / `workflow/SUMMARY.md`) and render them in the run UI. - Gitea stores summaries internally (DB) and serves them in the run view payload. - `act_runner` uploads the summary **only when Gitea advertises support** (`X-Gitea-Actions-Capabilities: job-summary`), and warns on upload failures without failing the job. ## Compatibility - New Gitea + old runner: no upload → no summary shown (no behavior change) - New runner + old Gitea: capability not advertised → runner skips upload (no behavior change) ## Issue - Fixes go-gitea/gitea#23721 Reviewed-on: https://gitea.com/gitea/runner/pulls/917 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
This commit is contained in:
@@ -36,15 +36,19 @@ import (
|
||||
|
||||
// RunContext contains info about current job
|
||||
type RunContext struct {
|
||||
Name string
|
||||
Config *Config
|
||||
Matrix map[string]any
|
||||
Run *model.Run
|
||||
EventJSON string
|
||||
Env map[string]string
|
||||
GlobalEnv map[string]string // to pass env changes of GITHUB_ENV and set-env correctly, due to dirty Env field
|
||||
ExtraPath []string
|
||||
CurrentStep string
|
||||
Name string
|
||||
Config *Config
|
||||
Matrix map[string]any
|
||||
Run *model.Run
|
||||
EventJSON string
|
||||
Env map[string]string
|
||||
GlobalEnv map[string]string // to pass env changes of GITHUB_ENV and set-env correctly, due to dirty Env field
|
||||
ExtraPath []string
|
||||
CurrentStep string
|
||||
// CurrentStepIndex is the index of the top-level job step currently executing
|
||||
// (model.Step.Number). Composite sub-steps inherit the outer step's index by
|
||||
// walking the Parent chain; see topLevelRunContext.
|
||||
CurrentStepIndex int
|
||||
StepResults map[string]*model.StepResult
|
||||
IntraActionState map[string]map[string]string
|
||||
ExprEval ExpressionEvaluator
|
||||
@@ -57,6 +61,14 @@ type RunContext struct {
|
||||
Masks []string
|
||||
cleanUpJobContainer common.Executor
|
||||
caller *caller // job calling this RunContext (reusable workflows)
|
||||
// summaryFileInitialized tracks which per-step summary files (workflow/step-summary-N.md)
|
||||
// have already been created on the JobContainer. The runner sets up file-command files
|
||||
// via JobContainer.Copy at the start of every phase, which truncates them — fine for
|
||||
// GITHUB_ENV/OUTPUT/STATE/PATH (consumed per phase) but wrong for GITHUB_STEP_SUMMARY,
|
||||
// which has accumulating semantics. We initialize each step's summary file exactly once
|
||||
// so writes from later phases and from composite sub-steps append to the same file.
|
||||
// Only populated on the top-level RunContext; child RCs walk Parent via topLevelRunContext.
|
||||
summaryFileInitialized map[int]bool
|
||||
// outputTemplate is this combination's pristine snapshot of the job's output expressions,
|
||||
// captured before execution so each matrix combo interpolates from the originals rather
|
||||
// than from a sibling's already-resolved values written into the shared Job.Outputs.
|
||||
@@ -704,6 +716,17 @@ func (rc *RunContext) steps() []*model.Step {
|
||||
return steps
|
||||
}
|
||||
|
||||
// topLevelRunContext walks the Parent chain to the outermost RunContext. Composite
|
||||
// actions create child RunContexts whose sub-steps need to share the outer job step's
|
||||
// summary file path so that nested writes accumulate under the right step_index.
|
||||
func (rc *RunContext) topLevelRunContext() *RunContext {
|
||||
top := rc
|
||||
for top.Parent != nil {
|
||||
top = top.Parent
|
||||
}
|
||||
return top
|
||||
}
|
||||
|
||||
// Executor returns a pipeline executor for all the steps in the job
|
||||
func (rc *RunContext) Executor() (common.Executor, error) {
|
||||
var executor common.Executor
|
||||
|
||||
Reference in New Issue
Block a user