From 32fc5b2ed664cbb1ad3776b330341a4cae45031d Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Mon, 4 Jan 2021 19:07:44 -0800 Subject: [PATCH 1/2] Add emscripten tests --- .cargo/config | 4 ++++ .github/workflows/tests.yml | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.cargo/config b/.cargo/config index 0c06f2ad..be3061ab 100644 --- a/.cargo/config +++ b/.cargo/config @@ -3,3 +3,7 @@ runner = 'wasm-bindgen-test-runner' [target.wasm32-wasi] runner = 'wasmtime' + +# Just run on node by default (that's where emscripten is tested) +[target.'cfg(target_os = "emscripten")'] +runner = 'node' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 028b7822..8ea8452b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,6 +11,7 @@ on: env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-Dwarnings" + EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11 jobs: check-doc: @@ -125,7 +126,6 @@ jobs: override: true - run: cargo test --features=std - # TODO: Add emscripten when it's working with Cross cross-tests: name: Cross Test runs-on: ubuntu-latest @@ -224,6 +224,38 @@ jobs: mv /tmp/wasmtime ~/.cargo/bin - run: cargo test --target wasm32-wasi + emscripten-tests: + name: Emscripten tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + - run: rustup target add wasm32-unknown-emscripten + - run: rustup target add asmjs-unknown-emscripten + - name: Cache emsdk + id: cache-emsdk + uses: actions/cache@v2 + with: + path: ~/emsdk + key: ${{ runner.os }}-${{ env.EMSDK_VERSION }}-emsdk + - name: Install emsdk + if: steps.cache-emsdk.outputs.cache-hit != 'true' + run: | + git clone https://github.com/emscripten-core/emsdk.git ~/emsdk + cd ~/emsdk + ./emsdk install $EMSDK_VERSION + ./emsdk activate $EMSDK_VERSION + - run: echo "$HOME/emsdk/upstream/emscripten" >> $GITHUB_PATH + - name: wasm test + run: cargo test --target=wasm32-unknown-emscripten --features=std + - name: asm.js test + run: | # Debug info breaks on asm.js + RUSTFLAGS="$RUSTFLAGS -C debuginfo=0" + cargo test --target=asmjs-unknown-emscripten --features=std + build: name: Build only runs-on: ubuntu-latest From e8f1c3690e2e75b27b37379aac451f87a00953a3 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Tue, 5 Jan 2021 01:05:46 -0800 Subject: [PATCH 2/2] Move EMSDK_VERSION --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8ea8452b..24dd9424 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,6 @@ on: env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-Dwarnings" - EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11 jobs: check-doc: @@ -227,6 +226,8 @@ jobs: emscripten-tests: name: Emscripten tests runs-on: ubuntu-latest + env: + EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11 steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1