# A few guiding principles.
# 
# * Always use actions-rust-lang/setup-rust-toolchain for its built-in caching.
# * Complexity lives in the justfile, this runner is as light as possible.
 
name: CI

# Run on direct commits to master, including merges, and any pull requests against master.
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  # Quick canary of code as well as potential issues with upcoming toolchains.
  check:
    strategy:
      matrix:
        toolchain: [stable, beta, nightly]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: extractions/setup-just@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: ${{ matrix.toolchain }}
          components: clippy,rustfmt
      - run: just check
  # Build and test the code across platforms.
  test:
    strategy:
      matrix:
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v4
      - uses: extractions/setup-just@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: just test unit
  features:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: extractions/setup-just@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: just test features
  msrv:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: extractions/setup-just@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: just test msrv
  integration:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: extractions/setup-just@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: just test integration
  min-versions:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: extractions/setup-just@v3
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: nightly
      - run: just test min-versions
