Git Hooks Integration¶
Release Agent can be used as a git pre-push hook to automatically validate code before pushing.
Setup Options¶
Option 1: Simple Script¶
Create .git/hooks/pre-push manually:
cat > .git/hooks/pre-push << 'EOF'
#!/bin/bash
exec atrelease check
EOF
chmod +x .git/hooks/pre-push
Option 2: Symlink¶
Create a symlink to the Release Agent binary:
Note: This runs atrelease with no arguments, which defaults to check.
Option 3: Shared Hooks Directory¶
For team-wide hooks, use a shared hooks directory:
# Create shared hooks directory
mkdir -p .githooks
# Create the hook
cat > .githooks/pre-push << 'EOF'
#!/bin/bash
exec atrelease check
EOF
chmod +x .githooks/pre-push
# Configure git to use shared hooks
git config core.hooksPath .githooks
Commit .githooks/ to your repository so all team members use the same hooks.
Hook Behavior¶
When the pre-push hook runs:
- Release Agent detects languages in your repository
- Runs all enabled checks for each language
- Exits with code 0 (success) if all hard checks pass
- Exits with code 1 (failure) if any hard check fails
Warnings Don't Block¶
Soft warnings (like untracked references) don't block the push:
=== Summary ===
✓ Go: build
✓ Go: tests
⚠ Go: untracked references (warning)
Passed: 6, Failed: 0, Skipped: 0, Warnings: 1
Pre-push checks passed with warnings.
Bypassing the Hook¶
To push without running checks (use sparingly):
Or:
Customizing the Hook¶
Skip Certain Checks¶
Verbose Output¶
Different Config for Hooks¶
#!/bin/bash
# Use hook-specific config
RELEASEAGENT_CONFIG=.releaseagent.hooks.yaml exec atrelease check
CI Integration¶
For complete coverage, run Release Agent in both:
- Pre-push hook - Fast feedback during development
- CI pipeline - Comprehensive checks with full test suite
GitHub Actions Example¶
name: Release Agent Checks
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Install Release Agent
run: go install github.com/agentplexus/agent-team-release/cmd/atrelease@latest
- name: Run checks
run: atrelease check
Troubleshooting¶
Hook Not Running¶
Check that the hook is executable:
Wrong Directory¶
The hook runs in the repository root. Use absolute paths if needed:
Release Agent Not Found¶
Ensure Release Agent is in your PATH:
Slow Hooks¶
For faster feedback, skip time-consuming checks:
Team Guidelines¶
Recommended Setup¶
- Use shared hooks directory (Option 3)
- Commit
.githooks/to repository - Document in README how to enable:
When to Bypass¶
Only bypass hooks (--no-verify) when:
- Pushing work-in-progress to a feature branch
- CI will catch any issues
- You understand the risks
Never bypass when pushing to main or release branches.