-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (156 loc) · 6.08 KB
/
Copy pathvalidate-scripts.yml
File metadata and controls
187 lines (156 loc) · 6.08 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Build Scripts Validation
on:
pull_request:
paths:
- "examples/build-examples*"
- "build-all.*"
- "build-system/**"
- ".github/workflows/**"
workflow_dispatch:
jobs:
validate-scripts:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install ShellCheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Validate Bash Scripts
run: |
echo "=== Validating Bash Scripts ==="
# Check main build scripts (moved under scripts/ in v2.2.0)
if [ -f "scripts/build-all.sh" ]; then
echo "Checking scripts/build-all.sh..."
shellcheck scripts/build-all.sh || echo "⚠️ scripts/build-all.sh has warnings"
fi
if [ -f "scripts/create-release.sh" ]; then
echo "Checking scripts/create-release.sh..."
shellcheck scripts/create-release.sh || echo "⚠️ scripts/create-release.sh has warnings"
fi
# Check example build scripts
for script in examples/build-examples*.sh; do
if [ -f "$script" ]; then
echo "Checking $script..."
shellcheck "$script" || echo "⚠️ $script has warnings"
fi
done
# Check build-system scripts
for script in build-system/*.sh; do
if [ -f "$script" ]; then
echo "Checking $script..."
shellcheck "$script" || echo "⚠️ $script has warnings"
fi
done
- name: Validate Batch Scripts Syntax
run: |
echo "=== Validating Batch Scripts Syntax ==="
# Basic syntax check for batch files
for script in examples/*.bat build-all.bat; do
if [ -f "$script" ]; then
echo "Checking $script syntax..."
# Check for common batch syntax issues
if grep -q "@echo off" "$script"; then
echo "✅ $script has proper @echo off"
else
echo "⚠️ $script missing @echo off"
fi
# Check for proper variable syntax
if grep -qE '%[A-Za-z_][A-Za-z0-9_]*%' "$script"; then
echo "✅ $script uses proper variable syntax"
fi
# Check for proper conditional syntax
if grep -q "if.*(" "$script" && grep -q ")" "$script"; then
echo "✅ $script has proper conditional syntax"
fi
fi
done
- name: Validate PowerShell Scripts
shell: pwsh
run: |
Write-Host "=== Validating PowerShell Scripts ==="
$scripts = Get-ChildItem -Path "examples" -Filter "*.ps1"
foreach ($script in $scripts) {
Write-Host "Checking $($script.Name)..."
try {
# Parse the script to check for syntax errors
$tokens = $null
$errors = $null
[System.Management.Automation.Language.Parser]::ParseFile($script.FullName, [ref]$tokens, [ref]$errors)
if ($errors.Count -eq 0) {
Write-Host "✅ $($script.Name) syntax is valid"
} else {
Write-Host "❌ $($script.Name) has syntax errors:"
foreach ($error in $errors) {
Write-Host " - $error"
}
}
} catch {
Write-Host "⚠️ Could not parse $($script.Name): $_"
}
}
- name: Test Script Permissions
run: |
echo "=== Testing Script Permissions ==="
# Check if scripts are executable
for script in build-all.sh examples/build-examples*.sh build-system/*.sh; do
if [ -f "$script" ]; then
if [ -x "$script" ]; then
echo "✅ $script is executable"
else
echo "⚠️ $script is not executable, making it executable..."
chmod +x "$script"
fi
fi
done
- name: Test Script Help/Usage
run: |
echo "=== Testing Script Help/Usage ==="
# Make scripts executable
chmod +x build-all.sh examples/build-examples*.sh 2>/dev/null || true
# Test if scripts handle help flags gracefully
for script in examples/build-examples*.sh; do
if [ -f "$script" ]; then
echo "Testing $script with --help..."
timeout 10s "$script" --help 2>&1 || echo "Script doesn't support --help (expected)"
fi
done
test-minimal-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install minimal dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential
- name: Test UBuilder core build only
run: |
echo "=== Testing Core Build Without Runtimes ==="
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
if [ -f "src/ubuilder" ]; then
echo "✅ UBuilder core built successfully"
./src/ubuilder --version || echo "Version check failed"
./src/ubuilder --help || echo "Help check failed"
else
echo "❌ UBuilder core build failed"
exit 1
fi
- name: Test build script error handling
run: |
echo "=== Testing Build Script Error Handling ==="
chmod +x examples/build-examples-linux.sh
# Test with missing runtimes (should skip gracefully)
echo "Testing with no runtimes installed..."
timeout 300s ./examples/build-examples-linux.sh || {
exit_code=$?
if [ $exit_code -eq 124 ]; then
echo "⚠️ Script timed out (may be normal for missing runtimes)"
else
echo "Script exited with code: $exit_code"
fi
}