-
Notifications
You must be signed in to change notification settings - Fork 1
383 lines (371 loc) · 12.5 KB
/
build-and-test.yml
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# Copyright (c) 2022-2025 Guilherme Janczak <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
name: 'Build and Test'
on: [push, pull_request]
# GitHub Actions doesn't support YAML anchors, so there's a lot of code
# copypasted between jobs. You'll probably want to read the 'glibc:' task first,
# it's the one that requires the least hacks.
jobs:
bionic:
# XXX: Checkout and upload actions don't work, work with termux to fix this
# and the need to run /entrypoint.sh ourselves.
runs-on: ubuntu-latest
container: termux/termux-docker:x86_64
steps:
- name: setup
run: |
/entrypoint.sh pkg install -y ninja clang python git
/entrypoint.sh pip install meson
git clone --depth 1 -b $GITHUB_REF_NAME \
https://github.com/$GITHUB_REPOSITORY
- name: build
run: |
meson setup build dictpw
meson compile -C build
- name: test
run: meson test -C build
dietlibc:
runs-on: ubuntu-latest
steps:
- name: setup
run: |
pip install meson
sudo apt update
sudo apt install -y dietlibc-dev linux-headers-generic ninja-build \
valgrind
- uses: actions/[email protected]
- name: build
run: |
CC='diet gcc' meson setup build -Ddefault_library=static
meson compile -C build
- name: test
run: meson test -C build --wrapper valgrind
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-dietlibc
path: build/meson-logs
emscripten:
runs-on: macos-latest
steps:
- name: setup
run: |
brew update
brew install meson samurai emscripten
- uses: actions/[email protected]
- name: build
run: |
meson setup build -Ddefault_library=static \
--cross-file=.github/workflows/meson-emscripten.txt
meson compile -C build
- name: test
run: meson test -t 3 -C build
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-emscripten
path: build/meson-logs
glibc:
runs-on: ubuntu-latest
outputs:
ver: ${{steps.ver.outputs.ver}}
steps:
- name: setup
run: |
pip install meson
sudo apt update
sudo apt install -y ninja-build jq
- uses: actions/[email protected]
- name: build
run: |
meson setup build
meson compile -C build
- name: test
run: meson test -C build
- name: output version # for release builds.
id: ver
run: |
ver="$(meson introspect --projectinfo build | jq -r '.version')"
printf 'ver=%s' "$ver" >> "$GITHUB_OUTPUT"
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-glibc
path: build/meson-logs
haiku:
runs-on: ubuntu-22.04
container: 'docker.io/hectorm/qemu-haiku:latest'
steps:
# Copied from: https://github.com/hectorm/docker-qemu-haiku#github-actions
# Notice I changed make to meson in the 'Install packages' step.
- name: 'Wait until the VM is ready'
run: 'container-init & timeout 600 vmshell exit 0'
- name: 'Install packages'
run: 'vmshell pkgman install -y meson gcc haiku_devel'
- name: 'Checkout project'
uses: 'actions/checkout@main'
- name: 'Copy project to VM'
run: 'vmshell mkdir ./src/; tar -cf - ./ | vmshell tar -xf - -C ./src/'
# Now the rest is much of the same old.
- name: build
run: |
vmshell meson setup build src
vmshell meson compile -C build
- name: test
run: vmshell meson test -C build
- name: copy falure logs
if: always()
run: |
vmshell tar -cf - build/meson-logs | tar -xf -
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-haiku
path: build/meson-logs
macos:
runs-on: macos-latest
steps:
- run: |
brew update
brew install meson samurai
- uses: actions/[email protected]
- name: build
run: |
meson setup build -Drelease=true --wrap-mode=forcefallback
- name: dist
run: |
# For release builds.
meson dist --include-subprojects --formats xztar,gztar -C build
- uses: actions/[email protected]
with:
name: dist
path: build/meson-dist/*
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-macos
path: build/meson-logs
msys2:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
# clang32 was broken last time I tried
sys: [msys, mingw64, mingw32, ucrt64, clang64]
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
path-type: strict
pacboy: |
gcc:p meson:p ninja:p dos2unix: git: groff:
- uses: actions/[email protected]
- name: build
run: |
inno="$(cmd //c 'echo %ProgramFiles(x86)%')\\Inno Setup 6\\"
inno="$(cygpath -u "$inno")"
PATH="${PATH}:${inno}"
echo "$PATH"
meson setup build -Dbuildtype=release # for release
meson compile -C build
strip build/dictpw.exe # for release
- name: test
run: meson test -C build
- name: installer
run: |
meson compile installer -C build
mv build/setup-dictpw.exe build/setup-dictpw-${{matrix.sys}}.exe
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-${{matrix.sys}}
path: build/meson-logs
- uses: actions/[email protected]
if: success()
with:
name: setup-dictpw-${{matrix.sys}}
path: build/setup-*.exe
netbsd:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: test on NetBSD
uses: cross-platform-actions/[email protected]
with:
operating_system: netbsd
version: '9.3'
run: |
sudo pkgin -y install meson git mozilla-rootcerts-openssl
meson setup build
meson compile -C build
meson test -C build
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-netbsd
path: build/meson-logs
vs:
runs-on: windows-latest
strategy:
matrix:
cc: [cl, clang-cl]
arch: [x86_64, x86, aarch64, arm]
env:
arch_map: |
{
"x86_64":
{
"_comment": "MSVC Dev CMD action name for this arch.",
"msvc_dev_cmd": "x64",
"_comment": "Is this a cross compiler?",
"msvc_cross": false,
},
"x86":
{
"_comment": "Take the chance to test more cross compilers.",
"msvc_dev_cmd": "amd64_x86",
"msvc_cross": true,
},
"aarch64":
{
"msvc_dev_cmd": "amd64_arm64",
"msvc_cross": true,
},
"arm":
{
"msvc_dev_cmd": "amd64_arm",
"msvc_cross": true,
},
}
steps:
- uses: actions/[email protected]
- run: |
pip install meson
choco install ninja innosetup groff -y
- uses: actions/[email protected]
- name: Enable Developer Command Prompt
uses: ilammy/[email protected]
with:
arch: ${{fromJSON(env.arch_map)[matrix.arch].msvc_dev_cmd}}
# Windows SDK 10.0.26100.0 dropped support for 32-bit ARM
# https://github.com/actions/runner-images/issues/10981#issuecomment-2481185614
# Pin in to the last version that had ARM.
sdk: ${{matrix.arch == 'arm' && '10.0.22621.0' || ''}}
- name: build
run: |
if ("${{matrix.cc}}" -eq 'clang-cl') {
clang-cl -print-target-triple
}
$cross = "${{fromJSON(env.arch_map)[matrix.arch].msvc_cross}}"
if ($cross -eq 'true') {
$buildcc = "--native-file=.github/workflows/meson-vs-gcc.txt"
$hostarch = `
"--cross-file=.github/workflows/meson-vs-${{matrix.arch}}.txt"
$hostcc = `
"--cross-file=.github/workflows/meson-vs-${{matrix.cc}}.txt"
# clang-cl needs extra args to target a particular architecture.
# https://github.com/llvm/llvm-project/raw/1a0d0ae234544dc4978f1e12730408cb83f6b923/clang/test/Preprocessor/predefined-macros-no-warnings.c
$hostcc_args = if ('${{matrix.cc}}' -eq 'clang-cl') {
"--cross-file=.github/workflows/meson-vs-clang-cl-${{matrix.arch}}.txt"
}
} else {
$hostcc = `
"--native-file=.github/workflows/meson-vs-${{matrix.cc}}.txt"
}
# Don't do debug builds because that triggers a Windows bug:
# https://developercommunity.visualstudio.com/t/_setmaxstdio-hangs-the-program-if-the/10164855?space=62&q=setmaxstdio&viewtype=all
meson setup build -Dbuildtype=release `
-Db_vscrt=static_from_buildtype `
$buildcc $hostarch $hostcc $hostcc_args
meson compile -C build
- name: test
run: meson test -C build
- name: inst
run: |
meson compile installer -C build
mv "build/setup-dictpw.exe" `
"build/setup-dictpw-${{matrix.cc}}-${{matrix.arch}}.exe"
- uses: actions/[email protected]
if: always()
with:
name: meson-logs-vs-${{matrix.cc}}-${{matrix.arch}}
path: build/meson-logs
- uses: actions/[email protected]
if: success()
with:
name: setup-dictpw-${{matrix.cc}}-${{matrix.arch}}
path: build/setup-*.exe
publish:
needs: [msys2, vs, glibc, macos]
runs-on: ubuntu-latest
permissions:
contents: write
env:
ver: '${{needs.glibc.outputs.ver}}'
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v4
with:
pattern: 'setup-dictpw-*'
path: 'setup/'
merge-multiple: true
- name: debug
run: |
echo ls:
ls -skR .
echo env:
env
- name: installers
run: |
echo $ver
mkdir out
mv "setup/setup-dictpw-ucrt64.exe" \
"out/setup-dictpw-${ver}-x64.exe"
mv "setup/setup-dictpw-mingw32.exe" \
"out/setup-dictpw-${ver}-x86.exe"
mv "setup/setup-dictpw-clang-cl-aarch64.exe" \
"out/setup-dictpw-${ver}-ARM64.exe"
mv "setup/setup-dictpw-clang-cl-arm.exe" \
"out/setup-dictpw-${ver}-ARM.exe"
# To make sure the hashes don't include the directory.
cd out && for file in setup-dictpw-*.exe; do
sha256sum "$file" > "${file}.sha256sum"
done
- uses: actions/download-artifact@v4
with:
name: dist
path: 'out/'
- name: publish check
run: |
echo 'output dir:'
ls -sk out/ # debug
# Test the subproject is included.
tar -ztvf out/dictpw-*.tar.gz | grep '/subprojects/libobsd/meson.build'
tag="$(echo '${{github.event.ref}}' | sed 's|refs/tags/v||')"
if [ "$tag" = "$ver" ]; then
echo "should_release=true" >> "$GITHUB_ENV"
else
echo "'$tag' isn't a version"
echo "should_release=false" >> "$GITHUB_ENV"
fi
- name: publish
if: fromJSON(env.should_release) == true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
gh release create "v$ver" --title "dictpw $ver" \
--notes-file "docs/CHANGELOG-${ver}.md" \
--target "$GITHUB_SHA" out/*