A comprehensive GitHub Action for Go Quality Gate - a language-agnostic code quality control tool built in Go with Git hooks support.
- ποΈ Zero Dependencies: Single binary with no runtime dependencies
- π§ Automatic Setup: Downloads and installs go-quality-gate automatically
- π Multi-language Support: Works with any programming language
- π Rich Output: Supports both human-readable and JSON output formats
- π Built-in Security: Includes secret scanning capabilities
- β‘ Fast Execution: Native Go performance
- π οΈ Auto-fix: Automatic code formatting and fixes when possible
name: Quality Gate
on: [push, pull_request]
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Quality Gate
uses: dmux/go-quality-gate-action@v1
with:
hook: "pre-commit"name: Quality Gate
on: [push, pull_request]
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Quality Gate with Auto-fix
uses: dmux/go-quality-gate-action@v1
with:
version: "latest"
config-file: ".github/quality.yml"
hook: "pre-commit"
auto-fix: true
json-output: true
fail-on-error: true
install-dependencies: true
working-directory: "."| Input | Description | Default | Required |
|---|---|---|---|
version |
Version of go-quality-gate to use | latest |
No |
config-file |
Path to the quality.yml configuration file | quality.yml |
No |
hook |
Hook to execute (pre-commit, pre-push) | pre-commit |
No |
auto-fix |
Enable automatic fixes when possible | false |
No |
json-output |
Output results in JSON format | true |
No |
fail-on-error |
Fail the action when quality checks fail | true |
No |
install-dependencies |
Automatically install missing quality tools | true |
No |
working-directory |
Working directory to run the quality gate | . |
No |
| Output | Description |
|---|---|
result |
Quality gate execution result (success/failure) |
output |
Quality gate output (JSON format when json-output is true) |
duration |
Total execution time in milliseconds |
Create a quality.yml file in your repository root:
tools:
- name: "Gitleaks"
check_command: "gitleaks version"
install_command: "go install github.com/zricethezav/gitleaks/v8@latest"
- name: "Ruff (Python)"
check_command: "ruff --version"
install_command: "pip install ruff"
- name: "Prettier (JavaScript/TypeScript)"
check_command: "npx prettier --version"
install_command: "npm install --global prettier"
hooks:
security:
pre-commit:
- name: "π Security Check"
command: "gitleaks detect --no-git --source . --verbose"
output_rules:
on_failure_message: "Secret leak detected! Review code before committing."
python-backend:
pre-commit:
- name: "π¨ Format Check (Ruff)"
command: "ruff format ./backend --check"
fix_command: "ruff format ./backend"
output_rules:
show_on: failure
on_failure_message: "Code formatting issues found. Enable auto-fix to resolve."
- name: "π§ͺ Lint Check (Ruff)"
command: "ruff check ./backend"
fix_command: "ruff check ./backend --fix"
typescript-frontend:
pre-commit:
- name: "π¨ Format Check (Prettier)"
command: "npx prettier --check 'frontend/**/*.{ts,tsx,js,jsx}'"
fix_command: "npx prettier --write 'frontend/**/*.{ts,tsx,js,jsx}'"
- name: "π Lint Check (ESLint)"
command: "npx eslint 'frontend/**/*.{ts,tsx,js,jsx}'"
fix_command: "npx eslint 'frontend/**/*.{ts,tsx,js,jsx}' --fix"name: Quality Gate - Multi-Language
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for better analysis
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- name: Install Dependencies
run: |
npm ci
pip install -r requirements.txt
- name: Run Quality Gate
uses: dmux/go-quality-gate-action@v1
with:
config-file: ".github/quality.yml"
hook: "pre-commit"
auto-fix: false
json-output: true
fail-on-error: true
- name: Upload Results
if: always()
uses: actions/upload-artifact@v3
with:
name: quality-gate-results
path: quality-gate-results.jsonname: Quality Gate - Auto Fix
on:
push:
branches: [feature/*, bugfix/*]
jobs:
quality-gate-autofix:
runs-on: ubuntu-latest
permissions:
contents: write # Required for auto-commit
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Quality Gate with Auto-fix
uses: dmux/go-quality-gate-action@v1
with:
hook: "pre-commit"
auto-fix: true
fail-on-error: false # Don't fail, we want to commit fixes
- name: Commit Auto-fixes
if: steps.quality-gate.outputs.result == 'failure'
run: |
git config --local user.email "action@github.com"
git config --local user.name "Quality Gate Action"
if ! git diff --quiet; then
git add .
git commit -m "π€ Auto-fix: Code formatting and linting fixes"
git push
echo "β
Auto-fixes committed and pushed"
else
echo "βΉοΈ No auto-fixes applied"
finame: Quality Gate - Matrix
on: [push, pull_request]
jobs:
quality-gate:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
hook: pre-commit
- os: windows-latest
hook: pre-commit
- os: macos-latest
hook: pre-push
steps:
- uses: actions/checkout@v4
- name: Run Quality Gate
uses: dmux/go-quality-gate-action@v1
with:
hook: ${{ matrix.hook }}
json-output: trueWhen json-output is enabled, you can process the results programmatically:
- name: Run Quality Gate
id: qg
uses: dmux/go-quality-gate-action@v1
with:
json-output: true
fail-on-error: false
- name: Process Results
run: |
echo "Result: ${{ steps.qg.outputs.result }}"
echo "Duration: ${{ steps.qg.outputs.duration }}ms"
# Parse JSON output
echo '${{ steps.qg.outputs.output }}' | jq '.results[] | select(.success == false) | .hook.Name'Sample JSON output:
{
"status": "failure",
"results": [
{
"hook": {
"Name": "π Security Check",
"Command": "gitleaks detect --no-git --source . --verbose"
},
"success": true,
"output": "",
"duration_ms": 150,
"duration": "150ms"
},
{
"hook": {
"Name": "π¨ Format Check (Prettier)",
"Command": "npx prettier --check 'src/**/*.{ts,tsx}'"
},
"success": false,
"output": "Code style issues found in 3 files",
"duration_ms": 890,
"duration": "890ms"
}
]
}Issue: Configuration file not found
# Solution: Specify correct path or let action create default
- uses: dmux/go-quality-gate-action@v1
with:
config-file: ".github/workflows/quality.yml" # Custom pathIssue: Tools not installed
# Solution: Enable automatic installation
- uses: dmux/go-quality-gate-action@v1
with:
install-dependencies: trueIssue: Action fails on formatting issues
# Solution: Enable auto-fix or set fail-on-error to false
- uses: dmux/go-quality-gate-action@v1
with:
auto-fix: true
fail-on-error: falseEnable step debug output:
- name: Run Quality Gate
uses: dmux/go-quality-gate-action@v1
with:
hook: "pre-commit"
env:
ACTIONS_STEP_DEBUG: true- β Linux (x64, ARM64)
- β macOS (Intel, Apple Silicon)
- β Windows (x64)
- go-quality-gate - The main CLI tool
- Quality Gate Documentation - Complete documentation
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.