forked from Light-Heart-Labs/DreamServer
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (51 loc) · 1.79 KB
/
lint-shell.yml
File metadata and controls
62 lines (51 loc) · 1.79 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
name: ShellCheck
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
shellcheck:
name: Lint shell scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install ShellCheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
shellcheck --version
- name: Run ShellCheck on dream-server shell scripts
run: |
# Find all .sh files under dream-server/
shfiles=$(find dream-server/ -name '*.sh' -type f)
if [ -z "$shfiles" ]; then
echo "No .sh files found under dream-server/"
exit 0
fi
echo "Found $(echo "$shfiles" | wc -l) shell scripts"
echo ""
# Run shellcheck:
# -e SC1091 exclude "can't follow sourced files"
# -e SC2034 exclude "unused variables" (many are used by sourced files)
# -S warning treat warnings and above as reportable
# shellcheck returns:
# 0 = no issues
# 1 = errors or warnings found
# We fail the job only on error-severity issues by using -S error,
# but still display warnings for visibility.
# First pass: display all warnings and errors for visibility
echo "=== ShellCheck results (warnings + errors) ==="
echo "$shfiles" | xargs shellcheck \
--exclude=SC1091,SC2034 \
--severity=warning \
--format=gcc \
|| true
echo ""
echo "=== Checking for error-severity issues (will fail if found) ==="
# Second pass: fail only on error severity
echo "$shfiles" | xargs shellcheck \
--exclude=SC1091,SC2034 \
--severity=error