rustversion-msrv 0.100.1

Conditional compilation according manifest MSRV
Documentation
name: CI

on:
  pull_request:
  merge_group: { types: [checks_requested] }
  push: { branches: [main] }
  schedule: [cron: "40 1 */2 * *"]

permissions:
  contents: read

jobs:
  read_msrv:
    name: Read MSRV
    uses: actions-rust-lang/msrv/.github/workflows/msrv.yml@b95a3a81b0efee6438b858b41a84aff627e01351 # v0.1.1

  test:
    name: Test Rust (${{ matrix.rust.name }})

    needs: read_msrv
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        # prettier-ignore
        rust:
          - { name: nightly, toolchain: nightly, expect_failure: true }
          - { name: beta, toolchain: beta, expect_failure: true }
          - { name: stable, toolchain: stable, expect_failure: true }
          - { name: msrv, toolchain: "${{ needs.read_msrv.outputs.msrv }}", expect_failure: false }

    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Install Rust (${{ matrix.rust.toolchain }})
        uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2.0.0
        with:
          toolchain: ${{ matrix.rust.toolchain }}

      - name: Enable type layout randomization
        run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV
        if: matrix.rust.toolchain == 'nightly'

      - name: Test
        shell: bash
        env:
          EXPECT_FAILURE: ${{ matrix.rust.expect_failure }}
        run: |
          set +e

          cargo --locked test --test=msrv

          xc="$?"
          echo "exit code = $xc"

          if [[ "$EXPECT_FAILURE" == "true" ]]; then
            if [[ "$xc" == "0" ]]; then
              echo "Expected failure, got exit code = $xc"
              exit 1
            fi
          else
            if [[ "$xc" != "0" ]]; then
              echo "Expected success, got exit code = $xc"
              exit 1
            fi
          fi

  doc:
    name: Documentation
    runs-on: ubuntu-latest
    timeout-minutes: 45
    env:
      RUSTDOCFLAGS: -Dwarnings
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Install Rust (nightly)
        uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2.0.0
        with:
          toolchain: nightly

      - uses: dtolnay/install@982daea0f5d846abc3c83e01a6a1d73c040047c1 # cargo-docs-rs

      - run: cargo docs-rs

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Install Rust (stable)
        uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2.0.0
        with:
          components: clippy

      - run: cargo --locked clippy --tests -- -Dclippy::todo

  zizmor:
    name: GitHub Actions Security
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
        with:
          advanced-security: false
          annotations: true