-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (92 loc) · 2.59 KB
/
bash-tests.yml
File metadata and controls
107 lines (92 loc) · 2.59 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Bash Tests
on:
workflow_dispatch:
push:
branches: [main, master, "claude/**"]
paths:
- "**/*.sh"
- "**/*.bats"
- ".github/workflows/bash-tests.yml"
pull_request:
branches: [main, master]
paths:
- "**/*.sh"
- "**/*.bats"
- ".github/workflows/bash-tests.yml"
permissions:
contents: read
jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
with:
scandir: "."
severity: warning
syntax-check:
name: Syntax Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Check bash syntax
run: |
echo "Checking bash script syntax..."
failed=0
while IFS= read -r -d '' script; do
echo "Checking: $script"
if ! bash -n "$script"; then
echo "❌ Syntax error in: $script"
failed=1
fi
done < <(find . -name "*.sh" -type f -print0)
if [[ $failed -eq 1 ]]; then
echo "❌ Some scripts have syntax errors"
exit 1
fi
echo "✅ All scripts passed syntax check"
compatibility:
name: Bash Compatibility
runs-on: ubuntu-latest
strategy:
matrix:
bash-version: ["4.4", "5.0", "5.1", "5.2"]
steps:
- uses: actions/checkout@v5
- name: Test with bash version
env:
BASH_VERSION_TAG: ${{ matrix.bash-version }}
run: |
docker run --rm -v "$PWD:/workspace" -w /workspace "bash:${BASH_VERSION_TAG}" bash -c '
echo "Testing with bash version:"
bash --version | head -1
failed=0
for script in $(find . -name "*.sh" -type f); do
echo "Checking: $script"
if ! bash -n "$script" 2>&1; then
echo "❌ Failed: $script"
failed=1
fi
done
if [[ $failed -eq 1 ]]; then
exit 1
fi
echo "✅ All scripts compatible"
'
unit-tests:
name: Unit Tests (bats)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup bats
uses: bats-core/bats-action@2.0.0
- name: Run bats tests
run: |
if [[ -d "tests" ]] && ls tests/*.bats 1>/dev/null 2>&1; then
bats tests/*.bats
else
echo "No bats tests found in tests/ directory"
echo "Skipping unit tests"
fi