Skip to main content

The GitHub Actions Best Practices Linter

Project description

Ghanon

Ghanon(dorf) - A strict GitHub Actions workflow linter that validates your workflows against best practices.

PyPI version Python Version License: MIT Test Coverage Code style: ruff

🎯 What is Ghanon?

Ghanon is a powerful linter for GitHub Actions workflows that goes beyond basic YAML validation. It validates your .github/workflows/*.yml files against the official GitHub Actions schema using Pydantic models and enforces best practices with custom validation rules.

Key Features

  • 📋 Complete Schema Validation: Validates against the full GitHub Actions Workflow Schema
  • 🎯 Precise Error Reporting: Shows exact line numbers where validation errors occur
  • ✨ Best Practices Enforcement: Custom validators that catch common anti-patterns and security issues
  • 🔒 Security-First: Enforces principle of least privilege for secrets and permissions
  • 🚀 CI/CD Ready: Easy to integrate into your continuous integration pipelines
  • 💯 Type-Safe: Built with Pydantic for robust validation

Best Practices Enforced

  • ❌ Discourages secrets: inherit (principle of least privilege)
  • 🔍 Validates job IDs, step configurations, and runner specifications
  • 🛡️ Checks permissions, concurrency settings, and environment configurations

📦 Installation

Ghanon requires Python 3.14 or higher.

Using pip

pip install ghanon

Using pipx (recommended for CLI tools)

pipx install ghanon

Using uv

uv tool install ghanon

🚀 Usage

Command Line

Validate a single workflow file:

ghanon path/to/workflow.yml

Validate all workflows in your repository:

ghanon .github/workflows/*.yml

In CI/CD Pipelines

Add Ghanon to your GitHub Actions workflow:

name: Validate Workflows

on:
  pull_request:
    paths:
      - '.github/workflows/**'
  push:
    branches:
      - main

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.14'
      
      - name: Install Ghanon
        run: pip install ghanon
      
      - name: Validate workflows
        run: ghanon .github/workflows/*.yml

📖 Example Output

When Ghanon finds issues in your workflow:

❌ Validation failed for workflow.yml

Error at line 15 (jobs.build.secrets):
  Do not use `secrets: inherit`. Define secrets explicitly for principle of least privilege.

🛠️ Development

Prerequisites

  • Python 3.14+
  • Task (task runner)
  • uv (package manager)

Setup

# Clone the repository
git clone https://github.com/nikoheikkila/ghanon.git
cd ghanon

# Install dependencies
task install

# Run the linter
uv tool install .
ghanon path/to/workflow.yml

Testing

Ghanon maintains 100% test coverage:

# Run full test suite (format, lint, test)
task test

# Run only unit tests
task test:unit

# Watch mode for TDD
task test:watch

Code Quality

# Lint code
task lint

# Format code
task format

🤝 Contributing

Contributions are welcome! Please read our Contributing Guidelines and Code of Conduct before submitting pull requests.

Quick Start for Contributors

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following our conventions
  4. Ensure all tests pass (task test)
  5. Commit using Conventional Commits
  6. Push to your fork and submit a pull request

📄 License

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

🙏 Acknowledgments

📞 Support

If you encounter any issues or have questions:


Made with ❤️ by Niko Heikkilä

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghanon-0.2.1.tar.gz (86.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ghanon-0.2.1-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file ghanon-0.2.1.tar.gz.

File metadata

  • Download URL: ghanon-0.2.1.tar.gz
  • Upload date:
  • Size: 86.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghanon-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0424e1958214f7941bf0908608d0130137a9689fd56bf1abc201413f1224dffd
MD5 8cfcdb89491cd887484c0927df727357
BLAKE2b-256 fb114b4a1092b61c9ce638c73c31961236b8b8285c470acc2a1348d55d8a0e05

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghanon-0.2.1.tar.gz:

Publisher: release.yml on nikoheikkila/ghanon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghanon-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ghanon-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 33.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghanon-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12616e21e187832746d78b0390bf49e46b2c88b6ba03771e20ef0061008a4e05
MD5 b827d02d8095a7a8a136de08af063edd
BLAKE2b-256 19c72b6740d3e063f658d956131b42fe41cd3002c5ea9964000a64f00a44b70f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghanon-0.2.1-py3-none-any.whl:

Publisher: release.yml on nikoheikkila/ghanon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page