-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (186 loc) · 6.21 KB
/
ci.yml
File metadata and controls
220 lines (186 loc) · 6.21 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: CI/CD Pipeline
on:
push:
branches: [ main, master, 'claude/**' ]
pull_request:
branches: [ main, master ]
jobs:
build-and-test:
name: Build & Test (${{ matrix.compiler }}, ${{ matrix.build-type }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc-13, clang-15]
build-type: [Release, Debug]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
# Install specific compiler versions
if [[ "${{ matrix.compiler }}" == "gcc-13" ]]; then
sudo apt-get install -y g++-13
echo "CC=gcc-13" >> $GITHUB_ENV
echo "CXX=g++-13" >> $GITHUB_ENV
elif [[ "${{ matrix.compiler }}" == "clang-15" ]]; then
sudo apt-get install -y clang-15
echo "CC=clang-15" >> $GITHUB_ENV
echo "CXX=clang++-15" >> $GITHUB_ENV
fi
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DCMAKE_C_COMPILER=${{ env.CC }} \
-DCMAKE_CXX_COMPILER=${{ env.CXX }} \
-G Ninja
- name: Build
run: cmake --build build
- name: Run Tests
working-directory: testes
run: |
# Run tests once and check for expected success output
../build/lua all.lua 2>&1 | tee test_output.txt
grep -q "final OK !!!" test_output.txt || exit 1
- name: Upload build artifacts
if: matrix.build-type == 'Release' && matrix.compiler == 'gcc-13'
uses: actions/upload-artifact@v4
with:
name: lua-cpp-binary
path: build/lua
retention-days: 7
code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++-13
- name: Configure with strict warnings
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc-13 \
-DCMAKE_CXX_COMPILER=g++-13
- name: Build with -Werror
run: cmake --build build 2>&1 | tee build.log
- name: Check for warnings
run: |
# Build should succeed with zero warnings
if grep -i "warning:" build.log; then
echo "ERROR: Warnings detected in build"
exit 1
fi
echo "SUCCESS: Zero warnings build"
- name: Verify no errors
run: |
if grep -i "error:" build.log; then
echo "ERROR: Errors detected in build"
exit 1
fi
echo "SUCCESS: Clean build"
performance-check:
name: Performance Regression Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake g++-13
- name: Build Release
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=gcc-13 \
-DCMAKE_CXX_COMPILER=g++-13
cmake --build build
- name: Run 5x Benchmark
working-directory: testes
run: |
echo "Running 5 benchmark iterations..."
for i in 1 2 3 4 5; do
echo "=== Run $i ==="
../build/lua all.lua 2>&1 | grep "total time:" | tee -a benchmark_results.txt
done
- name: Analyze Performance
working-directory: testes
run: |
# Extract times and calculate average
grep "total time:" benchmark_results.txt | \
awk '{print $3}' | \
awk '{sum+=$1; times[NR]=$1} END {
avg=sum/NR;
printf "Average: %.2fs\n", avg;
printf "Runs: ";
for(i=1; i<=NR; i++) printf "%.2fs ", times[i];
printf "\n";
# Check against threshold (allow some variance in CI)
# Using 5.00s threshold (more generous than local 4.33s due to CI variance)
if (avg > 5.00) {
printf "PERFORMANCE REGRESSION: %.2fs > 5.00s\n", avg;
exit 1;
}
printf "Performance OK: %.2fs <= 5.00s\n", avg;
}'
- name: Upload benchmark results
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: testes/benchmark_results.txt
retention-days: 30
sanitizers:
name: Sanitizer Tests (ASAN + UBSAN)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake clang-15
- name: Build with sanitizers
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang-15 \
-DCMAKE_CXX_COMPILER=clang++-15 \
-DLUA_ENABLE_ASAN=ON \
-DLUA_ENABLE_UBSAN=ON
cmake --build build
- name: Run tests with sanitizers
working-directory: testes
run: |
# Run with sanitizer options and check for success
ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 \
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \
../build/lua all.lua 2>&1 | tee test_output.txt
grep -q "final OK !!!" test_output.txt || exit 1
build-summary:
name: Build Summary
runs-on: ubuntu-latest
needs: [build-and-test, code-quality, performance-check, sanitizers]
if: always()
steps:
- name: Check results
run: |
echo "Build and Test: ${{ needs.build-and-test.result }}"
echo "Code Quality: ${{ needs.code-quality.result }}"
echo "Performance: ${{ needs.performance-check.result }}"
echo "Sanitizers: ${{ needs.sanitizers.result }}"
if [[ "${{ needs.build-and-test.result }}" != "success" ]] || \
[[ "${{ needs.code-quality.result }}" != "success" ]] || \
[[ "${{ needs.performance-check.result }}" != "success" ]] || \
[[ "${{ needs.sanitizers.result }}" != "success" ]]; then
echo "❌ Some checks failed"
exit 1
fi
echo "✅ All checks passed!"