echokit

Branch Protection Setup for EchoKit

Overview

This document describes the required branch protection rules to ensure automated regression tests block bad code from merging to develop.

Required Branch Protection Rules

For develop Branch

  1. Go to GitHub Repository Settings
    • Navigate to: Settings → Branches
    • Click “Add rule” or edit existing rule for develop
  2. Configure Required Status Checks
    • Require status checks to pass before merging
    • Require branches to be up to date before merging
    • Select required checks:
      • smoke (E2E regression tests - ~90 seconds)
      • validate (Syntax and structure validation - ~10 seconds)
  3. Additional Recommended Settings
    • Require a pull request before merging
    • Require approvals: 1 (at minimum)
    • Dismiss stale pull request approvals when new commits are pushed
    • Do not allow bypassing the above settings (enforce for admins too)
    • ⚠️ Allow force pushes: DISABLED
    • ⚠️ Allow deletions: DISABLED

Visual Guide

Step 1: Navigate to Branch Protection

GitHub Repo → Settings → Branches → Add rule (or Edit existing)

Step 2: Branch Name Pattern

Branch name pattern: develop

Step 3: Protection Settings

Required:

☑ Require a pull request before merging
  ☑ Require approvals: 1
  ☑ Dismiss stale pull request approvals when new commits are pushed

☑ Require status checks to pass before merging
  ☑ Require branches to be up to date before merging
  Status checks that are required:
    ✓ smoke
    ✓ validate

☑ Do not allow bypassing the above settings
  ☑ Include administrators

☐ Allow force pushes (leave unchecked)
☐ Allow deletions (leave unchecked)

What This Achieves

Before Branch Protection

After Branch Protection

Testing the Setup

1. Create a Test PR (Should Pass)

git checkout -b test/branch-protection
echo "# Test" >> README.md
git add README.md
git commit -m "test: verify branch protection works"
git push origin test/branch-protection

Create PR to develop:

2. Test Failure Scenario (Should Block)

# Break the extension
echo "syntax error!" >> extension/background.js
git add extension/background.js
git commit -m "test: verify tests catch broken code"
git push

Expected behavior:

3. Clean Up

git checkout develop
git branch -D test/branch-protection
git push origin --delete test/branch-protection

CI Job Descriptions

smoke Job

validate Job

Enforcement Policy

DO NOT bypass branch protection rules, even for:

Bypassing tests leads to production incidents.

Troubleshooting

Issue: “Merge pull request” button still enabled despite test failures

Solution:

  1. Check branch protection rules are saved
  2. Verify smoke and validate are in the required status checks list
  3. Ensure “Do not allow bypassing” is checked
  4. Wait a few minutes for GitHub to update (caching)

Issue: Tests pass locally but fail in CI

Solution:

  1. Run tests in headless mode locally: python3 tests/smoke_echokit.py
  2. Check GitHub Actions logs for specific errors
  3. Ensure all dependencies are listed in workflow file
  4. Review CI_CD_IMPLEMENTATION_GUIDE.md troubleshooting section

Issue: Tests are taking too long in CI

Current runtime: ~90 seconds for smoke tests Acceptable runtime: < 2 minutes

If tests exceed 2 minutes:

  1. Check for network timeouts
  2. Review service worker registration timing
  3. Consider parallel test execution (future optimization)

Maintenance

When to Update Rules

Add new required checks when:

Review rules when:

Success Criteria

Branch protection is working correctly when:


Last Updated: 2026-05-12 Status: Active Owner: Engineering Team