Skip to main content

Automated Quality Gates

TrendGate's automated quality gates prevent code with quality regressions from being merged, maintaining high standards across your codebase.

🚦 How Quality Gates Work

GitHub Integration

When a pull request is created:

  1. CI runs tests → Results sent to TrendGate
  2. TrendGate analyzes → Compares against baseline
  3. Status updated → GitHub shows pass/fail
  4. Merge blocked → If quality standards not met

Status Types

  • Passed: All quality criteria met
  • Failed: One or more criteria failed
  • ⚠️ Warning: Quality degraded but within limits
  • Pending: Analysis in progress

🎯 Gate Configuration

Basic Setup

quality_gates:
enabled: true

criteria:
test_pass_rate:
minimum: 95
block_on_failure: true

coverage:
minimum: 80
allow_decrease: 2 # Allow 2% decrease

performance:
lighthouse_score: 85
block_on_failure: false # Warning only

Advanced Rules

advanced_gates:
# Different rules for different files
file_rules:
"src/payments/**":
coverage: 95
test_pass_rate: 100

"src/utils/**":
coverage: 70
test_pass_rate: 90

# Bypass for emergencies
bypass:
with_label: ["emergency", "hotfix"]
requires_approval: true
approvers: ["qa-team", "team-lead"]

📊 Gate Decisions

Decision Logic

graph TD
A[PR Created] --> B[Run Tests]
B --> C{Pass Rate OK?}
C -->|Yes| D{Coverage OK?}
C -->|No| F[Block PR]
D -->|Yes| E{Performance OK?}
D -->|No| F
E -->|Yes| G[Allow Merge]
E -->|No| H{Enforcement?}
H -->|Block| F
H -->|Warn| I[Warning + Allow]

Override Mechanism

For exceptional cases:

# Override with justification
trendgate override --pr=123 --reason="Critical security fix"

# Requires approval based on policy
trendgate approve-override --pr=123

🔔 Notifications

Failure Notifications

When gates fail, TrendGate:

  • Comments on the PR with details
  • Sends notifications to configured channels
  • Provides specific fix suggestions

Example PR comment:

❌ Quality Gate Failed

Test Pass Rate: 92% (required: 95%)
- Failed tests: 8
- New failures: UserService.test.js

Coverage: 78% (required: 80%)
- Uncovered lines: 234-267 in payment.js

💡 To fix:
1. Review failing tests in UserService
2. Add tests for payment validation logic

View full report: https://app.trendgate.ai/pr/123

🛡️ Best Practices

1. Gradual Adoption

Start with warnings before blocking:

week_1_2:
block_on_failure: false
notify_only: true

week_3_onwards:
block_on_failure: true

2. Clear Communication

  • Document gate criteria in README
  • Include in onboarding docs
  • Show current thresholds in PR template

3. Emergency Procedures

Define clear bypass procedures:

  • Who can approve overrides
  • When overrides are acceptable
  • How to document exceptions

🚀 Getting Started

  1. Enable in GitHub: Install TrendGate GitHub App
  2. Configure Policies: Set quality thresholds
  3. Test with Sample PR: Verify gates work correctly
  4. Roll Out Gradually: Start with one team/repo
  5. Monitor and Adjust: Refine based on feedback

Quality gates are your automated guardian of code quality!