[FORGEJO] informative errors when local action is not found
This commit is contained in:
parent
6dc2a8e888
commit
cefe3d8dab
2 changed files with 9 additions and 0 deletions
|
@ -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, "\\", "/")
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue