Skip to content

Commit fe174af

Browse files
HoTT-stuffclaude
andcommitted
style(ci): [[ ]] tests and named locals in check-actions-lock.sh (SonarCloud S7688/S7679)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7Zo5h4xmXVEeSeQEDvw
1 parent c692533 commit fe174af

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎tools/ci/check-actions-lock.sh‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ lock="$dir/actions.lock"
2727
fail=0
2828
err() { printf '::error::%s\n' "$*"; fail=1; }
2929

30-
[ -f "$lock" ] || { err "actions lockfile missing: $lock"; exit 1; }
30+
[[ -f "$lock" ]] || { err "actions lockfile missing: $lock"; exit 1; }
3131

3232
# The actions a workflow file uses, normalised and sorted.
3333
used() {
34-
grep -E '^[[:space:]]*(-[[:space:]]*)?uses:' "$1" \
34+
local file="$1"
35+
grep -E '^[[:space:]]*(-[[:space:]]*)?uses:' "$file" \
3536
| sed -E 's/^[[:space:]]*(-[[:space:]]*)?uses:[[:space:]]*//; s/[[:space:]]+#.*$//; s/^["'\'']//; s/["'\'']$//; s/[[:space:]]+$//' \
3637
| grep -vE '^(\./|docker://)' \
3738
| grep -v '/\.github/workflows/' \
@@ -41,7 +42,8 @@ used() {
4142

4243
# The actions the lock lists for workflow path $1, sorted.
4344
locked() {
44-
awk -v wf="'$1':" '
45+
local path="$1"
46+
awk -v wf="'$path':" '
4547
/^workflows:/ { inwf = 1; next }
4648
/^dependencies:/ { inwf = 0 }
4749
inwf && $1 == wf { on = 1; next }
@@ -55,25 +57,25 @@ deps=$(awk '/^dependencies:/ { d = 1; next } d && /^ '\''/ { k = $1; gsub(/['
5557

5658
checked=0
5759
for wf in "$dir"/*.yml "$dir"/*.yaml; do
58-
[ -f "$wf" ] || continue
60+
[[ -f "$wf" ]] || continue
5961
rel=".github/workflows/$(basename "$wf")"
6062
checked=$((checked + 1))
6163
u=$(used "$wf")
6264
l=$(locked "$rel")
6365
if ! grep -qF "'$rel':" "$lock"; then
64-
[ -z "$u" ] || err "$rel uses actions but has no actions.lock entry: $(echo $u)"
66+
[[ -z "$u" ]] || err "$rel uses actions but has no actions.lock entry: $(echo $u)"
6567
continue
6668
fi
6769
missing=$(comm -23 <(printf '%s\n' "$u" | sed '/^$/d') <(printf '%s\n' "$l" | sed '/^$/d'))
6870
stale=$(comm -13 <(printf '%s\n' "$u" | sed '/^$/d') <(printf '%s\n' "$l" | sed '/^$/d'))
69-
[ -z "$missing" ] || err "$rel uses actions the lock does not list (regenerate actions.lock): $(echo $missing)"
70-
[ -z "$stale" ] || err "$rel: actions.lock lists actions the workflow no longer uses: $(echo $stale)"
71+
[[ -z "$missing" ]] || err "$rel uses actions the lock does not list (regenerate actions.lock): $(echo $missing)"
72+
[[ -z "$stale" ]] || err "$rel: actions.lock lists actions the workflow no longer uses: $(echo $stale)"
7173
for a in $l; do
7274
printf '%s\n' "$deps" | grep -qxF "$a" || err "actions.lock has no dependencies entry for $a ($rel)"
7375
done
7476
done
7577

76-
if [ "$fail" -ne 0 ]; then
78+
if [[ "$fail" -ne 0 ]]; then
7779
echo "actions.lock check FAILED: a mismatched workflow does not start (startup_failure, zero jobs)."
7880
exit 1
7981
fi

0 commit comments

Comments
 (0)