name: CI

on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  ci-rs:
    name: Rust · CI
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v6

      - uses: extractions/setup-just@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt,clippy

      - uses: Swatinem/rust-cache@v2

      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-audit

      - run: just install-rs

      - run: just lint-rs

      - run: just audit-rs

      - run: just test-rs

      - run: just build-rs

  ci-next:
    name: Next · CI
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v6

      - uses: extractions/setup-just@v4

      - uses: pnpm/action-setup@v6
        with:
          package_json_file: site/package.json

      - uses: actions/setup-node@v6
        with:
          node-version: 22
          cache: pnpm
          cache-dependency-path: site/pnpm-lock.yaml

      - run: just install-next

      - run: just lint-next

      - run: just audit-next

      - run: just test-next

      - run: just build-next
