Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / .github / workflows / ci.yaml
18 kB 542 lines
1name: ci 2on: 3 pull_request: 4 paths-ignore: 5 - "CHANGELOG.md" 6 - "docs/**" 7 push: 8 branches: 9 - main 10 workflow_dispatch: 11 12env: 13 CARGO_TERM_COLOR: always 14 RUSTFLAGS: "-D warnings" 15 CARGO_INCREMENTAL: 0 16 CARGO_PROFILE_DEV_DEBUG: 0 17 CARGO_PROFILE_TEST_DEBUG: 0 18 CROSS_CONTAINER_UID: 0 19 20permissions: 21 contents: read 22 23concurrency: 24 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 25 cancel-in-progress: true 26 27jobs: 28 test: 29 name: test 30 runs-on: ${{ matrix.os }} 31 timeout-minutes: 30 32 strategy: 33 fail-fast: false 34 matrix: 35 toolchain: [stable] 36 target: 37 - x86_64-unknown-linux-gnu 38 - x86_64-unknown-linux-musl 39 - aarch64-unknown-linux-gnu 40 - aarch64-unknown-linux-musl 41 - x86_64-apple-darwin 42 - x86_64-pc-windows-msvc 43 include: 44 - os: ubuntu-latest 45 target: x86_64-unknown-linux-gnu 46 binary: x86-64 47 cargo-tool: cargo 48 run-integration-tests: true 49 - os: ubuntu-latest 50 target: x86_64-unknown-linux-musl 51 binary: x86-64 52 cargo-tool: cross 53 run-integration-tests: true 54 - os: ubuntu-latest 55 target: aarch64-unknown-linux-gnu 56 binary: aarch64 57 cargo-tool: cross 58 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 59 - os: ubuntu-latest 60 target: aarch64-unknown-linux-musl 61 binary: aarch64 62 cargo-tool: cross 63 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 64 - os: macos-15-intel # intel 65 target: x86_64-apple-darwin 66 binary: x86_64 67 cargo-tool: cargo 68 run-integration-tests: true 69 - os: macos-latest # aarch64 70 toolchain: stable 71 target: aarch64-apple-darwin 72 binary: arm64 73 cargo-tool: cargo 74 run-integration-tests: true 75 - os: windows-2022 76 target: x86_64-pc-windows-msvc 77 binary: x86-64 78 cargo-tool: cargo 79 run-integration-tests: true 80 steps: 81 - name: Checkout repository 82 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 83 with: 84 persist-credentials: false 85 86 - name: Install musl-tools incl. musl-gcc 87 uses: awalsh128/cache-apt-pkgs-action@5513791f75b039e2a79653b1a92238d3fb8d99b4 # v1.6.2 88 with: 89 # musl-tools provide `musl-gcc` which is required for `ring` which is required for `rustls` et al. 90 packages: musl-tools 91 version: 1.1 92 if: ${{ matrix.target == 'x86_64-unknown-linux-musl'}} 93 94 - name: Install Rust toolchain 95 uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable 96 with: 97 toolchain: ${{ matrix.toolchain }} 98 target: ${{ matrix.target }} 99 100 - name: Install Erlang 101 uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.24.0 102 with: 103 otp-version: "29" 104 elixir-version: "1.19" 105 rebar3-version: "3" 106 107 - name: Setup Node 108 uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 109 with: 110 node-version: "25" 111 112 - name: Setup Deno 113 uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4 114 with: 115 deno-version: "2.2" 116 117 - name: Setup Bun 118 uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 119 with: 120 bun-version: "1.2" 121 122 - name: Handle Rust dependencies caching 123 uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 124 with: 125 key: v1-${{ matrix.target }} 126 127 - name: Install Gleam 128 uses: clechasseur/rs-cargo@b897b7d2f083c6274295825fdbd5a39b825c3f82 # v5.0.6 129 with: 130 command: install 131 args: "--path gleam-bin --target ${{ matrix.target }} --debug --locked --force" 132 tool: ${{ matrix.cargo-tool }} 133 if: ${{ matrix.run-integration-tests }} 134 135 - name: Verify binary architecture 136 shell: bash 137 run: | 138 BINARY_PATH="${CARGO_HOME}/bin/gleam" 139 if [[ "${{ matrix.target }}" == *"windows"* ]]; then 140 BINARY_PATH="${BINARY_PATH}.exe" 141 fi 142 143 if ! file -b "$BINARY_PATH" | grep -q "${{ matrix.binary }}"; then 144 echo "error: Architecture mismatch" 145 echo "Expected architecture: '${{ matrix.binary }}'" 146 echo "Found binary type: '$(file -b "$BINARY_PATH")'" 147 exit 1 148 fi 149 echo "ok: Architecture match" 150 if: ${{ matrix.run-integration-tests }} 151 152 - name: Run tests 153 uses: clechasseur/rs-cargo@b897b7d2f083c6274295825fdbd5a39b825c3f82 # v5.0.6 154 with: 155 command: test 156 # We only want to run `test-{output,commands}` when running integration tests. 157 # There's a caveat though: when `cargo-tool` is `cross` it uses a container 158 # and would result in these integration tests failing due to not finding 159 # the escript binary. So, in case `cargo-tool != cargo` we'll skip the 160 # `test-output` tests as well. 161 args: >- 162 --workspace 163 --target ${{ matrix.target }} 164 ${{ ((matrix.run-integration-tests && matrix.cargo-tool == 'cargo') 165 && ' ') 166 || '--exclude test-output --exclude test-commands' }} 167 tool: ${{ matrix.cargo-tool }} 168 169 - name: test/project_erlang (non-windows) 170 run: | 171 gleam run && cd src && gleam run && cd .. 172 gleam check 173 gleam test && cd src && gleam test && cd .. 174 gleam docs build 175 working-directory: ./test/project_erlang 176 if: ${{ runner.os != 'Windows' && matrix.run-integration-tests }} 177 178 - name: test/project_erlang (windows) 179 run: | 180 gleam run && cd src && gleam run && cd .. 181 gleam check 182 gleam test && cd src && gleam test && cd .. 183 gleam docs build 184 working-directory: ./test/project_erlang_windows 185 if: ${{ runner.os == 'Windows' && matrix.run-integration-tests }} 186 187 - name: test/project_erlang export erlang-shipment (non-windows) 188 run: | 189 gleam export erlang-shipment 190 ./build/erlang-shipment/entrypoint.sh run 191 working-directory: ./test/project_erlang 192 if: ${{ runner.os != 'Windows' && matrix.run-integration-tests }} 193 194 - name: test/project_erlang export erlang-shipment (windows) 195 run: | 196 gleam export erlang-shipment 197 .\build\erlang-shipment\entrypoint.ps1 run 198 working-directory: ./test/project_erlang_windows 199 if: ${{ runner.os == 'Windows' && matrix.run-integration-tests }} 200 201 - name: test/project_erlang export package-interface (non-windows) 202 run: | 203 gleam export package-interface --out="interface.json" 204 cat interface.json 205 working-directory: ./test/project_erlang 206 if: ${{ runner.os != 'Windows' && matrix.run-integration-tests }} 207 208 - name: test/project_erlang export package-interface (windows) 209 run: | 210 gleam export package-interface --out="interface.json" 211 cat interface.json 212 working-directory: ./test/project_erlang_windows 213 if: ${{ runner.os == 'Windows' && matrix.run-integration-tests }} 214 215 - name: test/project_erlang export package-information 216 run: | 217 gleam export package-information --out="gleam.json" 218 cat gleam.json 219 working-directory: ./test/project_erlang 220 if: ${{ matrix.run-integration-tests }} 221 222 - name: test/external_only_javascript 223 run: ./test.sh 224 working-directory: ./test/external_only_javascript 225 if: ${{ matrix.run-integration-tests }} 226 env: 227 GLEAM_COMMAND: gleam 228 229 - name: test/external_only_erlang 230 run: ./test.sh 231 working-directory: ./test/external_only_erlang 232 if: ${{ matrix.run-integration-tests }} 233 env: 234 GLEAM_COMMAND: gleam 235 236 - name: test/root_package_not_compiled_when_running_dep 237 run: ./test.sh 238 working-directory: ./test/root_package_not_compiled_when_running_dep 239 if: ${{ matrix.run-integration-tests }} 240 env: 241 GLEAM_COMMAND: gleam 242 243 - name: test/erlang_shipment_no_dev_deps 244 run: ./test.sh 245 working-directory: ./test/erlang_shipment_no_dev_deps 246 if: ${{ matrix.run-integration-tests }} 247 env: 248 GLEAM_COMMAND: gleam 249 250 - name: test/project_javascript 251 run: | 252 gleam run 253 gleam check 254 gleam test 255 gleam docs build 256 working-directory: ./test/project_javascript 257 if: ${{ matrix.run-integration-tests }} 258 259 - name: test/project_path_deps 260 run: | 261 gleam update 262 gleam check 263 working-directory: ./test/project_path_deps/project_a 264 if: ${{ matrix.run-integration-tests }} 265 266 - name: test/project_git_deps 267 run: | 268 gleam update 269 gleam check 270 working-directory: ./test/project_git_deps 271 if: ${{ matrix.run-integration-tests }} 272 273 - name: test/project_git_deps_path 274 run: ./test.sh 275 working-directory: ./test/project_git_deps_path 276 if: ${{ matrix.run-integration-tests }} 277 env: 278 GLEAM_COMMAND: gleam 279 280 - name: Test project generation 281 run: | 282 gleam new lib_project 283 cd lib_project 284 gleam run 285 gleam test 286 287 # Test adding of deps 288 gleam add exception # No specifier 289 gleam add gleam_http@4 # Version specifier 290 gleam test 291 292 # Test documentation generation 293 gleam docs build 294 295 # Assert that module metadata has been written 296 ls build/dev/erlang/lib_project/_gleam_artefacts/lib_project.cache 297 298 # Assert that HTML docs and their assets have been written 299 ls build/dev/docs/lib_project/index.html 300 ls build/dev/docs/lib_project/lib_project.html 301 ls build/dev/docs/lib_project/css/atom-one-light.min.css 302 ls build/dev/docs/lib_project/css/atom-one-dark.min.css 303 ls build/dev/docs/lib_project/css/index.css 304 ls build/dev/docs/lib_project/js/highlight.min.js 305 ls build/dev/docs/lib_project/js/highlightjs-gleam.js 306 ls build/dev/docs/lib_project/js/highlightjs-erlang.min.js 307 ls build/dev/docs/lib_project/js/highlightjs-elixir.min.js 308 ls build/dev/docs/lib_project/js/highlightjs-javascript.min.js 309 ls build/dev/docs/lib_project/js/highlightjs-typescript.min.js 310 ls build/dev/docs/lib_project/js/lunr.min.js 311 ls build/dev/docs/lib_project/js/index.js 312 ls build/dev/docs/lib_project/fonts/karla-v23-bold-latin-ext.woff2 313 ls build/dev/docs/lib_project/fonts/karla-v23-bold-latin.woff2 314 ls build/dev/docs/lib_project/fonts/karla-v23-regular-latin-ext.woff2 315 ls build/dev/docs/lib_project/fonts/karla-v23-regular-latin.woff2 316 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-cyrillic-ext.woff2 317 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-cyrillic.woff2 318 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-greek-ext.woff2 319 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-greek.woff2 320 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-latin-ext.woff2 321 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-latin.woff2 322 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-box.woff2 323 if: ${{ matrix.run-integration-tests }} 324 325 test-wasm: 326 runs-on: ubuntu-latest 327 timeout-minutes: 30 328 steps: 329 - name: Checkout repository 330 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 331 with: 332 persist-credentials: false 333 334 - name: Install Rust toolchain 335 uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable 336 with: 337 toolchain: stable 338 target: wasm32-unknown-unknown 339 340 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 341 with: 342 node-version: "25" 343 344 - name: Install wasm-pack 345 run: | 346 curl -sSL https://rustwasm.github.io/wasm-pack/installer/init.sh | sh 347 348 - name: Run wasm tests 349 run: wasm-pack test --node compiler-wasm 350 351 rustfmt: 352 name: rustfmt 353 runs-on: ubuntu-latest 354 timeout-minutes: 10 355 steps: 356 - name: Checkout repository 357 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 358 with: 359 persist-credentials: false 360 361 - name: Install Rust toolchain 362 uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable 363 with: 364 toolchain: stable 365 components: rustfmt 366 367 - run: cargo fmt --all -- --check 368 369 validate: 370 name: validate 371 runs-on: ubuntu-latest 372 timeout-minutes: 10 373 steps: 374 - name: Checkout repository 375 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 376 with: 377 persist-credentials: false 378 379 - name: Ensure no merge commits 380 uses: NexusPHP/no-merge-commits@109a3342781ddcf26b2fa739f29e8ee9f68b7d8e # v2.4.1 381 if: github.event_name == 'pull_request' 382 with: 383 token: ${{ secrets.GITHUB_TOKEN }} 384 385 - name: Install Rust toolchain 386 uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable 387 with: 388 toolchain: stable 389 390 - name: Install cargo-deny 391 run: | 392 set -e 393 curl -L https://github.com/EmbarkStudios/cargo-deny/releases/download/0.18.6/cargo-deny-0.18.6-x86_64-unknown-linux-musl.tar.gz | tar xzf - 394 mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny 395 echo `pwd` >> $GITHUB_PATH 396 397 - name: Validate deps 398 run: cargo deny check 399 400 lint-build: 401 name: lint-build 402 runs-on: ubuntu-latest 403 timeout-minutes: 10 404 steps: 405 - name: Checkout repository 406 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 407 with: 408 persist-credentials: false 409 410 - name: Install Rust toolchain 411 uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable 412 with: 413 toolchain: stable 414 components: clippy 415 416 - name: Handle Rust dependencies caching 417 uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 418 with: 419 key: v1-linux-gnu 420 421 - name: Run linter 422 run: cargo clippy --workspace 423 424 - run: cargo build 425 426 - name: Upload artifact (Ubuntu) 427 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 428 with: 429 name: gleam 430 path: target/debug/gleam 431 432 test-projects: 433 name: test-projects 434 needs: lint-build 435 runs-on: ubuntu-latest 436 timeout-minutes: 10 437 steps: 438 - name: Checkout repository 439 uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 440 with: 441 persist-credentials: false 442 443 - name: Install Deno 444 uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4 445 with: 446 deno-version: v2.x 447 448 - name: Install Bun 449 uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 450 451 - name: Install Erlang 452 uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.24.0 453 with: 454 otp-version: "29" 455 elixir-version: "1.19" 456 rebar3-version: "3" 457 458 - name: Download Gleam binary from previous job 459 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 460 with: 461 name: gleam 462 path: ./test 463 464 - name: Configure test projects to use Gleam binary 465 run: | 466 echo $PWD/ >> $GITHUB_PATH 467 chmod +x ./gleam 468 sed -i 's/cargo run --quiet --/gleam/' */Makefile 469 sed -i 's/cargo run --/gleam/' */Makefile 470 working-directory: ./test 471 472 - name: test/language Erlang 473 run: make clean erlang 474 working-directory: ./test/language 475 476 - name: test/language JavaScript with NodeJS 477 run: make clean nodejs 478 working-directory: ./test/language 479 480 - name: test/language JavaScript with Deno 481 run: make clean deno 482 working-directory: ./test/language 483 484 - name: test/language JavaScript with Bun 485 run: make clean bun 486 working-directory: ./test/language 487 488 - name: test/compile_package0 489 run: make 490 working-directory: ./test/compile_package0 491 492 - name: test/compile_package1 493 run: make 494 working-directory: ./test/compile_package1 495 496 - name: Test JavaScript prelude 497 run: make 498 working-directory: ./test/javascript_prelude 499 500 - name: Test generated TypeScript declarations 501 run: make test 502 working-directory: ./test/typescript_declarations 503 504 - name: Test export of hex tarball 505 run: make test 506 working-directory: ./test/hextarball 507 508 - name: test/running_modules 509 run: make test-all 510 working-directory: ./test/running_modules 511 512 - name: test/multi_namespace 513 run: ./test.sh 514 working-directory: ./test/multi_namespace 515 516 - name: test/multi_namespace_not_top_level 517 run: ./test.sh 518 working-directory: ./test/multi_namespace_not_top_level 519 520 - name: Test FFI in subdirectories 521 run: make 522 working-directory: ./test/subdir_ffi 523 524 - name: test/unicode_path 525 run: make 526 working-directory: ./test/unicode_path ⭐ 527 528 - name: test/assert 529 run: make test-all 530 working-directory: ./test/assert 531 532 - name: Test publishing with default main 533 run: ./test.sh 534 working-directory: ./test/publishing_default_main 535 536 - name: Test publishing with src symlink escape 537 run: ./test.sh 538 working-directory: ./test/publishing_src_symlink_escape 539 540 - name: Test publishing with priv symlink escape 541 run: ./test.sh 542 working-directory: ./test/publishing_priv_symlink_escape