diff options
author | ChristopherHX <christopher.homberger@web.de> | 2024-01-28 18:02:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-28 18:02:15 +0100 |
commit | 6dd67253bc4ca18ee7ec5e96b8967332fe94dda1 (patch) | |
tree | d5c2e8cf1f11dde16f5314fdc244754b525754c3 /pkg | |
parent | fix: subpath actions via new artifact cache (#2170) (diff) | |
download | forgejo-act-6dd67253bc4ca18ee7ec5e96b8967332fe94dda1.tar.xz forgejo-act-6dd67253bc4ca18ee7ec5e96b8967332fe94dda1.zip |
fix: improve new-action-cache fetch failure error (#2172)
- include repoURL and repoRef in error
- map NoErrAlreadyUptodate to `couldn't find remote ref` for branchOrtag
fetch request
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/runner/action_cache.go | 4 | ||||
-rw-r--r-- | pkg/runner/step_action_remote.go | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/pkg/runner/action_cache.go b/pkg/runner/action_cache.go index 1173206..da4e651 100644 --- a/pkg/runner/action_cache.go +++ b/pkg/runner/action_cache.go @@ -6,6 +6,7 @@ import ( "crypto/rand" "encoding/hex" "errors" + "fmt" "io" "io/fs" "path" @@ -86,6 +87,9 @@ func (c GoGitActionCache) Fetch(ctx context.Context, cacheDir, url, ref, token s Auth: auth, Force: true, }); err != nil { + if tagOrSha && errors.Is(err, git.NoErrAlreadyUpToDate) { + return "", fmt.Errorf("couldn't find remote ref \"%s\"", ref) + } return "", err } if tagOrSha { diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go index 7d0caa8..b34c6d9 100644 --- a/pkg/runner/step_action_remote.go +++ b/pkg/runner/step_action_remote.go @@ -68,9 +68,11 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor { var err error sar.cacheDir = fmt.Sprintf("%s/%s", sar.remoteAction.Org, sar.remoteAction.Repo) - sar.resolvedSha, err = cache.Fetch(ctx, sar.cacheDir, sar.remoteAction.URL+"/"+sar.cacheDir, sar.remoteAction.Ref, github.Token) + repoURL := sar.remoteAction.URL + "/" + sar.cacheDir + repoRef := sar.remoteAction.Ref + sar.resolvedSha, err = cache.Fetch(ctx, sar.cacheDir, repoURL, repoRef, github.Token) if err != nil { - return err + return fmt.Errorf("failed to fetch \"%s\" version \"%s\": %w", repoURL, repoRef, err) } remoteReader := func(ctx context.Context) actionYamlReader { |