-
-
Notifications
You must be signed in to change notification settings - Fork 0
298 lines (252 loc) · 9.95 KB
/
ci.yml
File metadata and controls
298 lines (252 loc) · 9.95 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
build_type: [Release, Debug]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake build-essential libomp-dev
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=${{ matrix.compiler }}
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} -j$(nproc)
- name: Run tests
run: cd build && ctest --output-on-failure --timeout 300
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build build --config Release -j$(sysctl -n hw.ncpu)
- name: Run tests
run: cd build && ctest --output-on-failure --timeout 300
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build
- name: Build
run: cmake --build build --config Release
- name: Run tests
run: cd build && ctest -C Release --output-on-failure --timeout 300
roundtrip-test:
runs-on: ubuntu-latest
needs: build-linux
steps:
- uses: actions/checkout@v4
- name: Build
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
- name: Download Canterbury Corpus
run: |
mkdir -p /tmp/cantrbry
cd /tmp/cantrbry
wget -q https://corpus.canterbury.ac.nz/resources/cantrbry.tar.gz
tar xzf cantrbry.tar.gz 2>/dev/null || true
- name: Roundtrip test (all levels)
run: |
for f in /tmp/cantrbry/*; do
[ -f "$f" ] || continue
name=$(basename "$f")
for level in 1 3 6 9 12 20 26; do
./build/bin/mcx compress -l $level "$f" -o "/tmp/${name}.mcx"
./build/bin/mcx decompress "/tmp/${name}.mcx" -o "/tmp/${name}.dec"
if diff "$f" "/tmp/${name}.dec" > /dev/null 2>&1; then
echo "OK: $name L$level"
else
echo "FAIL: $name L$level"
exit 1
fi
rm -f "/tmp/${name}.mcx" "/tmp/${name}.dec"
done
done
coverage:
runs-on: ubuntu-latest
needs: build-linux
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake build-essential libomp-dev lcov
- name: Configure with coverage
run: |
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=gcc \
-DMCX_CODE_COVERAGE=ON \
-DMCX_BUILD_BENCHMARKS=OFF
- name: Build
run: cmake --build build -j$(nproc)
- name: Run tests
run: cd build && ctest --output-on-failure --timeout 300
- name: Generate coverage report
run: |
lcov --capture --directory build --output-file coverage.info \
--rc branch_coverage=1 --ignore-errors unused
# Remove external/test/system files from report
lcov --remove coverage.info \
'/usr/*' \
'*/tests/*' \
'*/external/*' \
--output-file coverage.info \
--rc branch_coverage=1 --ignore-errors unused
lcov --list coverage.info --rc branch_coverage=1 --ignore-errors unused
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v4
with:
files: coverage.info
flags: unittests
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: lcov-report
path: coverage.info
retention-days: 30
pkg-config-test:
runs-on: ubuntu-latest
needs: build-linux
steps:
- uses: actions/checkout@v4
- name: Build and install
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
sudo cmake --install build --prefix /usr/local
- name: Test pkg-config discovery
run: |
pkg-config --exists maxcomp
echo "CFLAGS: $(pkg-config --cflags maxcomp)"
echo "LIBS: $(pkg-config --libs maxcomp)"
- name: Build minimal program via pkg-config
run: |
cat > /tmp/test_pkgconfig.c << 'EOF'
#include <maxcomp/maxcomp.h>
#include <stdio.h>
#include <string.h>
int main(void) {
const char* data = "Hello MaxCompression pkg-config test!";
size_t src_size = strlen(data);
size_t cap = mcx_compress_bound(src_size);
unsigned char comp[1024], decomp[1024];
size_t comp_size = mcx_compress(comp, cap, data, src_size, 3);
if (mcx_is_error(comp_size)) { fprintf(stderr, "compress failed\n"); return 1; }
size_t dec_size = mcx_decompress(decomp, sizeof(decomp), comp, comp_size);
if (mcx_is_error(dec_size)) { fprintf(stderr, "decompress failed\n"); return 1; }
if (dec_size != src_size || memcmp(data, decomp, src_size) != 0) {
fprintf(stderr, "roundtrip mismatch\n"); return 1;
}
printf("pkg-config integration OK: %s v%s\n", "maxcomp", mcx_version_string());
return 0;
}
EOF
gcc /tmp/test_pkgconfig.c -o /tmp/test_pkgconfig \
$(pkg-config --cflags --libs maxcomp) -lm
LD_LIBRARY_PATH=/usr/local/lib /tmp/test_pkgconfig
# TODO: Add find_package(MaxCompression) test once CMake config export is implemented
python-bindings:
runs-on: ubuntu-latest
needs: build-linux
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build shared library
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
cmake --build build -j$(nproc)
- name: Test Python bindings
run: |
cp build/lib/libmaxcomp.so bindings/python/ 2>/dev/null || cp build/bin/libmaxcomp.so bindings/python/
cd bindings/python
python3 -c "
import maxcomp
data = b'Hello World! ' * 1000
compressed = maxcomp.compress(data, level=6)
restored = maxcomp.decompress(compressed)
assert restored == data, 'Roundtrip failed'
ratio = len(data) / len(compressed)
print(f'Python bindings OK: {len(data)} -> {len(compressed)} ({ratio:.1f}x)')
print(f'Version: {maxcomp.version()}')
print(f'Bound(1MB): {maxcomp.compress_bound(1048576)}')
"
valgrind:
runs-on: ubuntu-latest
needs: build-linux
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake build-essential libomp-dev valgrind
- name: Build (Debug, without OpenMP for cleaner valgrind output)
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-g -O1"
cmake --build build -j$(nproc)
- name: Run tests under valgrind memcheck
run: |
cd build
ctest --output-on-failure --timeout 600 \
--overwrite MemoryCheckCommand=/usr/bin/valgrind \
--overwrite "MemoryCheckCommandOptions=--leak-check=full --error-exitcode=1 --track-origins=yes --suppressions=${{ github.workspace }}/valgrind.supp" \
-T MemCheck || true
# Show memcheck results
cat Testing/Temporary/MemoryChecker.*.log 2>/dev/null || true
- name: Valgrind roundtrip on sample data
run: |
echo "The quick brown fox jumps over the lazy dog. Pack my box with five dozen liquor jugs." > /tmp/vg_test.txt
for level in 1 3 6 9 12; do
echo "=== Level $level ==="
valgrind --leak-check=full --error-exitcode=1 --track-origins=yes --suppressions=${{ github.workspace }}/valgrind.supp \
./build/bin/mcx compress -l $level -q /tmp/vg_test.txt -o /tmp/vg_test.mcx -f
valgrind --leak-check=full --error-exitcode=1 --track-origins=yes --suppressions=${{ github.workspace }}/valgrind.supp \
./build/bin/mcx decompress -q /tmp/vg_test.mcx -o /tmp/vg_test.dec -f
diff /tmp/vg_test.txt /tmp/vg_test.dec
echo "Level $level: OK (no leaks)"
rm -f /tmp/vg_test.mcx /tmp/vg_test.dec
done
rm -f /tmp/vg_test.txt
doxygen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Doxygen
run: sudo apt-get update && sudo apt-get install -y doxygen
- name: Generate API docs
run: doxygen Doxyfile
- name: Check for undocumented public functions
run: |
# Extract public function declarations from header
grep -oP 'MCXAPI\s+\S+\s+\K(mcx_\w+)' include/maxcomp/maxcomp.h | sort > /tmp/public_funcs.txt
echo "Public functions:"
cat /tmp/public_funcs.txt
# Check Doxygen warnings for undocumented members
if doxygen Doxyfile 2>&1 | grep -i "not documented"; then
echo "WARNING: Some public symbols are undocumented"
else
echo "All public symbols documented"
fi
- name: Upload docs artifact
uses: actions/upload-artifact@v4
with:
name: api-docs
path: docs/api/html
retention-days: 30