name: Check stable

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

env:
  CARGO_TERM_COLOR: always
  CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse

jobs:
  test:
    name: Check examples ${{ matrix.os }} (using rustc ${{ matrix.rust }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        rust:
          - stable
        os:
          - ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.rust }}
          override: true
          components: rustfmt

      - name: Add wasm32-unknown-unknown
        run: rustup target add wasm32-unknown-unknown

      - name: Setup cargo-make
        uses: davidB/rust-cargo-make@v1

      - name: Cargo generate-lockfile
        run: cargo generate-lockfile

      - uses: Swatinem/rust-cache@v2

      - name: Run cargo check on all examples
        run: cargo make --profile=github-actions check-stable
