Skip to content

Commit 5375654

Browse files
authored
ci: add shellcheck + ruff workflow for shell / Python scripts (#51)
Stretch slice of #34. Adds a path-scoped CI workflow that runs `shellcheck --severity=warning` over all tracked `*.sh` files and `ruff check --output-format=github` over all tracked `*.py` files. Triggers only on `**.sh` / `**.py` / the workflow file itself, so Rust-only diffs don't spin it up. - New `.github/workflows/scripts.yml` with two jobs (shellcheck, ruff). Both exit cleanly when discovery returns no files. - New `ruff.toml` pinning `target-version = "py310"` (Jetson Ubuntu 22.04) with one inline-justified ignore for `E402` — the wakeword scripts under `deploy/scripts/` must redirect ALSA/PortAudio stderr before importing pyaudio, otherwise C-level diagnostics leak into the protocol stdout the scripts use to talk to `voice_loop.rs`. - Ruff pinned to `'ruff==0.6.*'` to avoid minor-version-breakage churn. Independent of the other #34 PRs.
1 parent 339f84f commit 5375654

3 files changed

Lines changed: 92 additions & 0 deletions

File tree

.github/workflows/scripts.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Scripts
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "**.sh"
8+
- "**.py"
9+
- ".github/workflows/scripts.yml"
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- "**.sh"
14+
- "**.py"
15+
- ".github/workflows/scripts.yml"
16+
17+
concurrency:
18+
group: scripts-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
shellcheck:
23+
name: shellcheck
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 5
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Install shellcheck
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y --no-install-recommends shellcheck
32+
- name: Run shellcheck on all .sh files
33+
run: |
34+
set -euo pipefail
35+
mapfile -t files < <(git ls-files '*.sh')
36+
if [ "${#files[@]}" -eq 0 ]; then
37+
echo "no shell scripts to check"
38+
exit 0
39+
fi
40+
printf '%s\n' "${files[@]}"
41+
shellcheck --severity=warning "${files[@]}"
42+
43+
ruff:
44+
name: ruff
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 5
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-python@v5
50+
with:
51+
python-version: "3.12"
52+
- name: Install ruff
53+
run: pip install --no-cache-dir 'ruff==0.6.*'
54+
- name: Discover Python files
55+
id: discover
56+
run: |
57+
set -euo pipefail
58+
mapfile -t files < <(git ls-files '*.py')
59+
if [ "${#files[@]}" -eq 0 ]; then
60+
echo "no python files to check"
61+
echo "found=false" >> "$GITHUB_OUTPUT"
62+
exit 0
63+
fi
64+
printf '%s\n' "${files[@]}"
65+
echo "found=true" >> "$GITHUB_OUTPUT"
66+
- name: ruff check
67+
if: steps.discover.outputs.found == 'true'
68+
run: ruff check --output-format=github .

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
### Added
66

7+
- `.github/workflows/scripts.yml` and `ruff.toml` — shellcheck + ruff
8+
workflow for the stretch slice of issue #34. Discovers all
9+
tracked `*.sh` and `*.py` files via `git ls-files`, then runs
10+
`shellcheck --severity=warning` and `ruff check
11+
--output-format=github`. `ruff.toml` pins `target-version = "py310"`
12+
(Jetson Ubuntu 22.04) and ignores E402, with an inline comment
13+
explaining why: `deploy/scripts/genie-wake-listen.py` and
14+
`genie-wakeword.py` legitimately import after redirecting ALSA stderr
15+
to `/dev/null` so the C-level diagnostic noise from PyAudio doesn't
16+
leak into the protocol stdout. Trigger paths are scoped to `**.sh` /
17+
`**.py` / the workflow file itself so Rust-only changes don't spin up
18+
this job.
719
- First-voice-reply latency banner (issue #19). On the first completed voice
820
cycle of a `genie-core` run, the loop prints a one-shot 5-phase breakdown
921
from end-of-user-speech to first audible audio:

ruff.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Ruff config for genie-claw's helper Python scripts under deploy/scripts/.
2+
# These scripts target the Python that ships with Jetson's Ubuntu 22.04 image.
3+
4+
target-version = "py310"
5+
line-length = 100
6+
7+
[lint]
8+
# E402 (module-level import not at top of file) is intentionally allowed:
9+
# the wakeword scripts have to suppress ALSA stderr and silence scipy/numpy
10+
# warnings *before* importing pyaudio / openwakeword, otherwise the C-level
11+
# diagnostics leak into the protocol stdout.
12+
ignore = ["E402"]

0 commit comments

Comments
 (0)