[FORGEJO] informative errors when local action is not found

(cherry picked from commit cefe3d8dab)
This commit is contained in:
Earl Warren 2023-07-02 10:39:22 +02:00
parent 0c2c019584
commit 1274b349f1
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 9 additions and 0 deletions

View file

@ -42,6 +42,9 @@ var trampoline embed.FS
func readActionImpl(ctx context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) { func readActionImpl(ctx context.Context, step *model.Step, actionDir string, actionPath string, readFile actionYamlReader, writeFile fileWriter) (*model.Action, error) {
logger := common.Logger(ctx) logger := common.Logger(ctx)
reader, closer, err := readFile("action.yml") reader, closer, err := readFile("action.yml")
if err != nil {
logger.Debugf("readActionImpl actionDir %s actionPath %s failed %v", actionDir, actionPath, err)
}
if os.IsNotExist(err) { if os.IsNotExist(err) {
reader, closer, err = readFile("action.yaml") reader, closer, err = readFile("action.yaml")
if err != nil { if err != nil {
@ -439,11 +442,15 @@ func getContainerActionPaths(step *model.Step, actionDir string, rc *RunContext)
actionName = strings.ReplaceAll(actionName, "\\", "/") actionName = strings.ReplaceAll(actionName, "\\", "/")
} }
} }
common.Logger(context.Background()).Debugf("getContainerActionPaths step.Type %s, rc.Config.Workdir %s, actionName %s, containerActionDir %s", step.Type().String(), rc.Config.Workdir, actionName, containerActionDir)
return actionName, containerActionDir return actionName, containerActionDir
} }
func getOsSafeRelativePath(s, prefix string) string { func getOsSafeRelativePath(s, prefix string) string {
actionName := strings.TrimPrefix(s, prefix) actionName := strings.TrimPrefix(s, prefix)
if s == actionName {
common.Logger(context.Background()).Errorf("getOsSafeRelativePath %s does not beging with %s", s, prefix)
}
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
actionName = strings.ReplaceAll(actionName, "\\", "/") actionName = strings.ReplaceAll(actionName, "\\", "/")
} }

View file

@ -44,10 +44,12 @@ func (sal *stepActionLocal) main() common.Executor {
return func(filename string) (io.Reader, io.Closer, error) { return func(filename string) (io.Reader, io.Closer, error) {
tars, err := sal.RunContext.JobContainer.GetContainerArchive(ctx, path.Join(cpath, filename)) tars, err := sal.RunContext.JobContainer.GetContainerArchive(ctx, path.Join(cpath, filename))
if err != nil { if err != nil {
common.Logger(context.Background()).Debugf("stepActionLocal reader %s failed %v", path.Join(cpath, filename), err)
return nil, nil, os.ErrNotExist return nil, nil, os.ErrNotExist
} }
treader := tar.NewReader(tars) treader := tar.NewReader(tars)
if _, err := treader.Next(); err != nil { if _, err := treader.Next(); err != nil {
common.Logger(context.Background()).Debugf("stepActionLocal reader %s failed %v", path.Join(cpath, filename), err)
return nil, nil, os.ErrNotExist return nil, nil, os.ErrNotExist
} }
return treader, tars, nil return treader, tars, nil