mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-31 18:30:58 +00:00
fix: log schema validation errors from actions
Resolves forgejo/runner#809
This commit is contained in:
parent
f567fb0d34
commit
1957b49669
4 changed files with 21 additions and 1 deletions
|
@ -45,7 +45,7 @@ func readActionImpl(ctx context.Context, step *model.Step, actionDir, actionPath
|
|||
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))
|
||||
allErrors = append(allErrors, fmt.Errorf("failed to read '%s' from action '%s' with path '%s': %w", fileName, step.String(), actionPath, err))
|
||||
} else {
|
||||
// One successful read, clear error state
|
||||
allErrors = nil
|
||||
|
@ -112,6 +112,9 @@ func readActionImpl(ctx context.Context, step *model.Step, actionDir, actionPath
|
|||
defer closer.Close()
|
||||
|
||||
action, err := model.ReadAction(reader)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to validate action.y*ml from action '%s' with path '%s': %v", step.String(), actionPath, err)
|
||||
}
|
||||
logger.Debugf("Read action %v from '%s'", action, "Unknown")
|
||||
return action, err
|
||||
}
|
||||
|
|
|
@ -242,6 +242,7 @@ func TestRunner_RunEvent(t *testing.T) {
|
|||
{workdir, "shells/pwsh", "push", "", platforms, secrets},
|
||||
|
||||
// Local action
|
||||
{workdir, "local-action-fails-schema-validation", "push", "Job 'test' failed", platforms, secrets},
|
||||
{workdir, "local-action-docker-url", "push", "", platforms, secrets},
|
||||
{workdir, "local-action-dockerfile", "push", "", platforms, secrets},
|
||||
{workdir, "local-action-via-composite-dockerfile", "push", "", platforms, secrets},
|
||||
|
|
7
act/runner/testdata/local-action-fails-schema-validation/action/action.yml
vendored
Normal file
7
act/runner/testdata/local-action-fails-schema-validation/action/action.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
inputs:
|
||||
leak:
|
||||
default: '${{ secrets.SOMESECRET }}'
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: echo OK
|
9
act/runner/testdata/local-action-fails-schema-validation/push.yml
vendored
Normal file
9
act/runner/testdata/local-action-fails-schema-validation/push.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
name: fails-schema-validation
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://data.forgejo.org/actions/checkout@v4
|
||||
- uses: ./local-action-fails-schema-validation/action
|
Loading…
Add table
Add a link
Reference in a new issue