MissingShell
¶
Run step is missing a shell.
Defined by MissingShellRule
which supports workflows in the "Default" ruleset.
Description¶
Specifying a shell explicitly has benefits,
see the shell:
documentation for what changes.
The shell:
can be specified on 3 levels, and the lowest wins:
For Linux / macOS runners it's recommended to specify bash
explicitly, because it adds additional arguments:
-e
: to stop on first error (used for both)-o pipefail
: propagate exit code from error inside a pipe--noprofile
/--norc
start with a clean environment.
For a deeper explanation of -e
/-o
read this gist.
This gives us faster failures and more useful error messages.
It's worth noting that simple shell commands might not warrant an explicit shell, but it's worth adding them anyway:
- for consistency with other steps and workflows.
- for maintainability, in case the command becomes more complex, protection is already in place.
- for copy-paste-ability, when the command or its modified version is "reused" in other workflows.
- for readability, to help the reader understand the environment the script is running in.
Known shortcut: shell: bash
is also recommended for Windows, but it's supported by GitHub Actions.
Compliant examples¶
Compliant example #1¶
Specified shell makes grep fail.
example.yml
on: push jobs: example: runs-on: ubuntu-latest steps: - run: echo "Example" | grep "Missing" | sort shell: bash
Compliant example #2¶
Globally specified shell is inherited to the step.
example.yml
on: push jobs: example: runs-on: ubuntu-latest defaults: run: shell: bash steps: - run: echo "Example" | grep "Missing" | sort
Non-compliant examples¶
Non-compliant example #1¶
Missing shell masks pipe failures.
example.yml
on: push jobs: example: runs-on: ubuntu-latest steps: - run: echo "Example" | grep "Missing" | sort
- Line 6: Step[#0] in Job[example] is missing a shell, specify
bash
for better error handling.
Non-compliant example #2¶
Shell is mandatory for composite action steps.
example.yml
name: Test description: Test runs: using: composite steps: - run: echo "Example" | grep "Missing" | sort