-
Notifications
You must be signed in to change notification settings - Fork 2
376 lines (336 loc) · 12 KB
/
wadge.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
name: wadge
on:
merge_group:
pull_request:
push:
branches:
- main
tags:
- 'crates/passthrough/v[0-9].[0-9]+.[0-9]+'
- 'crates/passthrough/v[0-9].[0-9]+.[0-9]+-*'
- 'crates/sys/v[0-9].[0-9]+.[0-9]+'
- 'crates/sys/v[0-9].[0-9]+.[0-9]+-*'
- 'v[0-9].[0-9]+.[0-9]+'
- 'v[0-9].[0-9]+.[0-9]+-*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-ffi:
strategy:
matrix:
target:
- aarch64-linux-android
- aarch64-unknown-linux-musl
- riscv64gc-unknown-linux-gnu
- x86_64-pc-windows-gnu
- x86_64-unknown-linux-musl
# TODO: figure out what's different in Mac libraries built this way
#- aarch64-apple-darwin
#- x86_64-apple-darwin
name: wadge-${{ matrix.target }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: ./.github/actions/build-nix
with:
package: wadge-${{ matrix.target }}
build-ffi-darwin:
strategy:
matrix:
config:
- os: macos-13
target: x86_64-apple-darwin
sdk: 10.12
- os: macos-14
target: aarch64-apple-darwin
sdk: 11.0
name: wadge-${{ matrix.config.target }}
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: rustup show
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- run: cargo build -p wadge-sys --release --target ${{ matrix.config.target }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.config.sdk }}
- run: mkdir -p artifact/lib
- run: mv target/${{ matrix.config.target }}/release/libwadge_sys.a artifact/lib/libwadge_sys.a
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: wadge-${{ matrix.config.target }}
path: artifact
build-wasm:
name: passthrough.wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix profile install --inputs-from . '.#rust' 'nixpkgs#wasm-tools'
- run: cargo build -p wadge-passthrough --target wasm32-unknown-unknown --release
- run: wasm-tools component new target/wasm32-unknown-unknown/release/wadge_passthrough.wasm -o lib/passthrough.wasm
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: passthrough
path: lib/passthrough.wasm
test-release:
strategy:
matrix:
config:
- os: ubuntu-latest
lib: x86_64-linux
target: x86_64-unknown-linux-musl
shell: bash
- os: windows-latest
lib: x86_64-windows
target: x86_64-pc-windows-gnu
shell: msys2
- os: macos-13
lib: x86_64-darwin
target: x86_64-apple-darwin
shell: bash
- os: macos-14
lib: aarch64-darwin
target: aarch64-apple-darwin
shell: bash
name: test-release (${{ matrix.config.os }})
needs:
- build-ffi
- build-ffi-darwin
- build-wasm
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: ${{ matrix.config.shell }} {0}
steps:
- uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1
if: matrix.config.os == 'windows-latest'
with:
update: true
install: mingw-w64-x86_64-toolchain
msystem: MINGW64
path-type: inherit
- run: git config --global core.autocrlf input
if: matrix.config.os == 'windows-latest'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: passthrough
path: lib
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: wadge-${{ matrix.config.target }}
- run: mv lib/libwadge_sys.a "lib/${{ matrix.config.lib }}/libwadge.a"
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
- run: rustup show
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- run: cargo install [email protected]
- run: go generate ./tests/go/... ./examples/go/...
- run: go test -failfast ./...
env:
GOGC: 1
WADGE_LOG: trace
- run: git diff --exit-code
test-dev:
strategy:
matrix:
config:
- os: ubuntu-latest
shell: bash
- os: windows-latest
shell: msys2
- os: macos-13
shell: bash
- os: macos-14
shell: bash
name: test-dev (${{ matrix.config.os }})
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: ${{ matrix.config.shell }} {0}
steps:
- uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1
if: matrix.config.os == 'windows-latest'
with:
update: true
install: mingw-w64-x86_64-toolchain
msystem: MINGW64
path-type: inherit
- run: git config --global core.autocrlf input
if: matrix.config.os == 'windows-latest'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
- run: rustup set default-host x86_64-pc-windows-gnu
if: matrix.config.os == 'windows-latest'
- run: rustup show
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- run: cargo install [email protected]
- run: cargo test --workspace --all-targets
- run: go generate -tags=dev ./...
- run: go test -failfast -tags=dev ./...
env:
GOGC: 1
WADGE_LOG: trace
- run: git diff --exit-code
gofmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: go.mod
- run: gofmt -w -s **/*.go
- run: git diff --exit-code
cargo:
strategy:
matrix:
check:
- audit
- fmt
- nextest
- clippy
name: cargo ${{ matrix.check }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: go work vendor -e -v
if: ${{ matrix.check }} == "nextest"
- run: git add .
if: ${{ matrix.check }} == "nextest"
- run: nix build -L .#checks.x86_64-linux.${{ matrix.check }}
crates:
strategy:
matrix:
include:
- crate: passthrough
workspace-dependencies: false
- crate: sys
workspace-dependencies: true
name: publish ${{ matrix.crate }} to crates.io
needs: cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Extract tag context
id: ctx
run: |
version=${GITHUB_REF_NAME#crates/${{ matrix.crate }}/v}
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "version is ${version}"
if [[ $version == *"-"* ]]; then
echo "version ${version} is a pre-release"
echo "prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: dry-run publish ${{ matrix.crate }} to crates.io
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
continue-on-error: ${{ matrix.workspace-dependencies }} # publish may fail due to workspace crates not being published yet
run: cargo publish --dry-run
working-directory: ./crates/${{ matrix.crate }}
- name: publish ${{ matrix.crate }} to crates.io
if: startsWith(github.ref, format('refs/tags/crates/{0}/v', matrix.crate)) && !steps.ctx.outputs.prerelease
continue-on-error: ${{ github.repository_owner != 'wasmCloud' }}
run: |
pkgver=$(cargo pkgid | cut -d '@' -f 2)
tagver="${{ steps.ctx.outputs.version }}"
if ! [ "$pkgver" = "$tagver" ]; then
echo "version mismatch, $pkgver (package) != $tagver (tag)"
exit 1
fi
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
working-directory: ./crates/${{ matrix.crate }}
build-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L .#checks.x86_64-linux.doc
- run: cp --no-preserve=mode -R ./result/share/doc ./doc
- run: rm -f doc/.lock
- name: Create `.nojekyll`
run: touch doc/.nojekyll
- name: Write `index.html`
run: |
cat <<EOF > doc/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting to wadge/index.html</title>
<meta http-equiv="refresh" content="0; URL=wadge/index.html">
<link rel="canonical" href="https://${{ github.repository_owner }}.github.io/wadge/wadge/index.html">
EOF
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: doc
deploy-doc:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-doc
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
id: deployment
release:
if: startsWith(github.ref, 'refs/tags/v')
needs:
- test-release
- cargo
- crates
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Extract tag context
id: ctx
run: |
version=${GITHUB_REF_NAME#v}
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "version is ${version}"
if [[ $version == *"-"* ]]; then
echo "version ${version} is a pre-release"
echo "prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: publish wadge to crates.io
run: |
pkgver=$(cargo pkgid | cut -d '@' -f 2)
tagver="${{ steps.ctx.outputs.version }}"
if ! [ "$pkgver" = "$tagver" ]; then
echo "version mismatch, $pkgver (package) != $tagver (tag)"
exit 1
fi
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
path: artifacts
- run: |
mkdir -p ./libwadge
for dir in ./artifacts/wadge-*; do
target=${dir#./artifacts/wadge-}
mv ${dir}/lib/libwadge_sys.a ./libwadge/libwadge-${target}.a
done
- uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
draft: true
prerelease: true
generate_release_notes: true
files: |
./libwadge/*