| 1 | name: Test |
| 2 | |
| 3 | on: |
| 4 | - push |
| 5 | - pull_request |
| 6 | |
| 7 | jobs: |
| 8 | build: |
| 9 | strategy: |
| 10 | matrix: |
| 11 | os: [ubuntu-latest] |
| 12 | rust-version: [1.33.0, stable, nightly] |
| 13 | mode: [native] |
| 14 | include: |
| 15 | - os: macos-latest |
| 16 | rust-version: 1.33.0 |
| 17 | mode: native |
| 18 | - os: windows-latest |
| 19 | rust-version: 1.33.0 |
| 20 | mode: native |
| 21 | - os: ubuntu-latest |
| 22 | rust-version: stable |
| 23 | mode: wasm |
| 24 | runs-on: ${{ matrix.os }} |
| 25 | env: |
| 26 | TARGET: "" |
| 27 | steps: |
| 28 | - uses: actions/checkout@v2 |
| 29 | - name: Set up Rust ${{ matrix.rust-version }} |
| 30 | uses: actions-rs/toolchain@v1 |
| 31 | id: rustup |
| 32 | with: |
| 33 | toolchain: ${{ matrix.rust-version }} |
| 34 | override: true |
| 35 | - name: Cache wasm binaries |
| 36 | if: matrix.mode == 'wasm' |
| 37 | uses: actions/cache@v2 |
| 38 | id: wasm-binaries |
| 39 | with: |
| 40 | path: | |
| 41 | ~/.cargo/bin |
| 42 | ~/.cargo/.crates.toml |
| 43 | ~/.cargo/.crates2.json |
| 44 | key: rust-${{ steps.rustup.outputs.rustc_hash }}-bindgen-0.2.63-pack-0.9.1 |
| 45 | - name: Set up wasm |
| 46 | if: matrix.mode == 'wasm' |
| 47 | run: | |
| 48 | rustup target add wasm32-unknown-unknown |
| 49 | echo "::set-env name=TARGET::--target wasm32-unknown-unknown" |
| 50 | cargo install --version 0.2.63 wasm-bindgen-cli |
| 51 | cargo install --version 0.9.1 wasm-pack |
| 52 | - name: Build |
| 53 | run: cargo build --verbose $TARGET |
| 54 | - name: Disable benchmarking dependencies |
| 55 | if: matrix.mode != 'native' || matrix.rust-version != 'stable' |
| 56 | run: "mv Cargo.toml Cargo.toml.bak && sed '/ # benchmark only$/d' Cargo.toml.bak > Cargo.toml" |
| 57 | - name: Run tests |
| 58 | if: matrix.mode == 'native' |
| 59 | run: cargo test --verbose |
| 60 | - name: Test benchmarks |
| 61 | if: matrix.mode == 'native' && matrix.rust-version == 'stable' |
| 62 | run: cargo test --benches --verbose |
| 63 | - name: Run wasm tests |
| 64 | if: matrix.mode == 'wasm' |
| 65 | run: wasm-pack test --node |
| 66 | - name: Build doc |
| 67 | if: matrix.mode == 'native' |
| 68 | run: cargo doc |