-
Notifications
You must be signed in to change notification settings - Fork 4
298 lines (260 loc) · 8.36 KB
/
Copy pathci.yml
File metadata and controls
298 lines (260 loc) · 8.36 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:
workflow_dispatch:
env:
COMMON_CFLAGS: >-
-Wall
-Werror
-Wno-format
-Wno-format-security
-Wno-unused-but-set-variable
-Wno-unused-const-variable
-Wno-type-limits
-Wno-uninitialized
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files
check-callgrind-header:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Diff includes/callgrind.h against valgrind-codspeed main
run: |
curl -fsSL -o /tmp/callgrind.h \
https://raw.githubusercontent.com/CodSpeedHQ/valgrind-codspeed/master/callgrind/callgrind.h
if ! diff -u /tmp/callgrind.h includes/callgrind.h; then
echo ""
echo "::error::includes/callgrind.h is out of sync with CodSpeedHQ/valgrind-codspeed."
echo "Copy callgrind/callgrind.h from the fork's default branch into includes/."
exit 1
fi
tests:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
- uses: extractions/setup-just@v3
- name: Run tests
run: zig build test --summary all
# Skip installing package docs to avoid wasting time when installing valgrind
# See: https://github.com/actions/runner-images/issues/10977#issuecomment-2810713336
- name: Skip installing package docs
if: runner.os == 'Linux'
run: |
sudo tee /etc/dpkg/dpkg.cfg.d/01_nodoc > /dev/null << 'EOF'
path-exclude /usr/share/doc/*
path-exclude /usr/share/man/*
path-exclude /usr/share/info/*
EOF
- name: Run valgrind tests
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y valgrind
just test-valgrind
build:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
- name: Build
run: zig build
test-build-cmake:
strategy:
matrix:
include:
- name: Linux GCC
os: ubuntu-latest
compiler: gcc
- name: Linux Clang
os: ubuntu-latest
compiler: clang
- name: macOS Clang
os: macos-latest
compiler: clang
- name: Windows MSVC
os: windows-latest
compiler: cl
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
- uses: extractions/setup-just@v3
- name: Cache build
uses: actions/cache@v4
with:
path: example/build
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}
- name: "Enable MSVC command prompt"
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
- name: "Install cmake"
uses: lukka/get-cmake@latest
- name: "Build debug mode"
shell: bash
run: |
cd example
mkdir -p out
cd out
cmake .. -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=Debug
cmake --build . --target example
- name: "Run example (Windows)"
if: runner.os == 'Windows'
shell: bash
run: |
cd example/out/Debug
./example.exe
- name: "Run example (Unix)"
if: runner.os != 'Windows'
shell: bash
run: |
cd example/out
./example
test-build-bazel:
strategy:
matrix:
include:
- name: Linux
os: ubuntu-latest
- name: macOS
os: macos-latest
- name: Windows
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@0.14.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
# Symlinks on windows are broken with bazel
- name: Fix symlink on Windows
if: runner.os == 'Windows'
shell: powershell
run: |
Get-ChildItem -Path example/instrument-hooks -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item -Path dist -Destination example/instrument-hooks/dist -Recurse
Copy-Item -Path includes -Destination example/instrument-hooks/includes -Recurse
- name: Build benchmarks
working-directory: example
run: |
bazel build //:example
- name: Run benchmarks
working-directory: example
run: |
bazel run //:example
test-gcc-versions:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: [15, 14, 13, 12, 11, 10, 9]
container:
image: gcc:${{ matrix.version }}
steps:
- uses: actions/checkout@v4
- name: Build example with GCC ${{ matrix.version }}
run: |
gcc -std=c11 -O3 example/main.c dist/core.c \
-I includes/ \
${{ env.COMMON_CFLAGS }} \
-o test-example
- name: Run example
run: ./test-example
test-clang-versions:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: [19, 18, 17, 16, 15, 14, 13]
container:
image: silkeh/clang:${{ matrix.version }}
steps:
- uses: actions/checkout@v4
- name: Build example with Clang ${{ matrix.version }}
run: |
clang -std=c11 -O3 example/main.c dist/core.c \
-I includes/ \
${{ env.COMMON_CFLAGS }} \
-o test-example
- name: Run example
run: ./test-example
cross-compile:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
# Linux targets - x86/x64
- { arch: x86_64-linux-gnu, name: "Linux x86_64 (glibc)" }
- { arch: x86_64-linux-musl, name: "Linux x86_64 (musl)" }
- { arch: x86-linux-gnu, name: "Linux x86 (32-bit)" }
# Linux targets - ARM
- { arch: aarch64-linux-gnu, name: "Linux ARM64 (glibc)" }
- { arch: aarch64-linux-musl, name: "Linux ARM64 (musl)" }
- { arch: arm-linux-gnueabihf, name: "Linux ARM (hard-float)" }
- { arch: arm-linux-gnueabi, name: "Linux ARM (soft-float)" }
# Linux targets - RISC-V
- { arch: riscv64-linux-gnu, name: "Linux RISC-V 64 (glibc)" }
- { arch: riscv64-linux-musl, name: "Linux RISC-V 64 (musl)" }
# Linux targets - Other architectures
- { arch: powerpc64le-linux-gnu, name: "Linux PowerPC64 LE" }
- { arch: s390x-linux-gnu, name: "Linux s390x (IBM Z)" }
- { arch: mips64el-linux-gnuabi64, name: "Linux MIPS64 LE" }
- { arch: loongarch64-linux-gnu, name: "Linux LoongArch64" }
# macOS targets
- { arch: x86_64-macos, name: "macOS x86_64 (Intel)" }
- { arch: aarch64-macos, name: "macOS ARM64 (Apple Silicon)" }
# Windows targets
- { arch: x86_64-windows-gnu, name: "Windows x86_64" }
- { arch: x86-windows-gnu, name: "Windows x86 (32-bit)" }
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
- name: Compile the example
run: |
zig cc example/main.c dist/core.c \
-I includes/ \
-target ${{ matrix.target.arch }} \
${{ env.COMMON_CFLAGS }} \
-Wno-constant-conversion \
-Wno-incompatible-pointer-types \
-Wno-unused-function \
-o example.out
check:
runs-on: ubuntu-latest
if: always()
needs:
- lint
- check-callgrind-header
- tests
- build
- test-build-cmake
- test-build-bazel
- test-gcc-versions
- test-clang-versions
- cross-compile
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJson( needs ) }}