-
-
Notifications
You must be signed in to change notification settings - Fork 1
596 lines (518 loc) · 21.1 KB
/
ci.yaml
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
name: ci
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_TEST_DEBUG: 0
CROSS_CONTAINER_UID: 0
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
name: test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
toolchain: [stable]
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use-cross: false
run-integration-tests: true
supports-nix: true
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
run-integration-tests: true
supports-nix: true
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use-cross: true
run-integration-tests: false # Cannot run aarch64 binaries on x86_64
supports-nix: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
run-integration-tests: false # Cannot run aarch64 binaries on x86_64
supports-nix: true
# macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64
- os: macos-13 # intel
target: x86_64-apple-darwin
use-cross: false
run-integration-tests: true
supports-nix: true
- os: macos-latest # aarch64
toolchain: stable
target: aarch64-apple-darwin
use-cross: false
run-integration-tests: true
supports-nix: true
- os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
run-integration-tests: true
supports-nix: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install musl-tools incl. musl-gcc
uses: awalsh128/cache-apt-pkgs-action@v1
with:
# musl-tools provide `musl-gcc` which is required for `ring` which is required for `rustls` et al.
packages: musl-tools
version: 1.1
if: ${{ matrix.target == 'x86_64-unknown-linux-musl'}}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
- name: Install Erlang (non-macos)
uses: erlef/setup-beam@v1
with:
otp-version: "26.1"
elixir-version: "1.16.1"
rebar3-version: "3"
if: ${{ runner.os != 'macOS' }} # setup-beam does not support macOS
- name: Install Erlang (macos)
run: |
brew install erlang rebar3 elixir
mix local.hex --force
if: ${{ runner.os == 'macOS' }} # setup-beam does not support macOS
- name: Install Nix (not ARM MacOS)
uses: nixbuild/nix-quick-install-action@v27
if: ${{ matrix.supports-nix && matrix.target != 'aarch64-apple-darwin' }}
- name: Install Nix (ARM MacOS)
uses: cachix/install-nix-action@v25
if: ${{ matrix.supports-nix && matrix.target == 'aarch64-apple-darwin' }}
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
key: v1-${{ matrix.target }}
- name: Install Glistix
uses: clechasseur/rs-cargo@v2
with:
command: install
args: "--path compiler-cli --target ${{ matrix.target }} --debug --locked"
use-cross: ${{ matrix.use-cross }}
if: ${{ matrix.run-integration-tests }}
- name: Run tests
uses: clechasseur/rs-cargo@v2
with:
command: test
args: "--workspace --target ${{ matrix.target }}"
use-cross: ${{ matrix.use-cross }}
- name: test/project_erlang (non-windows)
run: |
glistix run && cd src && glistix run && cd ..
glistix check
glistix test && cd src && glistix test && cd ..
glistix docs build
working-directory: ./test/project_erlang
if: ${{ runner.os != 'Windows' && matrix.run-integration-tests }}
- name: test/project_erlang (windows)
run: |
glistix run && cd src && glistix run && cd ..
glistix check
glistix test && cd src && glistix test && cd ..
glistix docs build
working-directory: ./test/project_erlang_windows
if: ${{ runner.os == 'Windows' && matrix.run-integration-tests }}
- name: test/project_erlang export erlang-shipment (non-windows)
run: |
glistix export erlang-shipment
./build/erlang-shipment/entrypoint.sh run
working-directory: ./test/project_erlang
if: ${{ runner.os != 'Windows' && matrix.run-integration-tests }}
- name: test/project_erlang export erlang-shipment (windows)
run: |
glistix export erlang-shipment
.\build\erlang-shipment\entrypoint.ps1 run
working-directory: ./test/project_erlang_windows
if: ${{ runner.os == 'Windows' && matrix.run-integration-tests }}
- name: test/project_erlang export package-interface
run: |
glistix export package-interface --out="interface.json"
cat interface.json
working-directory: ./test/project_erlang
if: ${{ matrix.run-integration-tests }}
- name: test/external_only_javascript
run: ./test.sh
working-directory: ./test/external_only_javascript
if: ${{ matrix.run-integration-tests }}
env:
GLEAM_COMMAND: glistix
- name: test/external_only_erlang
run: ./test.sh
working-directory: ./test/external_only_erlang
if: ${{ matrix.run-integration-tests }}
env:
GLEAM_COMMAND: glistix
- name: test/project_javascript
run: |
glistix run
glistix check
glistix test
glistix docs build
working-directory: ./test/project_javascript
if: ${{ matrix.run-integration-tests }}
- name: test/project_path_deps
run: |
glistix update
glistix check
working-directory: ./test/project_path_deps/project_a
if: ${{ matrix.run-integration-tests }}
- name: Test project generation (Erlang)
env:
TEMP_PROJECT_DIR: ${{ runner.temp }}
run: |
# Create project in temp dir to avoid Git interference
cd "${TEMP_PROJECT_DIR}"
glistix new lib_project
cd lib_project
glistix run --target erlang
glistix test --target erlang
# Test adding of deps
glistix add exception # No specifier
glistix add gleam_http@3 # Version specifier
glistix test --target erlang
# Test documentation generation
# Workaround for lack of --target option for docs build
# TODO: Remove this workaround after Gleam 1.4
# (See https://github.com/gleam-lang/gleam/pull/3333)
sed -i -e 's/target = "nix"/target = "erlang"/' gleam.toml
glistix docs build
# Assert that module metadata has been written
ls build/dev/erlang/lib_project/_gleam_artefacts/lib_project.cache
# Assert that HTML docs and their assets have been written
ls build/dev/docs/lib_project/index.html
ls build/dev/docs/lib_project/lib_project.html
ls build/dev/docs/lib_project/css/atom-one-light.min.css
ls build/dev/docs/lib_project/css/atom-one-dark.min.css
ls build/dev/docs/lib_project/css/index.css
ls build/dev/docs/lib_project/js/highlight.min.js
ls build/dev/docs/lib_project/js/highlightjs-gleam.js
ls build/dev/docs/lib_project/js/highlightjs-erlang.min.js
ls build/dev/docs/lib_project/js/highlightjs-elixir.min.js
ls build/dev/docs/lib_project/js/highlightjs-javascript.min.js
ls build/dev/docs/lib_project/js/highlightjs-typescript.min.js
ls build/dev/docs/lib_project/js/highlightjs-nix.min.js
ls build/dev/docs/lib_project/js/lunr.min.js
ls build/dev/docs/lib_project/js/index.js
ls build/dev/docs/lib_project/fonts/karla-v23-bold-latin-ext.woff2
ls build/dev/docs/lib_project/fonts/karla-v23-bold-latin.woff2
ls build/dev/docs/lib_project/fonts/karla-v23-regular-latin-ext.woff2
ls build/dev/docs/lib_project/fonts/karla-v23-regular-latin.woff2
ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-cyrillic-ext.woff2
ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-cyrillic.woff2
ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-greek-ext.woff2
ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-greek.woff2
ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-latin-ext.woff2
ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-latin.woff2
if: ${{ matrix.run-integration-tests }}
- name: Test project generation (Nix - not Windows)
env:
TEMP_PROJECT_DIR: ${{ runner.temp }}
run: |
# Create project in temp dir to avoid Git interference
cd "${TEMP_PROJECT_DIR}"
glistix new nix_lib_project
cd nix_lib_project
glistix run
glistix test
glistix run --target nix
glistix test --target nix
glistix docs build
# Assert that module metadata has been written
ls build/dev/nix/nix_lib_project/_gleam_artefacts/nix_lib_project.cache
# Assert that HTML docs and their assets have been written
ls build/dev/docs/nix_lib_project/index.html
ls build/dev/docs/nix_lib_project/nix_lib_project.html
ls build/dev/docs/nix_lib_project/css/atom-one-light.min.css
ls build/dev/docs/nix_lib_project/css/atom-one-dark.min.css
ls build/dev/docs/nix_lib_project/css/index.css
ls build/dev/docs/nix_lib_project/js/highlight.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-gleam.js
ls build/dev/docs/nix_lib_project/js/highlightjs-erlang.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-elixir.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-javascript.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-typescript.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-nix.min.js
ls build/dev/docs/nix_lib_project/js/lunr.min.js
ls build/dev/docs/nix_lib_project/js/index.js
ls build/dev/docs/nix_lib_project/fonts/karla-v23-bold-latin-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/karla-v23-bold-latin.woff2
ls build/dev/docs/nix_lib_project/fonts/karla-v23-regular-latin-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/karla-v23-regular-latin.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-cyrillic-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-cyrillic.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-greek-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-greek.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-latin-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-latin.woff2
if: ${{ matrix.run-integration-tests && matrix.supports-nix }}
- name: Test project generation (Nix - Windows)
env:
TEMP_PROJECT_DIR: ${{ runner.temp }}
run: |
# Create project in temp dir to avoid Git interference
cd "${TEMP_PROJECT_DIR}"
glistix new nix_lib_project
cd nix_lib_project
glistix build
glistix build --target nix
glistix docs build
# Assert that module metadata has been written
ls build/dev/nix/nix_lib_project/_gleam_artefacts/nix_lib_project.cache
# Assert that HTML docs and their assets have been written
ls build/dev/docs/nix_lib_project/index.html
ls build/dev/docs/nix_lib_project/nix_lib_project.html
ls build/dev/docs/nix_lib_project/css/atom-one-light.min.css
ls build/dev/docs/nix_lib_project/css/atom-one-dark.min.css
ls build/dev/docs/nix_lib_project/css/index.css
ls build/dev/docs/nix_lib_project/js/highlight.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-gleam.js
ls build/dev/docs/nix_lib_project/js/highlightjs-erlang.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-elixir.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-javascript.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-typescript.min.js
ls build/dev/docs/nix_lib_project/js/highlightjs-nix.min.js
ls build/dev/docs/nix_lib_project/js/lunr.min.js
ls build/dev/docs/nix_lib_project/js/index.js
ls build/dev/docs/nix_lib_project/fonts/karla-v23-bold-latin-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/karla-v23-bold-latin.woff2
ls build/dev/docs/nix_lib_project/fonts/karla-v23-regular-latin-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/karla-v23-regular-latin.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-cyrillic-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-cyrillic.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-greek-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-greek.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-latin-ext.woff2
ls build/dev/docs/nix_lib_project/fonts/ubuntu-mono-v15-regular-latin.woff2
if: ${{ matrix.run-integration-tests && !matrix.supports-nix }}
test-flake:
name: test-flake
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: macos-12 # intel
target: x86_64-apple-darwin
- os: macos-14 # aarch64
target: aarch64-apple-darwin
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix (not ARM MacOS)
uses: nixbuild/nix-quick-install-action@v27
if: ${{ matrix.target != 'aarch64-apple-darwin' }}
- name: Install Nix (ARM MacOS)
uses: cachix/install-nix-action@v25
if: ${{ matrix.target == 'aarch64-apple-darwin' }}
- uses: DeterminateSystems/magic-nix-cache-action@v4
- name: Check Flake
run: nix flake check
- name: Build Flake
run: nix build -L .
- name: Run Flake
run: nix run -L . -- --help
- name: Generate test project
run: |
mkdir .test-flake
cd .test-flake
nix run -L .. -- new newpkg
- name: Build generated project without flake
run: |
# Build to generate manifest.toml
nix run -L ../.. -- build
git add .
working-directory: ./.test-flake/newpkg
- name: Check generated project's flake
run: nix flake check --override-input glistix ../..
working-directory: ./.test-flake/newpkg
- name: Build generated project's flake
run: |
nix build -L --override-input glistix ../.. .
# Ensure build artifacts at 'result'
ls -ltah result/dev/nix
working-directory: ./.test-flake/newpkg
- name: Test 'loadGlistixPackage' on generated project
run: "nix eval -L --override-input glistix ../.. .#lib --apply '(lib: (lib.loadGlistixPackage { }).main { })' --impure"
working-directory: ./.test-flake/newpkg
test-wasm:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: wasm32-unknown-unknown
- uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install wasm-pack
run: |
curl -sSL https://rustwasm.github.io/wasm-pack/installer/init.sh | sh
- name: Run wasm tests
run: wasm-pack test --node compiler-wasm
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
# validate:
# name: validate
# runs-on: ubuntu-latest
# timeout-minutes: 10
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Install Rust toolchain
# uses: dtolnay/rust-toolchain@stable
# with:
# toolchain: stable
#
# - name: Install cargo-deny
# run: |
# set -e
# curl -L https://github.com/EmbarkStudios/cargo-deny/releases/download/0.14.18/cargo-deny-0.14.18-x86_64-unknown-linux-musl.tar.gz | tar xzf -
# mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny
# echo `pwd` >> $GITHUB_PATH
#
# - name: Validate deps
# run: cargo deny check
lint-build:
name: lint-build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
key: v1-linux-gnu
- name: Run linter
run: cargo clippy --workspace
- run: cargo build
- name: Upload artifact (Ubuntu)
uses: actions/upload-artifact@v4
with:
name: glistix
path: target/debug/glistix
test-projects:
name: test-projects
needs: lint-build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install Erlang
uses: erlef/setup-beam@v1
with:
otp-version: "26.1"
elixir-version: "1.16.1"
rebar3-version: "3"
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v27
- name: Download Glistix binary from previous job
uses: actions/download-artifact@v4
with:
name: glistix
path: ./test
- name: Configure test projects to use Glistix binary
run: |
echo $PWD/ >> $GITHUB_PATH
chmod +x ./glistix
sed -i 's/cargo run --quiet --/glistix/' */Makefile
sed -i 's/cargo run --/glistix/' */Makefile
working-directory: ./test
- name: test/language Erlang
run: make clean erlang
working-directory: ./test/language
- name: test/language JavaScript with NodeJS
run: make clean nodejs
working-directory: ./test/language
- name: test/language JavaScript with Deno
run: make clean deno
working-directory: ./test/language
- name: test/language JavaScript with Bun
run: make clean bun
working-directory: ./test/language
- name: test/language Nix
run: make clean nix
working-directory: ./test/language
- name: test/compile_package0
run: make
working-directory: ./test/compile_package0
- name: test/compile_package1
run: make
working-directory: ./test/compile_package1
- name: Test JavaScript prelude
run: make
working-directory: ./test/javascript_prelude
- name: Test export of hex tarball
run: make test
working-directory: ./test/hextarball
- name: Test running modules
run: make test
working-directory: ./test/running_modules