Repository navigation
63 lines (52 loc) · 1.95 KB
/
Copy pathshellcheck.yml
File metadata and controls
63 lines (52 loc) · 1.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: shellcheck
on:
push:
branches: [develop, main]
pull_request:
permissions:
contents: read
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run shellcheck with -S warning
run: |
# Install shellcheck if not available
if ! command -v shellcheck &> /dev/null; then
sudo apt-get update
sudo apt-get install -y shellcheck
fi
# Run shellcheck on repo-root *.sh and *.bash files, tests/
# Exclude can-utils/, openimu/
echo "=== Running shellcheck -S warning ==="
# Build file list
files=()
# Add repo-root *.sh and *.bash (can-utils/ and openimu/ are not
# matched by -maxdepth 1 in the first place, so no further
# exclusion is needed for them).
while IFS= read -r f; do
files+=("$f")
done < <(find . -maxdepth 1 -type f \( -name "*.sh" -o -name "*.bash" \) | sort)
# Add tests/ files: tests/run.sh, test_*.sh/bash, fakes/*, diag_fakes/* (all shell scripts)
while IFS= read -r f; do
if [[ -f "$f" ]] && {
[[ "$f" == "tests/run.sh" ]] || \
[[ "$f" == "tests/test_"* ]] || \
[[ "$f" == "tests/fakes/"* ]] || \
[[ "$f" == "tests/diag_fakes/"* ]]; }; then
# Only add if it's a shell script (bash/sh shebang, or *.sh/*.bash)
if head -1 "$f" 2>/dev/null | grep -qE '^#!.*\b(ba)?sh\b' || [[ "$f" =~ \.(sh|bash)$ ]]; then
files+=("$f")
fi
fi
done < <(find tests/ -type f 2>/dev/null | sort)
if (( ${#files[@]} > 0 )); then
shellcheck -S warning "${files[@]}"
else
echo "No shell files found to check"
fi
- name: Run tests
run: |
cd tests
bash run.sh