Skip to content

Commit d90da72

Browse files
ci: lint shell scripts with shellcheck
1 parent b204b82 commit d90da72

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CI enforces this on every pull request via `bash scripts/compute-workflow-sha256
1616

1717
## Linting
1818

19-
Workflows are linted with [actionlint](https://github.com/rhysd/actionlint), which also runs [shellcheck](https://github.com/koalaman/shellcheck) on `run:` scripts. Both tools are pinned in `mise.toml` and `mise.lock`. Install them with [mise](https://mise.jdx.dev):
19+
Workflows are linted with [actionlint](https://github.com/rhysd/actionlint), which also runs [shellcheck](https://github.com/koalaman/shellcheck) on inline `run:` scripts. Shell scripts committed to the repository (`*.sh`, e.g. under `scripts/`) are linted with shellcheck directly. Both tools are pinned in `mise.toml` and `mise.lock`. Install them with [mise](https://mise.jdx.dev):
2020

2121
```sh
2222
mise install --locked

‎mise.toml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ lockfile = true
99
[tasks."lint:actionlint"]
1010
run = "actionlint"
1111

12+
[tasks."lint:shellcheck"]
13+
shell = "bash -euo pipefail -c"
14+
run = "git ls-files -z --cached --others --exclude-standard '*.sh' | xargs -0 -r shellcheck"
15+
1216
[tasks.lint]
13-
depends = [ "lint:actionlint" ]
17+
depends = [ "lint:actionlint", "lint:shellcheck" ]

‎scripts/check-release-please-config.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fi
4040
# --- root key ordering: $schema first, lexicographic, packages last ---
4141
mapfile -t root_keys < <(jq -r 'keys_unsorted[]' "$CONFIG")
4242

43+
# shellcheck disable=SC2016 # literal key name, not an expansion
4344
if [[ "${root_keys[0]-}" != '$schema' ]]; then
4445
say_err "root key order: first key must be \"\$schema\" (got \"${root_keys[0]-<none>}\")"
4546
((failures += 1))
@@ -52,6 +53,7 @@ fi
5253

5354
mid_keys=()
5455
for k in "${root_keys[@]}"; do
56+
# shellcheck disable=SC2016 # literal key name, not an expansion
5557
[[ "$k" == '$schema' || "$k" == 'packages' ]] && continue
5658
mid_keys+=("$k")
5759
done

‎scripts/compute-workflow-sha256.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -uo pipefail
33

4-
cd "$(dirname "$0")/.."
4+
cd "$(dirname "$0")/.." || exit 1
55

66
check=false
77
if [[ "${1:-}" == "--check" ]]; then

0 commit comments

Comments
 (0)