codeowners-validation 0.4.10

A Rust library for validating CODEOWNERS files.
Documentation

CODEOWNERS Validation

Crates.io GitHub Workflow Status License: MIT GitHub release (latest by date)

A high-performance CODEOWNERS validator optimized for large repositories and monorepos. Written in Rust for maximum performance and minimal memory usage.

Features

✅ Active Checks

  • File/Directory Existence: Validates that all paths in CODEOWNERS exist in the repository
  • Duplicate Pattern Detection: Identifies duplicate ownership patterns

🚧 Planned Features

  • Validate file ownership coverage (detect unowned files)
  • Verify GitHub owners exist and have repository access
  • Comprehensive syntax validation
  • Custom check configurations

Performance

Optimized for large CODEOWNERS files:

  • Handles 10,000+ rules efficiently
  • Minimal memory footprint
  • Parallel file system traversal
  • Early exit optimization for better performance

Installation

As a GitHub Action

Add to your workflow (.github/workflows/codeowners-validation.yml):

name: CODEOWNERS Validation

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

jobs:
  validate-codeowners:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run CODEOWNERS Validation
        uses: ryan-flan/codeowners-validation@latest  # Use latest version
        with:
          checks: |
            exists
            duplicate_patterns

As a CLI Tool (Coming Soon)

# Install via cargo
cargo install codeowners-validation

# Run validation
codeowners-validation --path .github/CODEOWNERS

Configuration

Action Inputs

Input Description Default Required
checks Comma-separated list of checks to run all No
path Path to CODEOWNERS file .github/CODEOWNERS No

Available Checks

  • exists - Validate all referenced files/directories exist
  • duplicate_patterns - Find duplicate ownership patterns
  • all - Run all available checks (default)

Action Outputs

Output Description
result Validation result: success or failure
errors Detailed error messages (if any)

Usage Examples

Basic Validation

- uses: ryan-flan/codeowners-validation@v0.4.4

Specific Checks Only

- uses: ryan-flan/codeowners-validation@v0.4.4
  with:
    checks: exists

Custom CODEOWNERS Location

- uses: ryan-flan/codeowners-validation@v0.4.4
  with:
    path: docs/CODEOWNERS
    checks: exists,duplicate_patterns

Development

Prerequisites

  • Rust 1.70+
  • Cargo

Building

# Clone the repository
git clone https://github.com/ryan-flan/codeowners-validation
cd codeowners-validation

# Build release version
cargo build --release

# Run tests
cargo test

# Run benchmarks
cargo bench

Performance Testing

The project includes comprehensive benchmarks for large CODEOWNERS files:

# Run all benchmarks
cargo bench

# Run specific benchmark
cargo bench --bench benchmark 10k_rules

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Areas for Contribution

  1. Additional validation checks
  2. Performance optimizations
  3. Better error messages
  4. Documentation improvements
  5. Test coverage

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by the need for fast CODEOWNERS validation in large monorepos
  • Built with Rust for performance
  • Uses globset for efficient pattern matching

See Also