-
Notifications
You must be signed in to change notification settings - Fork 100
344 lines (295 loc) · 9.54 KB
/
build.yml
File metadata and controls
344 lines (295 loc) · 9.54 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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: Build
on:
pull_request:
push:
branches:
- main
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Install nasm
run: |
sudo apt-get update
sudo apt-get install -y nasm
- name: Cross-compile for all targets
run: |
zig build -Doptimize=ReleaseFast ci --verbose
- name: Prepare binaries as artifacts
run: |
mkdir binaries
cp zig-out/x86_64-linux/odiff binaries/odiff-linux-x64
cp zig-out/aarch64-linux/odiff binaries/odiff-linux-arm64
cp zig-out/riscv64-linux/odiff binaries/odiff-linux-riscv64
cp zig-out/riscv64-linux-rva23/odiff binaries/odiff-linux-riscv64-rva23
cp zig-out/x86_64-windows/odiff.exe binaries/odiff-windows-x64.exe
cp zig-out/aarch64-windows/odiff.exe binaries/odiff-windows-arm64.exe
cp zig-out/x86_64-macos/odiff binaries/odiff-macos-x64
cp zig-out/aarch64-macos/odiff binaries/odiff-macos-arm64
- name: Upload x86_64-linux artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-x64
path: binaries/odiff-linux-x64
retention-days: 14
- name: Upload aarch64-linux artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-arm64
path: binaries/odiff-linux-arm64
retention-days: 14
- name: Upload riscv64-linux artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-riscv64
path: binaries/odiff-linux-riscv64
retention-days: 14
- name: Upload riscv64-linux rva23 artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-linux-riscv64-rva23
path: binaries/odiff-linux-riscv64-rva23
retention-days: 14
- name: Upload x86_64-windows artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-windows-x64.exe
path: binaries/odiff-windows-x64.exe
retention-days: 14
- name: Upload aarch64-windows artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-windows-arm64.exe
path: binaries/odiff-windows-arm64.exe
retention-days: 14
- name: Upload x86_64-macos artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-macos-x64
path: binaries/odiff-macos-x64
retention-days: 14
- name: Upload aarch64-macos artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: odiff-macos-arm64
path: binaries/odiff-macos-arm64
retention-days: 14
test:
name: Run Tests (all targets)
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-linux-gnu
os: ubuntu-latest
run_tests: true
- target: x86_64-windows-gnu
os: windows-latest
run_tests: true
- target: aarch64-macos
os: macos-latest
run_tests: true
- target: riscv64-linux-gnu
os: ubuntu-latest
run_tests: false
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Install nasm for x86 targets (Linux)
if: contains(matrix.target, 'x86_64') && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y nasm
- name: Install nasm for x86 targets (macOS)
if: contains(matrix.target, 'x86_64') && runner.os == 'macOS'
run: |
brew install nasm
- name: Install nasm for x86 targets (Windows)
if: contains(matrix.target, 'x86_64') && runner.os == 'Windows'
run: |
choco install -y nasm
- name: Build and run tests
if: matrix.run_tests == true
run: |
zig build -Dtarget=${{matrix.target}} test-all --summary all
- name: Build without running tests
if: matrix.run_tests != true
run: |
zig build -Dtarget=${{matrix.target}}
test-avx:
name: Run Tests (AVX x86_64)
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-linux-gnu
os: ubuntu-latest
- target: x86_64-macos
os: macos-latest
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.15.2
- name: Install nasm for x86 targets (Linux)
if: contains(matrix.target, 'x86_64') && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y nasm
- name: Install nasm for x86 targets (macOS)
if: contains(matrix.target, 'x86_64') && runner.os == 'macOS'
run: |
brew install nasm
- name: Run AVX tests
run: |
zig build test-all --summary all
e2e-tests:
name: JavaScript tests
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download x86_64-linux artifact
uses: actions/download-artifact@v4
with:
name: odiff-linux-x64
path: zig-out/bin
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Prepare binary for tests
run: |
ls -la zig-out/bin/
cp zig-out/bin/odiff-linux-x64 zig-out/bin/odiff
chmod +x zig-out/bin/odiff
file zig-out/bin/odiff
zig-out/bin/odiff --version
- run: npm run test:js
playwright-tests:
name: Playwright visual regression tests
needs: [build]
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.56.0-noble
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download x86_64-linux artifact
uses: actions/download-artifact@v4
with:
name: odiff-linux-x64
path: zig-out/bin
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Prepare binary for tests
run: |
ls -la zig-out/bin/
cp zig-out/bin/odiff-linux-x64 zig-out/bin/odiff
cp zig-out/bin/odiff-linux-x64 npm_packages/odiff-bin/bin/odiff.exe
chmod +x zig-out/bin/odiff
chmod +x npm_packages/odiff-bin/bin/odiff.exe
zig-out/bin/odiff --version
- name: Build playwright-odiff package
working-directory: npm_packages/playwright-odiff
run: npm run build
- name: Run Playwright tests
working-directory: npm_packages/playwright-odiff
run: npm test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: npm_packages/playwright-odiff/test-results
retention-days: 7
spellcheck:
name: Spell check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run typos
uses: crate-ci/typos@master
with:
config: ./typos.toml
publish:
name: Publish release
needs: [build, test, e2e-tests]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Download all built binaries
uses: actions/download-artifact@v4
with:
pattern: odiff-*
merge-multiple: true
path: binaries
- name: Verify that we have 8 binaries
run: |
ls -la binaries
[ $(ls -1 binaries | wc -l) -eq 8 ] || (echo "Expected 8 binaries" && exit 1)
- name: Copy binaries to npm package (excluding rva23)
run: |
mkdir -p npm_packages/odiff-bin/raw_binaries
find binaries -type f ! -name '*riscv64-linux-rva23*' -exec cp {} npm_packages/odiff-bin/raw_binaries/ \;
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
always-auth: true
registry-url: "https://registry.npmjs.org"
cache-dependency-path: "package-lock.json"
- name: Copy root readme
run: cp README.md npm_packages/odiff-bin/README.md
- name: Publish odiff-bin package
working-directory: npm_packages/odiff-bin
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish playwright-odiff package
working-directory: npm_packages/playwright-odiff
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create github release
uses: softprops/action-gh-release@v1
with:
files: "binaries/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}