RedundantDefaultShell
¶
Same default shell is defined both on job and workflow.
Defined by RedundantShellRule
which supports workflows in the "Default" ruleset along with RedundantShell
.
Description¶
Duplication can lead to confusion.
The default shell:
can be specified on 2 levels, and the lowest wins:
This means that when the workflow has the shell defined, the job's definition is not necessary.
It is, however, recommended that the shell is defined on a per-job basis, because each job can have different runners.
This results in
- explicit definitions: each job has their shells defined.
- better locality: each job has their shell defined closer to usage.
- clear separation:
runs-on
andefaults.run.shell
are on the same level. - better copy-paste-ability: when a job is copied or moved, it can't break because of changed or missing shell.
Compliant examples¶
Compliant example #1¶
Default shell is defined on workflow.
example.yml
on: push defaults: run: shell: bash jobs: example: runs-on: ubuntu-latest steps: - run: echo "Example"
Compliant example #2¶
Default shell is defined on job.
example.yml
on: push jobs: example: runs-on: ubuntu-latest defaults: run: shell: bash steps: - run: echo "Example"
Non-compliant example¶
Same default shell is defined on both workflow and job.
example.yml
on: push defaults: run: shell: bash jobs: example: runs-on: ubuntu-latest defaults: run: shell: bash steps: - run: echo "Example"
- Line 6: Both Job[example] and Workflow[example] has
bash
shell as default, one of them can be removed.