on:
  pull_request:
  push:
    branches:
      - master

name: CI

# Adapted from recipe: https://github.com/actions-rs/meta/blob/master/recipes/matrix.md#workflow.
jobs:
  ci:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
          - 1.70.0  # MSRV

    steps:
      - uses: actions/checkout@v2

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

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

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

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

      - uses: actions-rs/cargo@v1
        with:
          command: clippy
          # clippy::needless_lifetimes suggest unsound code in this crate
          args: -- -D warnings -A clippy::needless_lifetimes
