lineguard 0.1.7

A fast and reliable file linter that ensures proper line endings and clean formatting
Documentation
name: CI

on:
  push:
    branches: [ master ]
    paths:
      - 'src/**'
      - 'Cargo.*'
      - '.github/workflows/ci.yml'
  pull_request:
    branches: [ master ]
    paths:
      - 'src/**'
      - 'Cargo.*'
      - '.github/workflows/ci.yml'
  workflow_dispatch:

# Cancel old runs when pushing new commits to a PR
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Quick tests that run on every OS
  quick-test:
    name: Quick Tests - ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    # Skip duplicate runs when PR is merged
    if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')
    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    steps:
    - name: Checkout repository
      uses: actions/checkout@v6

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

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

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

    - name: Build
      run: cargo build --verbose

    - name: Run unit tests
      run: cargo test --lib --verbose

    - name: Run doctests
      run: cargo test --doc --verbose

  # Full test suite - only runs on Linux for faster CI
  full-test:
    name: Full Test Suite
    runs-on: ubuntu-latest
    needs: quick-test
    # Skip duplicate runs when PR is merged
    if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')

    steps:
    - name: Checkout repository
      uses: actions/checkout@v6

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

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

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

    - name: Run all tests
      run: cargo test --all --verbose

    - name: Run tests with all features
      run: cargo test --all-features --verbose

  quality:
    name: Code Quality
    runs-on: ubuntu-latest
    needs: quick-test
    # Skip duplicate runs when PR is merged
    if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')

    steps:
    - name: Checkout repository
      uses: actions/checkout@v6

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

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

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

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

    - name: Build documentation
      run: cargo doc --no-deps --document-private-items
      env:
        RUSTDOCFLAGS: -D warnings

  security:
    name: Security Audit
    runs-on: ubuntu-latest
    needs: quick-test
    # Skip duplicate runs when PR is merged
    if: github.event_name != 'push' || !contains(github.event.head_commit.message, 'Merge pull request')

    steps:
    - name: Checkout repository
      uses: actions/checkout@v6

    - name: Cache cargo-audit
      id: cache-cargo-audit
      uses: actions/cache@v5
      with:
        path: ~/.cargo/bin/cargo-audit
        key: cargo-audit-${{ runner.os }}-v1

    - name: Install cargo-audit
      if: steps.cache-cargo-audit.outputs.cache-hit != 'true'
      run: cargo install cargo-audit

    - name: Run security audit
      run: cargo audit