fix: crash malformed composite action (#1616)
* fix: crash malformed composite action * Add remote composite action test --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
4b56aced15
commit
53095d76f4
4 changed files with 43 additions and 2 deletions
|
@ -503,7 +503,10 @@ func runPreStep(step actionStep) common.Executor {
|
||||||
step.getCompositeRunContext(ctx)
|
step.getCompositeRunContext(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return step.getCompositeSteps().pre(ctx)
|
if steps := step.getCompositeSteps(); steps != nil && steps.pre != nil {
|
||||||
|
return steps.pre(ctx)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("missing steps in composite action")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
@ -592,7 +595,10 @@ func runPostStep(step actionStep) common.Executor {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return step.getCompositeSteps().post(ctx)
|
if steps := step.getCompositeSteps(); steps != nil && steps.post != nil {
|
||||||
|
return steps.post(ctx)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("missing steps in composite action")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -86,6 +86,10 @@ func execAsComposite(step actionStep) common.Executor {
|
||||||
|
|
||||||
steps := step.getCompositeSteps()
|
steps := step.getCompositeSteps()
|
||||||
|
|
||||||
|
if steps == nil || steps.main == nil {
|
||||||
|
return fmt.Errorf("missing steps in composite action")
|
||||||
|
}
|
||||||
|
|
||||||
ctx = WithCompositeLogger(ctx, &compositeRC.Masks)
|
ctx = WithCompositeLogger(ctx, &compositeRC.Masks)
|
||||||
|
|
||||||
err := steps.main(ctx)
|
err := steps.main(ctx)
|
||||||
|
|
|
@ -299,6 +299,7 @@ func TestRunEvent(t *testing.T) {
|
||||||
{workdir, "do-not-leak-step-env-in-composite", "push", "", platforms, secrets},
|
{workdir, "do-not-leak-step-env-in-composite", "push", "", platforms, secrets},
|
||||||
{workdir, "set-env-step-env-override", "push", "", platforms, secrets},
|
{workdir, "set-env-step-env-override", "push", "", platforms, secrets},
|
||||||
{workdir, "set-env-new-env-file-per-step", "push", "", platforms, secrets},
|
{workdir, "set-env-new-env-file-per-step", "push", "", platforms, secrets},
|
||||||
|
{workdir, "no-panic-on-invalid-composite-action", "push", "jobs failed due to invalid action", platforms, secrets},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
|
@ -401,6 +402,7 @@ func TestRunEventHostEnvironment(t *testing.T) {
|
||||||
{workdir, "do-not-leak-step-env-in-composite", "push", "", platforms, secrets},
|
{workdir, "do-not-leak-step-env-in-composite", "push", "", platforms, secrets},
|
||||||
{workdir, "set-env-step-env-override", "push", "", platforms, secrets},
|
{workdir, "set-env-step-env-override", "push", "", platforms, secrets},
|
||||||
{workdir, "set-env-new-env-file-per-step", "push", "", platforms, secrets},
|
{workdir, "set-env-new-env-file-per-step", "push", "", platforms, secrets},
|
||||||
|
{workdir, "no-panic-on-invalid-composite-action", "push", "jobs failed due to invalid action", platforms, secrets},
|
||||||
}...)
|
}...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
29
pkg/runner/testdata/no-panic-on-invalid-composite-action/push.yml
vendored
Normal file
29
pkg/runner/testdata/no-panic-on-invalid-composite-action/push.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
local-invalid-step:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Foo
|
||||||
|
- uses: Foo/Bar
|
||||||
|
shell: cp {0} action.yml
|
||||||
|
- uses: ./
|
||||||
|
local-missing-steps:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: |
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
shell: cp {0} action.yml
|
||||||
|
- uses: ./
|
||||||
|
remote-invalid-step:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: nektos/act-test-actions/invalid-composite-action/invalid-step@main
|
||||||
|
remote-missing-steps:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: nektos/act-test-actions/invalid-composite-action/missing-steps@main
|
Loading…
Reference in a new issue