Skip to content

Commit

Permalink
Build and test wasm on MacOS in CI
Browse files Browse the repository at this point in the history
The default clang installation provided in MacOS does not work. We fixed
 this locally by installing clang via llvm through brew and setting the
 CC and AR env variables to point at the new clang installation.The CI
 MacOS image seems to already have llvm installed so we did not need to
 install llvm on the CI.

See rust-bitcoin/rust-secp256k1#254 for more
details
  • Loading branch information
rishflab committed Jul 20, 2021
1 parent 5e21a5f commit 7c46f07
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,29 @@ jobs:
DO_BENCH: true
run: ./contrib/test.sh

wasm_pack:
wasm:
name: Stable - Docs / WebAssembly Build
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
target: [ x86_64-unknown-linux-gnu, x86_64-apple-darwin ]
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cc: clang-9
ar: ar
- target: x86_64-apple-darwin
os: macos-latest
cc: /usr/local/opt/llvm/bin/clang
ar: /usr/local/opt/llvm/bin/llvm-ar
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Crate
uses: actions/checkout@v2
- name: Checkout Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: stable
override: true
- name: Building docs
env:
Expand All @@ -54,18 +62,10 @@ jobs:
- name: Running WASM build
env:
DO_WASM: true
CC: ${{ matrix.cc }}
AR: ${{ matrix.ar }}
run: ./contrib/test.sh

build_wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
- run: cargo build --target wasm32-unknown-unknown --features global-context,use-serde,use-rand

Tests:
name: Tests
strategy:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ bitcoin_hashes = "0.9"
[target.wasm32-unknown-unknown.dev-dependencies]
wasm-bindgen-test = "0.3"
rand = { version = "0.6", features = ["wasm-bindgen"] }

[lib]
crate-type = ["cdylib", "rlib"]
4 changes: 2 additions & 2 deletions contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fi
# Webassembly stuff
if [ "$DO_WASM" = true ]; then
clang --version &&
CC=clang-9 wasm-pack build &&
CC=clang-9 wasm-pack test --node;
wasm-pack build &&
wasm-pack test --node;
fi

# Address Sanitizer
Expand Down

0 comments on commit 7c46f07

Please sign in to comment.