api-version 0.3.5

Axum middleware to add a version prefix to request paths based on a set of versions and an optional `x-api-version` header
Documentation
name: CI

permissions:
  contents: read

on:
  pull_request:
    branches:
      - main
  workflow_dispatch:

concurrency:
  group: ${{github.workflow}}-${{github.head_ref || github.run_id}}
  cancel-in-progress: true

jobs:
  toolchain:
    name: Setup Rust toolchain
    runs-on: ubuntu-latest
    outputs:
      toolchain: ${{steps.set_toolchain.outputs.toolchain}}
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Output toolchain
        id: set_toolchain
        env:
          toolchain_toml: "rust-toolchain.toml"
        run: |
          toolchain=$(grep channel rust-toolchain.toml | sed -r 's/channel = "(.*)"/\1/')
          echo "toolchain=$toolchain" | tee -a "$GITHUB_OUTPUT"

  fmt-check:
    name: Check Code Format
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install Rust
        uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
        with:
          toolchain: nightly-2025-12-08
          components: rustfmt

      - name: Install just
        uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2.69.9
        with:
          tool: just

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1

      - name: just fmt-check
        run: |
          just fmt-check

  lint:
    runs-on: ubuntu-latest
    name: Lint Code
    needs: toolchain
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install Rust
        uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
        with:
          toolchain: ${{needs.toolchain.outputs.toolchain}}
          components: clippy

      - name: Install just
        uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2.69.9
        with:
          tool: just

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1

      - name: just lint
        run: |
          rustup override set ${{needs.toolchain.outputs.toolchain}}
          just lint

  test:
    runs-on: ubuntu-latest
    name: Run Tests
    needs: toolchain
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install Rust
        uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
        with:
          toolchain: ${{needs.toolchain.outputs.toolchain}}

      - name: Install just
        uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2.69.9
        with:
          tool: just

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1

      - name: just test
        run: |
          rustup override set ${{needs.toolchain.outputs.toolchain}}
          just test

  doc:
    runs-on: ubuntu-latest
    name: Create Documentation
    needs: toolchain
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install Rust
        uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
        with:
          toolchain: ${{needs.toolchain.outputs.toolchain}}
          components: rust-docs

      - name: Install just
        uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2.69.9
        with:
          tool: just

      - name: Setup Rust cache
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1

      - name: just doc
        run: |
          just doc