Repository navigation
46 lines (40 loc) · 1.82 KB
/
Copy pathshellcheck.yml
File metadata and controls
46 lines (40 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: shellcheck
on:
push:
paths: ["**.sh", ".github/workflows/shellcheck.yml"]
pull_request:
paths: ["**.sh", ".github/workflows/shellcheck.yml"]
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
# bash -n catches the failure that actually matters here: a syntax error
# that would strand someone half-way through a 30-minute install.
- name: Syntax check
run: |
for f in *.sh; do
echo "== $f"
bash -n "$f"
done
# shellcheck runs at warning severity. These scripts intentionally
# avoid `set -e`/`set -u` (see the header comment in termux-linux-setup.sh),
# which trips a lot of shellcheck's style and info-level advice.
- name: shellcheck
run: shellcheck --severity=warning --shell=bash *.sh
# The flag parser runs before anything Termux-specific, so it can be
# exercised on a normal runner. Also checks the scripts refuse to run
# outside Termux instead of half-installing.
- name: CLI smoke test
run: |
bash termux-linux-setup.sh --help | grep -q -- "--de"
bash setup-homeassistant.sh --help | grep -q -- "--no-hacs"
! bash termux-linux-setup.sh --de nope 2>/dev/null
! bash termux-linux-setup.sh --bogus 2>/dev/null
! bash setup-homeassistant.sh --bogus 2>/dev/null
out=$(HOME=$(mktemp -d) PREFIX=/nonexistent bash termux-linux-setup.sh -y 2>&1 < /dev/null || true)
echo "$out" | grep -q "must be run inside Termux"
out=$(HOME=$(mktemp -d) PREFIX=/nonexistent bash setup-homeassistant.sh -y 2>&1 < /dev/null || true)
echo "$out" | grep -q "must be run inside Termux"