The GitHub Actions Best Practices Linter
Project description
Ghanon
Ghanon(dorf) - A strict GitHub Actions workflow linter that validates your workflows against best practices.
🎯 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
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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following our conventions
- Ensure all tests pass (
task test) - Commit using Conventional Commits
- 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
- Built with Pydantic for robust validation
- Schema based on SchemaStore's GitHub Workflow Schema
- Inspired by the need for better GitHub Actions workflow validation
📞 Support
If you encounter any issues or have questions:
Made with ❤️ by Niko Heikkilä
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0424e1958214f7941bf0908608d0130137a9689fd56bf1abc201413f1224dffd
|
|
| MD5 |
8cfcdb89491cd887484c0927df727357
|
|
| BLAKE2b-256 |
fb114b4a1092b61c9ce638c73c31961236b8b8285c470acc2a1348d55d8a0e05
|
Provenance
The following attestation bundles were made for ghanon-0.2.1.tar.gz:
Publisher:
release.yml on nikoheikkila/ghanon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghanon-0.2.1.tar.gz -
Subject digest:
0424e1958214f7941bf0908608d0130137a9689fd56bf1abc201413f1224dffd - Sigstore transparency entry: 741608810
- Sigstore integration time:
-
Permalink:
nikoheikkila/ghanon@33ead07dd75e55587acaa7d972b7f9066d04536f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nikoheikkila
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@33ead07dd75e55587acaa7d972b7f9066d04536f -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12616e21e187832746d78b0390bf49e46b2c88b6ba03771e20ef0061008a4e05
|
|
| MD5 |
b827d02d8095a7a8a136de08af063edd
|
|
| BLAKE2b-256 |
19c72b6740d3e063f658d956131b42fe41cd3002c5ea9964000a64f00a44b70f
|
Provenance
The following attestation bundles were made for ghanon-0.2.1-py3-none-any.whl:
Publisher:
release.yml on nikoheikkila/ghanon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghanon-0.2.1-py3-none-any.whl -
Subject digest:
12616e21e187832746d78b0390bf49e46b2c88b6ba03771e20ef0061008a4e05 - Sigstore transparency entry: 741608816
- Sigstore integration time:
-
Permalink:
nikoheikkila/ghanon@33ead07dd75e55587acaa7d972b7f9066d04536f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nikoheikkila
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@33ead07dd75e55587acaa7d972b7f9066d04536f -
Trigger Event:
push
-
Statement type: