summaryrefslogtreecommitdiffstats
path: root/pkg/runner
diff options
context:
space:
mode:
authorChristopherHX <christopher.homberger@web.de>2024-01-28 17:37:19 +0100
committerGitHub <noreply@github.com>2024-01-28 17:37:19 +0100
commita6ec2c129a94a9cd488750a3be8b961cff08fd0c (patch)
treee0eab8368614beb4f6847f88317502c55baed08f /pkg/runner
parentrefactor(cmd/root): simplify `parseEnvs` (#2162) (diff)
downloadforgejo-act-a6ec2c129a94a9cd488750a3be8b961cff08fd0c.tar.xz
forgejo-act-a6ec2c129a94a9cd488750a3be8b961cff08fd0c.zip
fix: improve action not found error (#2171)
Diffstat (limited to 'pkg/runner')
-rw-r--r--pkg/runner/action.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/pkg/runner/action.go b/pkg/runner/action.go
index 0af6c65..42742c4 100644
--- a/pkg/runner/action.go
+++ b/pkg/runner/action.go
@@ -3,6 +3,7 @@ package runner
import (
"context"
"embed"
+ "errors"
"fmt"
"io"
"io/fs"
@@ -41,11 +42,24 @@ var trampoline embed.FS
func readActionImpl(ctx context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
logger := common.Logger(ctx)
+ allErrors := []error{}
+ addError := func(fileName string, err error) {
+ if err != nil {
+ allErrors = append(allErrors, fmt.Errorf("failed to read '%s' from action '%s' with path '%s' of step %w", fileName, step.String(), actionPath, err))
+ } else {
+ // One successful read, clear error state
+ allErrors = nil
+ }
+ }
reader, closer, err := readFile("action.yml")
+ addError("action.yml", err)
if os.IsNotExist(err) {
reader, closer, err = readFile("action.yaml")
+ addError("action.yaml", err)
if os.IsNotExist(err) {
- if _, closer, err2 := readFile("Dockerfile"); err2 == nil {
+ _, closer, err := readFile("Dockerfile")
+ addError("Dockerfile", err)
+ if err == nil {
closer.Close()
action := &model.Action{
Name: "(Synthetic)",
@@ -90,12 +104,10 @@ func readActionImpl(ctx context.Context, step *model.Step, actionDir string, act
return action, nil
}
}
- return nil, err
- } else if err != nil {
- return nil, err
}
- } else if err != nil {
- return nil, err
+ }
+ if allErrors != nil {
+ return nil, errors.Join(allErrors...)
}
defer closer.Close()