Debian Codegraph @

debian/rust-vendor/codspeed/instrument-hooks/.github/workflows/ci.yml

raw
1 name: CI
2
3 on:
4 push:
5 branches: [main]
6 pull_request:
7 workflow_dispatch:
8
9 env:
10 COMMON_CFLAGS: >-
11 -Wall
12 -Werror
13 -Wno-format
14 -Wno-format-security
15 -Wno-unused-but-set-variable
16 -Wno-unused-const-variable
17 -Wno-type-limits
18 -Wno-uninitialized
19
20 jobs:
21 lint:
22 runs-on: ubuntu-latest
23 steps:
24 - uses: actions/checkout@v4
25 - uses: mlugg/setup-zig@v2
26 - uses: pre-commit/[email protected]
27 with:
28 extra_args: --all-files
29
30 tests:
31 strategy:
32 matrix:
33 os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
34 runs-on: ${{ matrix.os }}
35 steps:
36 - uses: actions/checkout@v4
37 - uses: mlugg/setup-zig@v2
38 - uses: extractions/setup-just@v3
39 - name: Run tests
40 run: zig build test --summary all
41
42 # Skip installing package docs to avoid wasting time when installing valgrind
43 # See: https://github.com/actions/runner-images/issues/10977#issuecomment-2810713336
44 - name: Skip installing package docs
45 if: runner.os == 'Linux'
46 run: |
47 sudo tee /etc/dpkg/dpkg.cfg.d/01_nodoc > /dev/null << 'EOF'
48 path-exclude /usr/share/doc/*
49 path-exclude /usr/share/man/*
50 path-exclude /usr/share/info/*
51 EOF
52
53 - name: Run valgrind tests
54 if: runner.os == 'Linux'
55 run: |
56 sudo apt-get update
57 sudo apt-get install -y valgrind
58 just test-valgrind
59
60 build:
61 strategy:
62 matrix:
63 os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
64 runs-on: ${{ matrix.os }}
65 steps:
66 - uses: actions/checkout@v4
67 - uses: mlugg/setup-zig@v2
68 - name: Build
69 run: zig build
70
71 test-build-cmake:
72 strategy:
73 matrix:
74 include:
75 - name: Linux GCC
76 os: ubuntu-latest
77 compiler: gcc
78
79 - name: Linux Clang
80 os: ubuntu-latest
81 compiler: clang
82
83 - name: macOS Clang
84 os: macos-latest
85 compiler: clang
86
87 - name: Windows MSVC
88 os: windows-latest
89 compiler: cl
90 runs-on: ${{ matrix.os }}
91 steps:
92 - uses: actions/checkout@v4
93 - uses: mlugg/setup-zig@v2
94 - uses: extractions/setup-just@v3
95
96 - name: Cache build
97 uses: actions/cache@v4
98 with:
99 path: example/build
100 key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}
101
102 - name: "Enable MSVC command prompt"
103 if: matrix.os == 'windows-latest'
104 uses: ilammy/msvc-dev-cmd@v1
105
106 - name: "Install cmake"
107 uses: lukka/get-cmake@latest
108
109 - name: "Build debug mode"
110 shell: bash
111 run: |
112 cd example
113 mkdir -p out
114 cd out
115 cmake .. -DCMAKE_C_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=Debug
116 cmake --build . --target example
117
118 - name: "Run example (Windows)"
119 if: runner.os == 'Windows'
120 shell: bash
121 run: |
122 cd example/out/Debug
123 ./example.exe
124
125 - name: "Run example (Unix)"
126 if: runner.os != 'Windows'
127 shell: bash
128 run: |
129 cd example/out
130 ./example
131
132 test-build-bazel:
133 strategy:
134 matrix:
135 include:
136 - name: Linux
137 os: ubuntu-latest
138 - name: macOS
139 os: macos-latest
140 - name: Windows
141 os: windows-latest
142 runs-on: ${{ matrix.os }}
143 steps:
144 - uses: actions/checkout@v4
145
146 - name: Set up Bazel
147 uses: bazel-contrib/[email protected]
148 with:
149 # Avoid downloading Bazel every time.
150 bazelisk-cache: true
151 # Store build cache per workflow.
152 disk-cache: ${{ github.workflow }}
153 # Share repository cache between workflows.
154 repository-cache: true
155
156 # Symlinks on windows are broken with bazel
157 - name: Fix symlink on Windows
158 if: runner.os == 'Windows'
159 shell: powershell
160 run: |
161 Get-ChildItem -Path example/instrument-hooks -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
162 Copy-Item -Path dist -Destination example/instrument-hooks/dist -Recurse
163 Copy-Item -Path includes -Destination example/instrument-hooks/includes -Recurse
164
165 - name: Build benchmarks
166 working-directory: example
167 run: |
168 bazel build //:example
169
170 - name: Run benchmarks
171 working-directory: example
172 run: |
173 bazel run //:example
174
175 test-gcc-versions:
176 runs-on: ubuntu-latest
177 strategy:
178 fail-fast: false
179 matrix:
180 version: [15, 14, 13, 12, 11, 10, 9]
181 container:
182 image: gcc:${{ matrix.version }}
183 steps:
184 - uses: actions/checkout@v4
185
186 - name: Build example with GCC ${{ matrix.version }}
187 run: |
188 gcc -std=c11 -O3 example/main.c dist/core.c \
189 -I includes/ \
190 ${{ env.COMMON_CFLAGS }} \
191 -o test-example
192
193 - name: Run example
194 run: ./test-example
195
196 test-clang-versions:
197 runs-on: ubuntu-latest
198 strategy:
199 fail-fast: false
200 matrix:
201 version: [19, 18, 17, 16, 15, 14, 13]
202 container:
203 image: silkeh/clang:${{ matrix.version }}
204 steps:
205 - uses: actions/checkout@v4
206
207 - name: Build example with Clang ${{ matrix.version }}
208 run: |
209 clang -std=c11 -O3 example/main.c dist/core.c \
210 -I includes/ \
211 ${{ env.COMMON_CFLAGS }} \
212 -o test-example
213
214 - name: Run example
215 run: ./test-example
216
217 cross-compile:
218 runs-on: ubuntu-latest
219 strategy:
220 fail-fast: false
221 matrix:
222 target:
223 # Linux targets - x86/x64
224 - { arch: x86_64-linux-gnu, name: "Linux x86_64 (glibc)" }
225 - { arch: x86_64-linux-musl, name: "Linux x86_64 (musl)" }
226 - { arch: x86-linux-gnu, name: "Linux x86 (32-bit)" }
227
228 # Linux targets - ARM
229 - { arch: aarch64-linux-gnu, name: "Linux ARM64 (glibc)" }
230 - { arch: aarch64-linux-musl, name: "Linux ARM64 (musl)" }
231 - { arch: arm-linux-gnueabihf, name: "Linux ARM (hard-float)" }
232 - { arch: arm-linux-gnueabi, name: "Linux ARM (soft-float)" }
233
234 # Linux targets - RISC-V
235 - { arch: riscv64-linux-gnu, name: "Linux RISC-V 64 (glibc)" }
236 - { arch: riscv64-linux-musl, name: "Linux RISC-V 64 (musl)" }
237
238 # Linux targets - Other architectures
239 - { arch: powerpc64le-linux-gnu, name: "Linux PowerPC64 LE" }
240 - { arch: s390x-linux-gnu, name: "Linux s390x (IBM Z)" }
241 - { arch: mips64el-linux-gnuabi64, name: "Linux MIPS64 LE" }
242 - { arch: loongarch64-linux-gnu, name: "Linux LoongArch64" }
243
244 # macOS targets
245 - { arch: x86_64-macos, name: "macOS x86_64 (Intel)" }
246 - { arch: aarch64-macos, name: "macOS ARM64 (Apple Silicon)" }
247
248 # Windows targets
249 - { arch: x86_64-windows-gnu, name: "Windows x86_64" }
250 - { arch: x86-windows-gnu, name: "Windows x86 (32-bit)" }
251
252 steps:
253 - uses: actions/checkout@v4
254 - uses: mlugg/setup-zig@v2
255
256 - name: Compile the example
257 run: |
258 zig cc example/main.c dist/core.c \
259 -I includes/ \
260 -target ${{ matrix.target.arch }} \
261 ${{ env.COMMON_CFLAGS }} \
262 -Wno-constant-conversion \
263 -Wno-incompatible-pointer-types \
264 -Wno-unused-function \
265 -o example.out
266
267 check:
268 runs-on: ubuntu-latest
269 if: always()
270 needs:
271 - lint
272 - tests
273 - build
274 - test-build-cmake
275 - test-build-bazel
276 - test-gcc-versions
277 - test-clang-versions
278 - cross-compile
279 steps:
280 - uses: re-actors/alls-green@release/v1
281 with:
282 jobs: ${{ toJson( needs ) }}