enhance: download each action repository once per job (#1178)

A job downloads each action repository once, keyed on the clone URL and ref, so repeated `uses:` and different paths of one repository share a checkout. The download is reported once as `{org}/{repo}@{ref}`, the way actions/runner reports it.

The action itself is still read per step, because a repository without an action file gets a synthetic action built from that step's `with.args`.

Fixes https://gitea.com/gitea/runner/issues/1159

---------

Co-authored-by: silverwind <me@silverwind.io>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1178
Reviewed-by: bircni <bircni@icloud.com>
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Lunny Xiao
2026-08-22 17:01:39 +00:00
committed by silverwind
parent 2fa5fe7121
commit c0a07cfb72
11 changed files with 241 additions and 146 deletions
+13 -1
View File
@@ -65,7 +65,8 @@ type RunContext struct {
Parent *RunContext
Masks []string
cleanUpJobContainer common.Executor
caller *caller // job calling this RunContext (reusable workflows)
caller *caller // job calling this RunContext (reusable workflows)
actionDownloads map[string]string // resolved commit per action repository, downloaded once per job
// 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
@@ -1010,6 +1011,17 @@ func (rc *RunContext) topLevelRunContext() *RunContext {
return top
}
// downloadedActions returns the action repositories this job has downloaded, keyed by repository
// and ref. Composite actions reach the job's map through their Parent chain, and a job runs its
// steps one at a time, so the map needs no synchronization.
func (rc *RunContext) downloadedActions() map[string]string {
top := rc.topLevelRunContext()
if top.actionDownloads == nil {
top.actionDownloads = map[string]string{}
}
return top.actionDownloads
}
// Executor returns a pipeline executor for all the steps in the job
func (rc *RunContext) Executor() (common.Executor, error) {
var executor common.Executor