name: Rust

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --features std --verbose
    - name: Run tests
      run: cargo test --features std --verbose

  nostd:
    runs-on: ubuntu-latest
    name: build on nostd
    timeout-minutes: 60

    steps:
      - uses: actions/checkout@v2

      - name: Cache Cargo Dependencies
        uses: Swatinem/rust-cache@v1.3.0

      - name: Add thumbv7m Target
        run: rustup target add thumbv7m-none-eabi

      - name: Build with no features
        run: cargo build --verbose --no-default-features --target thumbv7m-none-eabi
