This guide explains the automated quality checks and policy validation integrated into the TRCLI development workflow.
Pre-commit hooks ensure code quality before commits are made, catching issues early in development.
# Install pre-commit
pip install pre-commit
# Install the git hooks
pre-commit install
# Install commit-msg hook for JIRA validation
pre-commit install --hook-type commit-msg
# (Optional) Run hooks on all files
pre-commit run --all-filesThe pre-commit hooks run the following checks automatically:
- Black - Python code formatter (line length: 120)
# Skip all hooks (not recommended)
git commit --no-verify -m "your message"
# Skip specific hook
SKIP=black git commit -m "your message"It's recommended to include an issue reference (JIRA ticket or GitHub issue) in your commit messages for better traceability.
JIRA Tickets:
# Format 1: JIRA key with colon
git commit -m "TRCLI-123: Add new feature for XML parsing"
# Format 2: JIRA key with space
git commit -m "TRCLI-456 Fix bug in API request handler"
# Format 3: JIRA key in brackets
git commit -m "[TRCLI-789] Update documentation"GitHub Issues:
# Format 1: GIT prefix with issue number
git commit -m "GIT-123: Add new feature for XML parsing"
# Format 2: Hash symbol with issue number
git commit -m "#456: Fix bug in API request handler"
# Format 3: Brackets with hash
git commit -m "[#789] Update documentation"- Merge commits:
Merge branch 'feature/xyz' into main - Release commits:
Release v1.2.3 - Version bumps:
Bump version to 1.2.3 - Reverts:
Revert "TRCLI-123: Add feature"orRevert "#123: Add feature"
- Traceability: Links code changes to requirements/bugs
- Project Management: Enables automatic issue tracking and updates
- Release Notes: Simplifies changelog generation
- Code Review: Provides context for reviewers
- Documentation: Easy to find all commits related to a specific issue
# Feature branch
git checkout -b feature/TRCLI-123-add-xml-parser
# Bug fix branch
git checkout -b fix/TRCLI-456-api-timeout
# Documentation
git checkout -b docs/TRCLI-789-update-readmeIt's recommended to use Conventional Commits format for clarity:
type(scope): description
Valid Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, no logic change)refactor: Code refactoring (no feature change)perf: Performance improvementstest: Adding or updating testsbuild: Build system changesci: CI/CD pipeline changeschore: Maintenance tasks
Examples:
feat(parser): add support for JUnit XML format
fix(api): handle timeout errors gracefully
docs(readme): update installation instructions
refactor(cli): simplify argument parsing logic
test(parser): add edge case tests for empty files
The PR template includes required sections:
- Issue reference (GitHub or JIRA)
- Solution description
- Changes made
- Test steps
- Checklist items
All checklist items must be completed before requesting review.
When you open a PR, the following checks run automatically:
- Checks for issue reference (JIRA or GitHub)
- Ensures PR description is complete
- Verifies all checklist items are checked
- Ensures required sections are filled
- Adds/removes labels based on completion
Runs on every PR and push to main:
- Tests on Python 3.10, 3.11, 3.12, 3.13
- Tests on Ubuntu and Windows
- Code coverage must be ≥ 80%
- All tests must pass
Checks:
- Issue reference (JIRA ticket or GitHub issue)
- PR description completeness
Validates:
- All checklist items are completed
- Required sections have content
- Issue reference exists
- Test steps provided
Labels:
ready-for-review: All checks passedincomplete-pr: Missing required items
Problem: Code formatting doesn't match Black style.
Solution:
# Let Black fix it automatically
pre-commit run black --all-files
# Then commit again
git add .
git commit -m "Your commit message"Problem: No issue reference in PR title or description.
Solution: Add issue reference:
JIRA ticket:
- In PR title:
feat(api): TRCLI-123 Add endpoint - In PR body: Link to JIRA or mention
TRCLI-123
GitHub issue:
- In PR title:
feat(api): GIT-456 Add endpointorfeat(api): #789 Add endpoint - In PR body:
Fixes #123orResolves GIT-456or link to GitHub issue
Problem: Not all checklist items are checked.
Solution: Complete all items or remove non-applicable ones.
- Make small, logical commits
- Each commit should have a single purpose
- Write descriptive commit messages
# Test your changes locally first
pre-commit run --all-files
pytest tests/- Aim for <400 lines changed per PR
- Break large features into multiple PRs
- Easier to review and less likely to introduce bugs
- Maintain ≥80% code coverage
- Test edge cases
- Include integration tests where applicable
pre-commit install # Initial setup
pre-commit install --hook-type commit-msg
pre-commit run --all-files # Run on all files
pre-commit run <hook-id> # Run specific hook
SKIP=<hook-id> git commit # Skip specific hook# Using JIRA ticket
git checkout -b feature/TRCLI-123-description
git add .
git commit -m "TRCLI-123: Description"
git push origin feature/TRCLI-123-description
# Using GitHub issue
git checkout -b feature/GIT-456-description
git add .
git commit -m "GIT-456: Description"
# or
git commit -m "#456: Description"
git push origin feature/GIT-456-description
# Open PR with semantic titlepytest tests/ # Run all tests
pytest tests/test_xyz.py # Run specific test
pytest --cov=trcli --cov-report=html # Coverage report- Pre-commit issues: Check
.pre-commit-config.yamlconfiguration - PR workflow issues: Review
.github/workflows/files - General questions: Open an issue or ask in team chat
Happy coding! 🚀