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
13 kB 394 lines
1name: ci 2on: 3 pull_request: 4 push: 5 branches: 6 - main 7 8env: 9 CARGO_TERM_COLOR: always 10 RUSTFLAGS: "-D warnings" 11 CARGO_INCREMENTAL: 0 12 CARGO_PROFILE_DEV_DEBUG: 0 13 CARGO_PROFILE_TEST_DEBUG: 0 14 CROSS_CONTAINER_UID: 0 15 16jobs: 17 test: 18 name: test 19 runs-on: ${{ matrix.os }} 20 strategy: 21 fail-fast: false 22 matrix: 23 toolchain: [stable] 24 target: 25 - x86_64-unknown-linux-gnu 26 - x86_64-unknown-linux-musl 27 # https://github.com/gleam-lang/gleam/issues/2221 28 # - aarch64-unknown-linux-gnu 29 - aarch64-unknown-linux-musl 30 - x86_64-apple-darwin 31 - x86_64-pc-windows-msvc 32 include: 33 - os: ubuntu-latest 34 target: x86_64-unknown-linux-gnu 35 use-cross: false 36 run-integration-tests: true 37 - os: ubuntu-latest 38 target: x86_64-unknown-linux-musl 39 use-cross: true 40 run-integration-tests: true 41 # - os: ubuntu-latest 42 # target: aarch64-unknown-linux-gnu 43 # use-cross: true 44 # run-integration-tests: false # Cannot run aarch64 binaries on x86_64 45 - os: ubuntu-latest 46 target: aarch64-unknown-linux-musl 47 use-cross: true 48 run-integration-tests: false # Cannot run aarch64 binaries on x86_64 49 - os: macos-latest 50 target: x86_64-apple-darwin 51 use-cross: false 52 run-integration-tests: true 53 - os: windows-latest 54 target: x86_64-pc-windows-msvc 55 use-cross: false 56 run-integration-tests: true 57 steps: 58 - name: Checkout repository 59 uses: actions/checkout@v2 60 61 - name: Install musl-tools incl. musl-gcc 62 uses: awalsh128/cache-apt-pkgs-action@v1 63 with: 64 # musl-tools provide `musl-gcc` which is required for `ring` which is required for `rustls` et al. 65 packages: musl-tools 66 version: 1.1 67 if: ${{ matrix.target == 'x86_64-unknown-linux-musl'}} 68 69 - name: Install Rust toolchain 70 uses: actions-rs/toolchain@v1 71 with: 72 toolchain: ${{ matrix.toolchain }} 73 target: ${{ matrix.target }} 74 override: true 75 default: true 76 profile: minimal 77 78 - name: Install Erlang (non-macos) 79 uses: erlef/setup-beam@v1.15.4 80 with: 81 otp-version: "25.1" 82 elixir-version: "1.14.1" 83 rebar3-version: "3" 84 if: ${{ matrix.os != 'macos-latest' }} # setup-beam does not support macOS 85 86 - name: Install Erlang (macos) 87 run: | 88 brew install erlang rebar3 elixir 89 mix local.hex --force 90 if: ${{ matrix.os == 'macos-latest' }} # setup-beam does not support macOS 91 92 - name: Handle Rust dependencies caching 93 uses: Swatinem/rust-cache@v2 94 with: 95 key: v1-${{ matrix.target }} 96 97 - name: Install Gleam 98 uses: actions-rs/cargo@v1 99 with: 100 command: install 101 args: "--path compiler-cli --target ${{ matrix.target }} --debug --locked" 102 use-cross: ${{ matrix.use-cross }} 103 if: ${{ matrix.run-integration-tests }} 104 105 - name: Run tests 106 uses: actions-rs/cargo@v1 107 with: 108 command: test 109 args: "--workspace --target ${{ matrix.target }}" 110 use-cross: ${{ matrix.use-cross }} 111 112 - name: test/project_erlang (non-windows) 113 run: | 114 gleam run && cd src && gleam run && cd .. 115 gleam check 116 gleam test && cd src && gleam test && cd .. 117 gleam docs build 118 working-directory: ./test/project_erlang 119 if: ${{ matrix.os != 'windows-latest' && matrix.run-integration-tests }} 120 121 - name: test/project_erlang (windows) 122 run: | 123 gleam run && cd src && gleam run && cd .. 124 gleam check 125 gleam test && cd src && gleam test && cd .. 126 gleam docs build 127 working-directory: ./test/project_erlang_windows 128 if: ${{ matrix.os == 'windows-latest' && matrix.run-integration-tests }} 129 130 - name: test/project_erlang export erlang-shipment (non-windows) 131 run: | 132 gleam export erlang-shipment 133 ./build/erlang-shipment/entrypoint.sh run 134 working-directory: ./test/project_erlang 135 if: ${{ matrix.os != 'windows-latest' && matrix.run-integration-tests }} 136 137 - name: test/project_erlang export erlang-shipment (windows) 138 run: | 139 gleam export erlang-shipment 140 .\build\erlang-shipment\entrypoint.ps1 run 141 working-directory: ./test/project_erlang_windows 142 if: ${{ matrix.os == 'windows-latest' && matrix.run-integration-tests }} 143 144 - name: test/project_erlang export package-interface 145 run: | 146 gleam export package-interface --out="interface.json" 147 cat interface.json 148 working-directory: ./test/project_erlang 149 if: ${{ matrix.run-integration-tests }} 150 151 - name: test/external_only_javascript 152 run: make 153 working-directory: ./test/external_only_javascript 154 if: ${{ matrix.run-integration-tests }} 155 156 - name: test/external_only_erlang 157 run: make 158 working-directory: ./test/external_only_erlang 159 if: ${{ matrix.run-integration-tests }} 160 161 - name: test/project_javascript 162 run: | 163 gleam run 164 gleam check 165 gleam test 166 gleam docs build 167 working-directory: ./test/project_javascript 168 if: ${{ matrix.run-integration-tests }} 169 170 - name: test/project_path_deps 171 run: | 172 gleam update 173 gleam check 174 working-directory: ./test/project_path_deps/project_a 175 if: ${{ matrix.run-integration-tests }} 176 177 - name: Test project generation 178 run: | 179 gleam new lib_project 180 cd lib_project 181 gleam run 182 gleam test 183 gleam docs build 184 185 # Assert that module metadata has been written 186 ls build/dev/erlang/lib_project/_gleam_artefacts/lib_project.cache 187 188 # Assert that HTML docs and their assets have been written 189 ls build/dev/docs/lib_project/index.html 190 ls build/dev/docs/lib_project/lib_project.html 191 ls build/dev/docs/lib_project/css/atom-one-light.min.css 192 ls build/dev/docs/lib_project/css/atom-one-dark.min.css 193 ls build/dev/docs/lib_project/css/index.css 194 ls build/dev/docs/lib_project/js/highlight.min.js 195 ls build/dev/docs/lib_project/js/highlightjs-gleam.js 196 ls build/dev/docs/lib_project/js/highlightjs-erlang.min.js 197 ls build/dev/docs/lib_project/js/highlightjs-elixir.min.js 198 ls build/dev/docs/lib_project/js/highlightjs-javascript.min.js 199 ls build/dev/docs/lib_project/js/highlightjs-typescript.min.js 200 ls build/dev/docs/lib_project/js/lunr.min.js 201 ls build/dev/docs/lib_project/js/index.js 202 ls build/dev/docs/lib_project/fonts/karla-v23-bold-latin-ext.woff2 203 ls build/dev/docs/lib_project/fonts/karla-v23-bold-latin.woff2 204 ls build/dev/docs/lib_project/fonts/karla-v23-regular-latin-ext.woff2 205 ls build/dev/docs/lib_project/fonts/karla-v23-regular-latin.woff2 206 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-cyrillic-ext.woff2 207 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-cyrillic.woff2 208 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-greek-ext.woff2 209 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-greek.woff2 210 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-latin-ext.woff2 211 ls build/dev/docs/lib_project/fonts/ubuntu-mono-v15-regular-latin.woff2 212 if: ${{ matrix.run-integration-tests }} 213 214 test-wasm: 215 runs-on: ubuntu-latest 216 steps: 217 - name: Checkout repository 218 uses: actions/checkout@v2 219 220 - name: Install Rust toolchain 221 uses: actions-rs/toolchain@v1 222 with: 223 toolchain: stable 224 target: wasm32-unknown-unknown 225 profile: minimal 226 override: true 227 228 - uses: actions/setup-node@v2 229 with: 230 node-version: "16" 231 232 - name: Install wasm-pack 233 run: | 234 curl -L --output wasm-pack-init https://rustwasm.github.io/wasm-pack/installer/init.sh \ 235 && chmod +x wasm-pack-init \ 236 && ./wasm-pack-init \ 237 && rm wasm-pack-init 238 - name: Run wasm tests 239 working-directory: ./compiler-wasm 240 run: wasm-pack test --node 241 242 rustfmt: 243 name: rustfmt 244 runs-on: ubuntu-latest 245 steps: 246 - name: Checkout repository 247 uses: actions/checkout@v2 248 249 - name: Install Rust toolchain 250 uses: actions-rs/toolchain@v1 251 with: 252 toolchain: stable 253 override: true 254 default: true 255 profile: minimal 256 components: rustfmt 257 258 - name: Check formatting 259 uses: actions-rs/cargo@v1 260 with: 261 command: fmt 262 args: --all -- --check 263 264 validate-deps: 265 name: validate-deps 266 runs-on: ubuntu-latest 267 steps: 268 - name: Checkout repository 269 uses: actions/checkout@v2 270 271 - name: Install Rust toolchain 272 uses: actions-rs/toolchain@v1 273 with: 274 toolchain: stable 275 override: true 276 default: true 277 profile: minimal 278 279 - name: Install cargo-deny 280 run: | 281 set -e 282 curl -L https://github.com/EmbarkStudios/cargo-deny/releases/download/0.8.5/cargo-deny-0.8.5-x86_64-unknown-linux-musl.tar.gz | tar xzf - 283 mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny 284 echo `pwd` >> $GITHUB_PATH 285 286 - name: Validate deps 287 uses: actions-rs/cargo@v1 288 with: 289 command: deny 290 args: check 291 292 lint-build: 293 name: lint-build 294 runs-on: ubuntu-latest 295 steps: 296 - name: Checkout repository 297 uses: actions/checkout@v2 298 299 - name: Install Rust toolchain 300 uses: actions-rs/toolchain@v1 301 with: 302 toolchain: stable 303 override: true 304 default: true 305 profile: minimal 306 components: clippy 307 308 - name: Handle Rust dependencies caching 309 uses: Swatinem/rust-cache@v2 310 with: 311 key: v1-linux-gnu 312 313 - name: Run linter 314 uses: actions-rs/cargo@v1 315 with: 316 command: clippy 317 args: --workspace 318 319 - name: Build binary 320 uses: actions-rs/cargo@v1 321 with: 322 command: build 323 324 - name: Upload artifact (Ubuntu) 325 uses: actions/upload-artifact@v2 326 with: 327 name: gleam 328 path: target/debug/gleam 329 330 test-projects: 331 name: test-projects 332 needs: lint-build 333 runs-on: ubuntu-latest 334 steps: 335 - name: Checkout repository 336 uses: actions/checkout@v3.0.0 337 338 - name: Install Deno 339 uses: denoland/setup-deno@v1 340 with: 341 deno-version: v1.x 342 343 - name: Install Erlang 344 uses: erlef/setup-beam@v1.15.4 345 with: 346 otp-version: "25.1" 347 elixir-version: "1.14.1" 348 rebar3-version: "3" 349 350 - name: Download Gleam binary from previous job 351 uses: actions/download-artifact@v3 352 with: 353 name: gleam 354 path: ./test 355 356 - name: Configure test projects to use Gleam binary 357 run: | 358 echo $PWD/ >> $GITHUB_PATH 359 chmod +x ./gleam 360 sed -i 's/cargo run --quiet --/gleam/' */Makefile 361 sed -i 's/cargo run --/gleam/' */Makefile 362 working-directory: ./test 363 364 - name: test/language Erlang 365 run: make clean erlang 366 working-directory: ./test/language 367 368 - name: test/language JavaScript with NodeJS 369 run: make clean nodejs 370 working-directory: ./test/language 371 372 - name: test/language Javascript with Deno 373 run: make clean deno 374 working-directory: ./test/language 375 376 - name: test/compile_package0 377 run: make 378 working-directory: ./test/compile_package0 379 380 - name: test/compile_package1 381 run: make 382 working-directory: ./test/compile_package1 383 384 - name: Test JavaScript prelude 385 run: make 386 working-directory: ./test/javascript_prelude 387 388 - name: Test export of hex tarball 389 run: make test 390 working-directory: ./test/hextarball 391 392 - name: Test running modules 393 run: make test 394 working-directory: ./test/running_modules