---

name: rust

on:
  pull_request:
    paths:
      - 'Cargo.toml'
      - 'Cargo.lock'
      - '**.rs'
  push:
    branches:
      - main
      - wip/next
    paths:
      - 'Cargo.toml'
      - 'Cargo.lock'
      - '**.rs'

env:
  CARGO_TERM_COLOR: always
  CARGO_TERM_VERBOSE: true

jobs:

  test:
    name: ubuntu-${{ matrix.toolchain }}
    runs-on: ubuntu-latest

    strategy:
      matrix:
        toolchain: [stable, beta, nightly]

    steps:

      - name: checkout
        uses: actions/checkout@v4

      - name: set up rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }}
          components: clippy, rustfmt

      - name: cargo check
        uses: actions-rs/cargo@v1
        with:
          command: check

      - name: cargo clippy
        uses: actions-rs/cargo@v1
        with:
          command: clippy

      - name: check formatting
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: -- --check

      - name: cargo build
        uses: actions-rs/cargo@v1
        with:
          command: build

      - name: cargo test
        uses: actions-rs/cargo@v1
        with:
          command: test

...
