wasm-embedded-hal 0.4.0

WASM embedded-hal implementation
name: Rust HAL tests
on:
  push:
    branches: [ main ]
    tags: [ 'v*' ]
  pull_request:
    branches: [ main ]

env:
  CARGO_TERM_COLOR: always

jobs:
  hal_tests:
    name: Test ${{ matrix.test }}
    runs-on: ubuntu-latest
    continue-on-error: true
    
    strategy:
      matrix:
        test: [ spi, i2c, gpio ]
        runtime: [ wasm3, wasmtime ]

    steps:
    - uses: actions/checkout@v2
    - uses: FranzDiebold/github-env-vars-action@v1.2.1

    # TODO: make this work alongside PRs to the spec and RT.
    # probably move tests for a given spec version to the runtime to simplify this
    - name: Fetch spec
      uses: actions/checkout@v2
      with:
        repository: embedded-wasm/spec
        path: spec

    - name: Fetch (latest) runtime
      run: |
        wget https://github.com/embedded-wasm/rt/releases/latest/download/wasm-embedded-rt-x86_64-unknown-linux-gnu.tgz
        tar -xvf wasm-embedded-rt-x86_64-unknown-linux-gnu.tgz

    - name: Configure toolchain
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly
        target:  wasm32-wasi
        override: true
        components: rustfmt, clippy

    - name: Configure caching
      uses: actions/cache@v2
      with:
        key: hal_rs-${{ matrix.test }}
        path: |
          ~/.cargo
          target
    
    - name: Build ${{matrix.test}} test
      run: |
        cargo build --features=test_${{ matrix.test }}

    - name: Run ${{ matrix.test }} test
      run: |
        ./wasm-embedded-rt --mode mock --runtime ${{ matrix.runtime }} --config spec/tests/${{ matrix.test }}.toml ./target/wasm32-wasi/debug/test-${{ matrix.test }}.wasm