auditmysite 1.2.0

Resource-efficient WCAG 2.1 Accessibility Checker in Rust
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
  RUST_BACKTRACE: 1

jobs:
  check:
    name: Check & Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      - name: Cache cargo registry & build
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      - name: Build (without PDF)
        run: cargo build --no-default-features

      - name: Run clippy
        run: cargo clippy --no-default-features -- -D warnings

      - name: Run tests
        run: cargo test --no-default-features -- --nocapture --test-threads=1

  check-all-features:
    name: Check & Test (all features)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      - name: Cache cargo registry & build
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-all-features-${{ hashFiles('**/Cargo.lock') }}

      - name: Build (all features)
        run: cargo build --all-features

      - name: Run clippy (all features)
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Run tests (all features, PDF smoke excluded)
        run: cargo test --features pdf -- --nocapture --test-threads=1

  pdf-smoke:
    name: PDF Smoke Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry & build
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-pdf-smoke-${{ hashFiles('**/Cargo.lock') }}

      # poppler-utils (pdftoppm/pdftotext) powers the visual smoke checks
      # (#510: blank-page, page-budget, dual-viewport-gauge regression tests)
      # and the pdftotext-based content-traceability tests. Without it these
      # tests silently no-op (`find_executable("pdftoppm")` returns `None`)
      # rather than fail — installing it here is what makes them actually
      # run in CI instead of always being skipped.
      - name: Install poppler-utils (pdftoppm, pdftotext)
        run: sudo apt-get update && sudo apt-get install -y poppler-utils

      - name: Run PDF smoke tests
        run: cargo test --features pdf_test -- --nocapture --test-threads=1

      - name: Upload visual regression debug artifacts on failure
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: pdf-visual-debug
          path: target/pdf-visual-debug/
          if-no-files-found: ignore

  format:
    name: Formatting
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - name: Check formatting
        run: cargo fmt -- --check

  unused-deps:
    name: Unused Dependencies
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Install cargo-machete
        run: cargo install cargo-machete --locked

      - name: Check for unused dependencies
        run: cargo machete

  integration-mocked:
    name: Mocked Integration Tests (no Chrome)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry & build
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-mocked-${{ hashFiles('**/Cargo.lock') }}

      - name: Run mocked integration tests
        run: cargo test --test integration_mocked --no-default-features -- --nocapture

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry & build
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}

      - name: Install cargo-tarpaulin
        run: cargo install cargo-tarpaulin --locked

      - name: Measure coverage (unit tests + mocked integration)
        run: >
          cargo tarpaulin
          --no-default-features
          --tests
          --exclude-files 'src/output/*' 'src/i18n/*'
          --out xml
          --output-dir coverage/

      - name: Upload to Codecov
        uses: codecov/codecov-action@v5
        with:
          files: coverage/cobertura.xml
          fail_ci_if_error: false

  browser-smoke:
    name: Browser Integration Tests (E2E)
    runs-on: ubuntu-latest
    if: github.event_name == 'push' || github.event_name == 'pull_request'
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry & build
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-browser-${{ hashFiles('**/Cargo.lock') }}

      - name: Install Chrome
        id: setup-chrome
        uses: browser-actions/setup-chrome@v2

      - name: Run browser integration tests
        env:
          AUDITMYSITE_BROWSER: ${{ steps.setup-chrome.outputs.chrome-path }}
          CI: "true"
        run: cargo test --test integration_test -- --ignored --nocapture --test-threads=1