fix: rework setupShellCommand (#930)
* fix: rework `setupShellCommand` * move all logic to separate function so we can test that later * split `step.Shell` and `step.WorkingDirectory` setup into own funcs * general cleanup of function * use `ActPath` to not collide with checked out repository * use `shellquote.Split()` instead of `strings.Fields()` for better command split * replace single string concat with `fmt` Signed-off-by: hackercat <me@hackerc.at> * lint(editorconfig): ignore *_test.go due to mixed style Signed-off-by: hackercat <me@hackerc.at>
This commit is contained in:
18
pkg/runner/testdata/shells/bash/push.yml
vendored
18
pkg/runner/testdata/shells/bash/push.yml
vendored
@@ -1,9 +1,11 @@
|
||||
on: push
|
||||
env:
|
||||
MY_SHELL: bash
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- shell: bash
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
if [[ -n "$BASH" ]]; then
|
||||
echo "I'm $BASH!"
|
||||
@@ -14,10 +16,22 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: node:12-buster-slim
|
||||
steps:
|
||||
- shell: bash
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
if [[ -n "$BASH" ]]; then
|
||||
echo "I'm $BASH!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- run: |
|
||||
if [[ -n "$BASH" ]]; then
|
||||
echo "I'm $BASH!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
14
pkg/runner/testdata/shells/custom/push.yml
vendored
Normal file
14
pkg/runner/testdata/shells/custom/push.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
on: push
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# prints version and exits, it's not valid (for github) if {0} is not included
|
||||
- shell: pwsh -v '. {0}'
|
||||
run: ''
|
||||
check-container:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/justingrote/act-pwsh:latest
|
||||
steps:
|
||||
- shell: pwsh -v '. {0}'
|
||||
run: ''
|
14
pkg/runner/testdata/shells/pwsh/push.yml
vendored
14
pkg/runner/testdata/shells/pwsh/push.yml
vendored
@@ -1,15 +1,25 @@
|
||||
on: push
|
||||
env:
|
||||
MY_SHELL: pwsh
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- shell: pwsh
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
$PSVersionTable
|
||||
check-container:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/justingrote/act-pwsh:latest
|
||||
steps:
|
||||
- shell: pwsh
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
$PSVersionTable
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- run: |
|
||||
$PSVersionTable
|
||||
|
15
pkg/runner/testdata/shells/python/push.yml
vendored
15
pkg/runner/testdata/shells/python/push.yml
vendored
@@ -1,9 +1,11 @@
|
||||
on: push
|
||||
env:
|
||||
MY_SHELL: python
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- shell: python
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
import platform
|
||||
print(platform.python_version())
|
||||
@@ -11,7 +13,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: node:12-buster
|
||||
steps:
|
||||
- shell: python
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
import platform
|
||||
print(platform.python_version())
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- run: |
|
||||
import platform
|
||||
print(platform.python_version())
|
||||
|
18
pkg/runner/testdata/shells/sh/push.yml
vendored
18
pkg/runner/testdata/shells/sh/push.yml
vendored
@@ -1,9 +1,11 @@
|
||||
on: push
|
||||
env:
|
||||
MY_SHELL: sh
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- shell: sh
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
if [ -z ${BASH+x} ]; then
|
||||
echo "I'm sh!"
|
||||
@@ -14,10 +16,22 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container: alpine:latest
|
||||
steps:
|
||||
- shell: sh
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
if [ -z ${BASH+x} ]; then
|
||||
echo "I'm sh!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- run: |
|
||||
if [ -z ${BASH+x} ]; then
|
||||
echo "I'm sh!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user