-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (141 loc) · 5.63 KB
/
Copy pathvalidate-scripts.yml
File metadata and controls
161 lines (141 loc) · 5.63 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Validate Scripts
on:
push:
branches: ['**']
pull_request:
branches: [main]
jobs:
syntax-check:
name: Bash Syntax Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check bash syntax with bash -n
run: |
echo "Checking syntax of all .sh files..."
failed=0
count=0
while IFS= read -r file; do
if ! bash -n "$file" 2>/tmp/syntax_err; then
echo "FAIL: $file"
cat /tmp/syntax_err
failed=$((failed + 1))
fi
count=$((count + 1))
done < <(find . -name '*.sh' -not -path './.git/*' | sort)
echo ""
echo "Checked $count files, $failed failed"
[ "$failed" -eq 0 ]
shellcheck:
name: ShellCheck (advisory)
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Run shellcheck --severity=error
run: |
echo "Running shellcheck (error-level only)..."
failed=0
count=0
while IFS= read -r file; do
if ! shellcheck --severity=error "$file" 2>/dev/null; then
failed=$((failed + 1))
fi
count=$((count + 1))
done < <(find . -name '*.sh' -not -path './.git/*' | sort)
echo ""
echo "Checked $count files, $failed had errors"
[ "$failed" -eq 0 ]
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run unit test suites
run: |
failed=0
for suite in tests/test_environment_unit.sh tests/test_pipeline_control_unit.sh tests/test_import_unit.sh; do
echo ""
echo "========================================"
echo "Running: $suite"
echo "========================================"
if bash "$suite"; then
echo "PASS: $suite"
else
echo "FAIL: $suite (exit code: $?)"
failed=$((failed + 1))
fi
done
echo ""
echo "========================================"
if [ "$failed" -gt 0 ]; then
echo "$failed test suite(s) failed"
exit 1
else
echo "All test suites passed"
fi
pipeline-smoke-test:
name: Pipeline Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify pipeline.sh --help works
run: |
# Provide a dummy FSL config so the early `source $FSLDIR/etc/fslconf/fsl.sh`
# in pipeline.sh succeeds under `set -e` (no real FSL install in CI).
export FSLDIR=/tmp/fake_fsl
mkdir -p "$FSLDIR/etc/fslconf"
printf '# dummy FSL config for CI smoke test\n' > "$FSLDIR/etc/fslconf/fsl.sh"
output=$(bash src/pipeline.sh --help 2>&1)
echo "$output"
echo ""
echo "--- Validating help output ---"
echo "$output" | grep -q "Usage:" || { echo "FAIL: missing Usage line"; exit 1; }
echo "$output" | grep -q "Pipeline Stages:" || { echo "FAIL: missing Pipeline Stages"; exit 1; }
echo "PASS: --help output looks correct"
- name: Verify pipeline loads all modules and fails gracefully on missing tools
run: |
# Set required vars to dummy values so module sourcing doesn't crash
# on unbound variables. The pipeline should still fail at the
# dependency check stage — that's exactly what we want to verify.
export FSLDIR=/tmp/fake_fsl
export ANTS_PATH=/tmp/fake_ants
# Provide a dummy FSL config so the early `source $FSLDIR/etc/fslconf/fsl.sh`
# in pipeline.sh succeeds under `set -e` (no real FSL install in CI).
mkdir -p "$FSLDIR/etc/fslconf"
printf '# dummy FSL config for CI smoke test\n' > "$FSLDIR/etc/fslconf/fsl.sh"
echo "Running pipeline.sh with no input data..."
output=$(bash src/pipeline.sh 2>&1 || true)
echo "$output"
echo ""
echo "--- Validating module loading ---"
check() {
if echo "$output" | grep -q "$1"; then
echo "PASS: found '$1'"
else
echo "FAIL: missing '$1'"
return 1
fi
}
failed=0
# Confirm key modules loaded successfully
check "Environment module loaded" || failed=$((failed + 1))
check "Import module loaded" || failed=$((failed + 1))
check "Registration module loaded" || failed=$((failed + 1))
check "Segmentation module loaded" || failed=$((failed + 1))
check "Analysis module loaded" || failed=$((failed + 1))
check "Visualization module loaded" || failed=$((failed + 1))
# Confirm pipeline got past module loading to actual execution
check "Arguments parsed:" || failed=$((failed + 1))
check "Comprehensive Pipeline Dependency Check" || failed=$((failed + 1))
# Confirm the dependency check section ran (outcome varies by environment)
check "Dependency Check Summary" || failed=$((failed + 1))
echo ""
if [ "$failed" -gt 0 ]; then
echo "$failed checks failed — pipeline may not be loading correctly"
exit 1
else
echo "All checks passed — pipeline loads and fails gracefully"
fi