codeowners-validation 0.4.10

A Rust library for validating CODEOWNERS files.
Documentation
name: CI

on:
  push:
    branches:
      - main
    tags:
      - 'v*'
  pull_request:
    branches:
      - main

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    permissions:
      contents: read
    strategy:
      fail-fast: false
      matrix:
        rust: [stable, beta]
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust ${{ matrix.rust }}
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt, clippy

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.rust }}

      - name: Check formatting
        if: matrix.rust == 'stable'
        run: cargo fmt -- --check

      - name: Clippy
        if: matrix.rust == 'stable'
        run: cargo clippy -- -D warnings

      - name: Build
        run: cargo build --release

      - name: Run tests (excluding integration)
        run: cargo test --release

      # Run integration tests separately with timeout
      - name: Run integration tests
        timeout-minutes: 5
        run: cargo test --release -- --ignored --test-threads=1 --nocapture

  validate-codeowners:
    name: Validate CODEOWNERS
    runs-on: ubuntu-latest
    needs: test
    permissions:
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Validate CODEOWNERS
        uses: ryan-flan/codeowners-validation@main
        with:
          checks: "exists,duplicate_patterns"

  # Release job - only handles GitHub release and Docker image
  release:
    name: Create Release Assets
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
    permissions:
      contents: write
      packages: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Extract version
        id: version
        run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ steps.version.outputs.version }}
          name: Release ${{ steps.version.outputs.version }}
          generate_release_notes: true
          draft: false
          prerelease: false

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            ghcr.io/ryan-flan/codeowners-validation:latest
            ghcr.io/ryan-flan/codeowners-validation:${{ steps.version.outputs.version }}