Skip to content

Commit

Permalink
Properly run wasm32-unknown-unknown tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Jul 9, 2019
1 parent b82bba2 commit 0040a07
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

14 changes: 3 additions & 11 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions ci/docker/wasm32-unknown-unknown/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions ci/docker/wasm32-unknown-unknown/wasm-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
3 changes: 2 additions & 1 deletion ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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"
}
Expand Down

0 comments on commit 0040a07

Please sign in to comment.