From a53a1c20005614cefd3d6519abd7f76d91467132 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Tue, 10 Jan 2023 22:55:05 +0100 Subject: [PATCH] fix: extra path lost in composite actions (#1531) * test: define test case of path issues Test case for #1528 * test: add multi arch grep * fix: Always use current ExtraPath * replace setup-node with run step * Update push.yml * yaml mistake Co-authored-by: Markus Wolf Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/runner/runner_test.go | 1 + pkg/runner/step_action_remote.go | 1 + pkg/runner/testdata/path-handling/action.yml | 21 +++++++++++ pkg/runner/testdata/path-handling/push.yml | 39 ++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 pkg/runner/testdata/path-handling/action.yml create mode 100644 pkg/runner/testdata/path-handling/push.yml diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go index ceae70c..95fbbcc 100644 --- a/pkg/runner/runner_test.go +++ b/pkg/runner/runner_test.go @@ -201,6 +201,7 @@ func TestRunEvent(t *testing.T) { {"../model/testdata", "strategy", "push", "", platforms, secrets}, // TODO: move all testdata into pkg so we can validate it with planner and runner // {"testdata", "issue-228", "push", "", platforms, }, // TODO [igni]: Remove this once everything passes {"../model/testdata", "container-volumes", "push", "", platforms, secrets}, + {workdir, "path-handling", "push", "", platforms, secrets}, } for _, table := range tables { diff --git a/pkg/runner/step_action_remote.go b/pkg/runner/step_action_remote.go index 00d9502..1783486 100644 --- a/pkg/runner/step_action_remote.go +++ b/pkg/runner/step_action_remote.go @@ -196,6 +196,7 @@ func (sar *stepActionRemote) getCompositeRunContext(ctx context.Context) *RunCon // was already created during the pre stage) env := evaluateCompositeInputAndEnv(ctx, sar.RunContext, sar) sar.compositeRunContext.Env = env + sar.compositeRunContext.ExtraPath = sar.RunContext.ExtraPath } return sar.compositeRunContext } diff --git a/pkg/runner/testdata/path-handling/action.yml b/pkg/runner/testdata/path-handling/action.yml new file mode 100644 index 0000000..8db98c5 --- /dev/null +++ b/pkg/runner/testdata/path-handling/action.yml @@ -0,0 +1,21 @@ +name: output action +description: output action + +inputs: + input: + description: some input + required: false + +outputs: + job-output: + description: some output + value: ${{ steps.gen-out.outputs.step-output }} + +runs: + using: composite + steps: + - name: run step + id: gen-out + run: | + echo "::set-output name=step-output::" + shell: bash diff --git a/pkg/runner/testdata/path-handling/push.yml b/pkg/runner/testdata/path-handling/push.yml new file mode 100644 index 0000000..812c8b8 --- /dev/null +++ b/pkg/runner/testdata/path-handling/push.yml @@ -0,0 +1,39 @@ +name: path tests +on: push +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: "Append to $GITHUB_PATH" + run: | + echo "/opt/hostedtoolcache/node/18.99/x64/bin" >> $GITHUB_PATH + + - name: test path (after setup) + run: | + if ! echo "$PATH" |grep "/opt/hostedtoolcache/node/18.*/\(x64\|arm64\)/bin" ; then + echo "Node binaries not in path: $PATH" + exit 1 + fi + + - id: action-with-output + uses: ./path-handling/ + + - name: test path (after local action) + run: | + if ! echo "$PATH" |grep "/opt/hostedtoolcache/node/18.*/\(x64\|arm64\)/bin" ; then + echo "Node binaries not in path: $PATH" + exit 1 + fi + + - uses: nektos/act-test-actions/composite@main + with: + input: some input + + - name: test path (after remote action) + run: | + if ! echo "$PATH" |grep "/opt/hostedtoolcache/node/18.*/\(x64\|arm64\)/bin" ; then + echo "Node binaries not in path: $PATH" + exit 1 + fi