Repository navigation
Description
Parent Epic: #112 - Refactor and Improve E2E Test Execution
Depends On: #120 - Configure GitHub Copilot Agent Environment (Issue 1-4)
Overview
Install Git pre-commit hooks in the Copilot agent's environment to enforce pre-commit checks deterministically. This ensures the agent cannot commit code without running linting checks, even if the agent forgets or ignores the instruction in .github/copilot-instructions.md.
Problem
Previous attempts to instruct the Copilot agent to run pre-commit checks via .github/copilot-instructions.md were not reliable. The agent sometimes:
- Forgot to run checks before committing
- Ignored the instructions
- Committed code that failed linting
Solution: Use Git hooks to enforce checks mechanistically, not instructionally.
Objectives
- Create symlink from
.git/hooks/pre-committo./scripts/pre-commit.sh - Install hook in Copilot setup workflow
- Verify hook works correctly (blocks bad commits)
- Document the hook installation process
Implementation Approach
Use Symlink (NOT Wrapper Script):
ln -sf ../../scripts/pre-commit.sh .git/hooks/pre-commitWhy Symlink:
- ✅ Simple - no wrapper script needed
- ✅ Always up-to-date - changes to script are immediately reflected
- ✅ Single source of truth -
./scripts/pre-commit.sh - ✅ Easy to verify -
readlink .git/hooks/pre-commit
Workflow Integration
Add to .github/workflows/copilot-setup-steps.yml:
- name: Install Git pre-commit hooks
run: |
# Create symlink to enforce pre-commit checks
ln -sf ../../scripts/pre-commit.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# Verify hook is installed
if [ -L .git/hooks/pre-commit ]; then
echo "✅ Pre-commit hook installed successfully"
readlink .git/hooks/pre-commit
else
echo "❌ Failed to install pre-commit hook"
exit 1
fiAcceptance Criteria
- Pre-commit checks pass
- Hook installation added to Copilot setup workflow
- Hook successfully blocks commits that fail checks
- Hook is verified during workflow execution
- Documentation updated
Time Estimate
2-3 hours
Related Documentation
- Full specification: docs/issues/121-1-5-install-git-precommit-hooks-for-copilot.md
- Removed Integration Test Commit: e9955b0
Reacted by Copilot
Activity
docs: add GitHub issues for E2E test refactoring EPIC
Merge #150: Split E2E tests in pre-commit script for GitHub Actions c…
feat: [#121] add git pre-commit hook installation script and workflow…
Merge #153: Install Git pre-commit hooks to enforce checks in Copilot…
chore: remove closed issue documentation files
josecelano commentedon Nov 6, 2025
This is not working. The pre-commit checks script takes longer than Copilot waits for a bash command, and it continues; then it realises the commit was not done, tries again, and so on until we reach the whole agent timeout for a task.
I think there is a way to increase timeouts. I will try to find that in the Copilot agent docs.
In my machine pre-commit checks take ~6 minutes:
josecelano commentedon Nov 6, 2025
Update: Root Cause Identified
I've identified the root cause of the infinite loop issue with GitHub Copilot agent and pre-commit checks.
The Problem:
GitHub Copilot coding agent has a hardcoded ~5-6 minute timeout for command execution during the coding phase. When our pre-commit script (which takes ~6 minutes) exceeds this timeout, Copilot assumes the commit failed and retries, creating an infinite loop.
Discussion:
https://github.com/orgs/community/discussions/178998
Key Findings:
timeout-minutessetting in.github/workflows/copilot-setup-steps.ymlonly applies to the setup phaseTemporary Solution:
We will implement an environment variable-based approach to skip E2E tests when Copilot agent is running, while keeping the full pre-commit verification for local development.
feat: [#121] skip slow tests for Copilot agent with enhanced messaging
docs: [#121] add comprehensive environment variable naming guide