name: test

on:
  push:
  schedule: # run every month
    - cron: '0 0 1 * *'
  pull_request:
  workflow_dispatch:
    
jobs:
  test_rust:
    name: Test Rust
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rust-src
      - name: Setup WASM
        uses: jetli/wasm-pack-action@v0.4.0
      - name: Test Native & WASM
        run: |
          cargo clippy --verbose --all-targets --features "std alloc rog-experimental" -- -D clippy::all -A deprecated
          cargo test --verbose --features rog-experimental
          cargo test --features alloc --no-default-features --verbose --features rog-experimental
          wasm-pack test --chrome --headless --features alloc --no-default-features --verbose --features rog-experimental
      - name: Setup and check Embedded
        run: |
          rustup target add thumbv7m-none-eabi
          cargo check --target thumbv7m-none-eabi --features alloc --no-default-features --features rog-experimental
          rustup override set nightly
          rustup target add thumbv7m-none-eabi
          cargo check --target thumbv7m-none-eabi --features alloc --no-default-features --features rog-experimental
          sudo apt-get update && sudo apt-get install qemu qemu-system-arm
      - name: Test Embedded (in nightly)
        timeout-minutes: 3
        run: |
          cd tests/embedded
          cargo run
