Skip to content

Commit ff8f821

Browse files
ci: add shell/json/python lint workflow (#64)
## Summary Adds `.github/workflows/ci.yml` — a minimal lint workflow that runs on every `pull_request` and on `push` to `main`. Checks (vendor excluded — `scripts/vendor/**` is forward-ported upstream-first): - **Shell syntax**: `bash -n` on every `*.sh` - **Shellcheck**: `--severity=error` only (keeps the signal high; raise the floor to `warning` once the tree is clean) - **JSON**: `python3 json.load` on every `*.json` - **Python**: `python3 -m py_compile` on every `*.py` All four checks pass locally on the current `main` (34 shell scripts, 5 JSON files, 2 Python files). ## Why `--severity=error` and not stricter Shellcheck at `warning` or `info` produces a lot of style noise on an established shell codebase. Starting at `error` catches real bugs (unquoted expansions that will break at runtime, wrong variable references, etc.) without blocking day-to-day PRs. The comment in the workflow flags this as an explicit choice to tighten later. ## Test plan - [ ] Open this PR → verify the `lint (shell / json / python)` job runs and passes. - [ ] Intentionally break a shell script on a throwaway branch (`bash -n` error) → verify CI fails. - [ ] Intentionally break a JSON file → verify CI fails with `::error file=...::invalid JSON`. - [ ] Confirm `scripts/vendor/brcs/BRCS.sh` is **not** linted (adding a syntax error there should be ignored by CI). https://claude.ai/code/session_017cykH875moQgptoFGxfQai
2 parents 508da3e + 5a8aceb commit ff8f821

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
# Vendored upstream code (scripts/vendor/**) is excluded from every check —
9+
# we forward-port bug fixes upstream-first, so we don't gate our CI on it.
10+
11+
jobs:
12+
lint:
13+
name: lint (shell / json / python)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install shellcheck
19+
run: sudo apt-get update && sudo apt-get install -y shellcheck
20+
21+
- name: List targets
22+
id: targets
23+
shell: bash
24+
run: |
25+
set -euo pipefail
26+
mapfile -t SH_FILES < <(
27+
find . -type f -name '*.sh' \
28+
-not -path './.git/*' \
29+
-not -path './scripts/vendor/*' \
30+
| sort
31+
)
32+
mapfile -t JSON_FILES < <(
33+
find . -type f -name '*.json' \
34+
-not -path './.git/*' \
35+
-not -path './scripts/vendor/*' \
36+
| sort
37+
)
38+
mapfile -t PY_FILES < <(
39+
find . -type f -name '*.py' \
40+
-not -path './.git/*' \
41+
-not -path './scripts/vendor/*' \
42+
| sort
43+
)
44+
printf 'sh files: %d\n' "${#SH_FILES[@]}"
45+
printf 'json files: %d\n' "${#JSON_FILES[@]}"
46+
printf 'py files: %d\n' "${#PY_FILES[@]}"
47+
printf '%s\n' "${SH_FILES[@]}" > sh.list
48+
printf '%s\n' "${JSON_FILES[@]}" > json.list
49+
printf '%s\n' "${PY_FILES[@]}" > py.list
50+
51+
- name: Shell syntax (bash -n)
52+
shell: bash
53+
run: |
54+
set -euo pipefail
55+
status=0
56+
while IFS= read -r f; do
57+
[ -z "$f" ] && continue
58+
if ! bash -n "$f"; then
59+
echo "::error file=$f::bash -n failed"
60+
status=1
61+
fi
62+
done < sh.list
63+
exit $status
64+
65+
- name: Shellcheck (errors only)
66+
shell: bash
67+
run: |
68+
set -euo pipefail
69+
# --severity=error keeps CI focused on real bugs (SC2xxx style
70+
# warnings are useful but noisy on an established codebase). Raise
71+
# the floor to 'warning' later once the tree is clean.
72+
if [ ! -s sh.list ]; then exit 0; fi
73+
xargs -a sh.list shellcheck --severity=error --shell=bash
74+
75+
- name: JSON validation
76+
shell: bash
77+
run: |
78+
set -euo pipefail
79+
status=0
80+
while IFS= read -r f; do
81+
[ -z "$f" ] && continue
82+
if ! python3 -c "import json,sys; json.load(open(sys.argv[1]))" "$f"; then
83+
echo "::error file=$f::invalid JSON"
84+
status=1
85+
fi
86+
done < json.list
87+
exit $status
88+
89+
- name: Python syntax (py_compile)
90+
shell: bash
91+
run: |
92+
set -euo pipefail
93+
if [ ! -s py.list ]; then exit 0; fi
94+
xargs -a py.list python3 -m py_compile

0 commit comments

Comments
 (0)