on:
  pull_request:
  push:
    branches:
      - master

name: Rust

jobs:
  ci:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: rustfmt, clippy

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

      - uses: actions-rs/install@v0.1
        with:
          crate: cargo-hack
          version: latest
          use-tool-cache: true

      - uses: actions-rs/cargo@v1
        with:
          command: hack
          args: check --workspace --ignore-private --each-feature --no-dev-deps

      - uses: actions-rs/cargo@v1
        with:
          command: check
          args: --workspace --all-targets --all-features

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

      - uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features

      - uses: actions-rs/audit-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
