-
Notifications
You must be signed in to change notification settings - Fork 1
339 lines (273 loc) · 11.8 KB
/
build.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
name: build
on:
workflow_dispatch:
pull_request:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
rust-hello-linux:
strategy:
matrix:
config:
- package: default
test-bin: ./result/bin/rust-hello
- package: rust-hello
test-bin: ./result/bin/rust-hello
- package: rust-hello-aarch64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-aarch64-linux-android
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-armv7-unknown-linux-musleabihf
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-wasm32-unknown-unknown
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
- package: rust-hello-wasm32-wasi
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
test-oci: docker load < ./result
- package: rust-hello-x86_64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/rust-hello.exe
test-oci: docker load < ./result
- package: rust-hello-x86_64-unknown-linux-musl
test-bin: ./result/bin/rust-hello
test-oci: |
docker load < ./result
docker run --rm rust-hello:$(nix eval --raw --override-input 'nixify' '.' ./examples/rust-hello#rust-hello-x86_64-unknown-linux-musl-oci.imageTag)
- package: rust-hello-debug
test-bin: ./result/bin/rust-hello
- package: rust-hello-debug-aarch64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-debug-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-debug-aarch64-linux-android
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-debug-armv7-unknown-linux-musleabihf
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-debug-wasm32-wasi
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
test-oci: docker load < ./result
- package: rust-hello-debug-x86_64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result
- package: rust-hello-debug-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/rust-hello.exe
test-oci: docker load < ./result
- package: rust-hello-debug-x86_64-unknown-linux-musl
test-bin: ./result/bin/rust-hello
test-oci: |
docker load < ./result
docker run --rm rust-hello:$(nix eval --raw --override-input 'nixify' '.' ./examples/rust-hello#rust-hello-x86_64-unknown-linux-musl-oci.imageTag)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}'
- run: ${{ matrix.config.test-bin }}
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}-oci'
if: ${{ matrix.config.package != 'default' && matrix.config.package != 'rust-hello' && matrix.config.package != 'rust-hello-debug' }}
- run: ${{ matrix.config.test-oci }}
rust-hello-macos:
strategy:
matrix:
# NOTE: Only build Wasm targets on Darwin here, since Mac machines are extremely slow on GitHub. Other targets are built as part of `rust-complex-macos`
config:
- package: rust-hello-wasm32-unknown-unknown
- package: rust-hello-wasm32-wasi
- package: rust-hello-debug-wasm32-unknown-unknown
- package: rust-hello-debug-wasm32-wasi
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}'
- run: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
rust-complex-linux:
strategy:
matrix:
config:
- package: default
test-bin: ./result/bin/foo
- package: rust-complex
test-bin: ./result/bin/foo
- package: rust-complex-aarch64-apple-darwin
test-bin: file ./result/bin/foo
- package: rust-complex-aarch64-linux-android
test-bin: file ./result/bin/foo
- package: rust-complex-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/foo
- package: rust-complex-armv7-unknown-linux-musleabihf
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/foo
- package: rust-complex-x86_64-apple-darwin
test-bin: file ./result/bin/foo
- package: rust-complex-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/foo.exe
suffix: .exe
- package: rust-complex-x86_64-unknown-linux-musl
test-bin: ./result/bin/foo
- package: rust-complex-debug
test-bin: ./result/bin/foo
- package: rust-complex-debug-aarch64-apple-darwin
test-bin: file ./result/bin/foo
- package: rust-complex-debug-aarch64-linux-android
test-bin: file ./result/bin/foo
- package: rust-complex-debug-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/foo
- package: rust-complex-debug-armv7-unknown-linux-musleabihf
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/foo
- package: rust-complex-debug-x86_64-apple-darwin
test-bin: file ./result/bin/foo
- package: rust-complex-debug-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/foo.exe
suffix: .exe
- package: rust-complex-debug-x86_64-unknown-linux-musl
test-bin: ./result/bin/foo
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: ./.github/actions/build-nix
with:
package: ${{ matrix.config.package }}
flake: ./examples/rust-complex
install-path: /bin/foo${{ matrix.config.suffix }}
- run: ${{ matrix.config.test-bin }}
rust-complex-macos:
strategy:
matrix:
config:
- package: default
test-bin: ./result/bin/foo
- package: rust-complex
test-bin: ./result/bin/foo
- package: rust-complex-aarch64-apple-darwin
test-bin: file ./result/bin/foo
- package: rust-complex-aarch64-unknown-linux-musl
test-bin: file ./result/bin/foo
- package: rust-complex-armv7-unknown-linux-musleabihf
test-bin: file ./result/bin/foo
- package: rust-complex-x86_64-apple-darwin
test-bin: ./result/bin/foo
- package: rust-complex-x86_64-pc-windows-gnu
test-bin: file ./result/bin/foo.exe
suffix: .exe
- package: rust-complex-x86_64-unknown-linux-musl
test-bin: file ./result/bin/foo
- package: rust-complex-debug
test-bin: ./result/bin/foo
- package: rust-complex-debug-aarch64-apple-darwin
test-bin: file ./result/bin/foo
- package: rust-complex-debug-aarch64-unknown-linux-musl
test-bin: file ./result/bin/foo
- package: rust-complex-debug-armv7-unknown-linux-musleabihf
test-bin: file ./result/bin/foo
- package: rust-complex-debug-x86_64-apple-darwin
test-bin: ./result/bin/foo
- package: rust-complex-debug-x86_64-pc-windows-gnu
test-bin: file ./result/bin/foo.exe
suffix: .exe
- package: rust-complex-debug-x86_64-unknown-linux-musl
test-bin: file ./result/bin/foo
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: ./.github/actions/build-nix
with:
package: ${{ matrix.config.package }}
flake: ./examples/rust-complex
install-path: /bin/foo${{ matrix.config.suffix }}
- run: ${{ matrix.config.test-bin }}
oci-linux:
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'pull_request' }}
permissions:
packages: write
needs:
- rust-hello-linux
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-nix
with:
cachixAuthToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
nix run -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#build-rust-hello-oci' rust-hello
nix profile install --inputs-from . 'nixpkgs#buildah'
buildah manifest push --all --format 'v2s2' rust-hello docker://ghcr.io/${{ github.repository_owner }}/nixify:rust-hello-${{ github.sha }}
docker run ghcr.io/${{ github.repository_owner }}/nixify:rust-hello-${{ github.sha }}
test-linux:
runs-on: ubuntu-22.04
needs:
- rust-complex-linux
- oci-linux
steps:
- uses: actions/download-artifact@v3
with:
name: rust-complex-x86_64-unknown-linux-musl
- run: chmod +x ./rust-complex-x86_64-unknown-linux-musl
- run: ./rust-complex-x86_64-unknown-linux-musl
test-macos:
runs-on: macos-12
needs: rust-complex-linux
steps:
- uses: actions/download-artifact@v3
with:
name: rust-complex-aarch64-apple-darwin
- uses: actions/download-artifact@v3
with:
name: rust-complex-x86_64-apple-darwin
- run: chmod +x ./rust-complex-x86_64-apple-darwin
- run: ./rust-complex-x86_64-apple-darwin
- run: lipo -create ./rust-complex-aarch64-apple-darwin ./rust-complex-x86_64-apple-darwin -output ./rust-complex-universal-darwin
- run: chmod +x ./rust-complex-universal-darwin
- run: ./rust-complex-universal-darwin
- uses: actions/upload-artifact@v3
with:
name: rust-complex-universal-darwin
path: rust-complex-universal-darwin
test-windows:
runs-on: windows-2022
needs: rust-complex-linux
steps:
- uses: actions/download-artifact@v3
with:
name: rust-complex-x86_64-pc-windows-gnu
- run: '& .\rust-complex-x86_64-pc-windows-gnu'
test-artifacts:
runs-on: ubuntu-22.04
needs:
- rust-complex-linux
- rust-complex-macos
- rust-hello-linux
- rust-hello-macos
- test-linux
- test-macos
- test-windows
steps:
- run: echo "binary artifacts are valid"