From 0040a07156a3425247a2ea988bfe1ca861bd3f1a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 9 Jul 2019 18:03:04 +0200 Subject: [PATCH] Properly run wasm32-unknown-unknown tests on CI --- Cargo.toml | 8 +++++-- azure-pipelines.yml | 14 +++-------- ci/docker/wasm32-unknown-unknown/Dockerfile | 24 +++++++++++++++++++ .../wasm32-unknown-unknown/wasm-entrypoint.sh | 15 ++++++++++++ ci/run-docker.sh | 3 ++- 5 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 ci/docker/wasm32-unknown-unknown/Dockerfile create mode 100755 ci/docker/wasm32-unknown-unknown/wasm-entrypoint.sh diff --git a/Cargo.toml b/Cargo.toml index 3e681785..ba12938c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,12 @@ members = [ "crates/libm-bench", ] +[build-dependencies] +rand = { version = "0.6.5", optional = true } + [dev-dependencies] no-panic = "0.1.8" -[build-dependencies] -rand = { version = "0.6.5", optional = true } +[target.wasm32-unknown-unknown.dev-dependencies] +wasm-bindgen-test = "0.2.47" + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ca17cc9f..934eb839 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,17 +39,9 @@ jobs: TARGET: powerpc64le-unknown-linux-gnu x86_64: TARGET: x86_64-unknown-linux-gnu - - - job: wasm - pool: - vmImage: ubuntu-16.04 - steps: - - template: ci/azure-install-rust.yml - - script: rustup target add wasm32-unknown-unknown - displayName: "Install rust wasm target" - - script: sh ./ci/run.sh wasm32-unknown-unknown - variables: - TOOLCHAIN: nightly + wasm32: + TARGET: wasm32-unknown-unknown + TOOLCHAIN: nightly - job: rustfmt pool: diff --git a/ci/docker/wasm32-unknown-unknown/Dockerfile b/ci/docker/wasm32-unknown-unknown/Dockerfile new file mode 100644 index 00000000..ff8eb284 --- /dev/null +++ b/ci/docker/wasm32-unknown-unknown/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:18.04 + +RUN apt-get update -y && apt-get install -y --no-install-recommends \ + ca-certificates \ + clang \ + cmake \ + curl \ + git \ + libc6-dev \ + make \ + python \ + xz-utils + +# Install `wasm2wat` +RUN git clone --recursive https://github.com/WebAssembly/wabt +RUN make -C wabt -j$(nproc) +ENV PATH=$PATH:/wabt/bin + +# Install `node` +RUN curl https://nodejs.org/dist/v12.0.0/node-v12.0.0-linux-x64.tar.xz | tar xJf - +ENV PATH=$PATH:/node-v12.0.0-linux-x64/bin + +COPY docker/wasm32-unknown-unknown/wasm-entrypoint.sh /wasm-entrypoint.sh +ENTRYPOINT ["/wasm-entrypoint.sh"] diff --git a/ci/docker/wasm32-unknown-unknown/wasm-entrypoint.sh b/ci/docker/wasm32-unknown-unknown/wasm-entrypoint.sh new file mode 100755 index 00000000..89b1d685 --- /dev/null +++ b/ci/docker/wasm32-unknown-unknown/wasm-entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -ex + +# Download an appropriate version of wasm-bindgen based off of what's being used +# in the lock file. Ideally we'd use `wasm-pack` at some point for this! +version=$(grep -A 1 'name = "wasm-bindgen"' Cargo.lock | grep version) +version=$(echo $version | awk '{print $3}' | sed 's/"//g') +curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/$version/wasm-bindgen-$version-x86_64-unknown-linux-musl.tar.gz \ + | tar xzf - -C target +export PATH=$PATH:`pwd`/target/wasm-bindgen-$version-x86_64-unknown-linux-musl +export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner +export NODE_ARGS=--experimental-wasm-simd + +exec "$@" diff --git a/ci/run-docker.sh b/ci/run-docker.sh index e7b80c71..96720626 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -12,7 +12,7 @@ run() { # will be owned by root mkdir -p target - docker build -t $target ci/docker/$target + docker build -t $target -f ci/docker/$target/Dockerfile ci/ docker run \ --rm \ --user $(id -u):$(id -g) \ @@ -24,6 +24,7 @@ run() { -v `rustc --print sysroot`:/rust:ro \ --init \ -w /checkout \ + --privileged \ $target \ sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh $target" }