|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +## ⚠️ IMPORTANT: Single Workflow Policy |
| 4 | + |
| 5 | +**This repository uses a SINGLE consolidated workflow file: `ci.yml`** |
| 6 | + |
| 7 | +### DO NOT Create Additional Workflow Files |
| 8 | + |
| 9 | +❌ **Do NOT create:** |
| 10 | +- Separate workflows for Slack notifications |
| 11 | +- Separate workflows for performance audits |
| 12 | +- Separate workflows for different branches |
| 13 | +- Duplicate workflows with slight variations |
| 14 | + |
| 15 | +✅ **Instead:** |
| 16 | +- Edit `ci.yml` to add new functionality |
| 17 | +- Use conditional logic for different behaviors |
| 18 | +- Use job dependencies for complex workflows |
| 19 | +- Use reusable workflows only for external consumption |
| 20 | + |
| 21 | +## Why Single Workflow? |
| 22 | + |
| 23 | +**Problem we had (Dec 2025):** |
| 24 | +- 3 separate workflows running simultaneously |
| 25 | +- Each PR/push triggered 3+ workflow runs |
| 26 | +- Wasted CI resources and created confusion |
| 27 | +- Duplicate Slack notifications |
| 28 | +- Harder to maintain consistency |
| 29 | + |
| 30 | +**Solution:** |
| 31 | +- Consolidated into single `ci.yml` workflow |
| 32 | +- Conditional Slack notifications based on event type |
| 33 | +- All CI logic in one place |
| 34 | +- Easier to maintain and debug |
| 35 | + |
| 36 | +## Current Workflow Structure |
| 37 | + |
| 38 | +### `ci.yml` - Consolidated CI Workflow |
| 39 | + |
| 40 | +**Triggers:** |
| 41 | +- `push` to main/development branches |
| 42 | +- `pull_request` to main/development branches |
| 43 | +- `workflow_dispatch` for manual runs |
| 44 | + |
| 45 | +**Jobs:** |
| 46 | + |
| 47 | +1. **performance-checks** |
| 48 | + - Runs performance audit in JSON mode |
| 49 | + - Conditional Slack notifications: |
| 50 | + - Push to main/development: Always notify |
| 51 | + - Pull requests: Only notify on failures |
| 52 | + - Uploads audit results as artifacts |
| 53 | + - Handles missing SLACK_WEBHOOK_URL gracefully |
| 54 | + |
| 55 | +2. **validate-test-fixtures** |
| 56 | + - Runs automated fixture validation tests |
| 57 | + - Tests antipattern detection |
| 58 | + - Validates clean code passes checks |
| 59 | + |
| 60 | +### `wp-performance.yml` - Reusable Workflow |
| 61 | + |
| 62 | +**Purpose:** External consumption only (workflow_call) |
| 63 | +- Used by other repositories to run performance checks |
| 64 | +- NOT triggered by events in this repository |
| 65 | +- This is OK to keep as it's not causing duplicate runs |
| 66 | + |
| 67 | +## How to Modify CI Behavior |
| 68 | + |
| 69 | +### Adding a New Check |
| 70 | + |
| 71 | +```yaml |
| 72 | +# Add to ci.yml under the appropriate job |
| 73 | +- name: Your new check |
| 74 | + run: | |
| 75 | + echo "Running new check..." |
| 76 | + ./your-script.sh |
| 77 | +``` |
| 78 | +
|
| 79 | +### Changing Slack Notification Logic |
| 80 | +
|
| 81 | +```yaml |
| 82 | +# Edit the conditional in ci.yml |
| 83 | +- name: Post to Slack |
| 84 | + if: your-condition-here |
| 85 | + env: |
| 86 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 87 | + run: | |
| 88 | + ./dist/bin/post-to-slack.sh audit-results.json |
| 89 | +``` |
| 90 | +
|
| 91 | +### Adding a New Job |
| 92 | +
|
| 93 | +```yaml |
| 94 | +# Add to ci.yml at the jobs level |
| 95 | +jobs: |
| 96 | + your-new-job: |
| 97 | + name: Your New Job |
| 98 | + runs-on: ubuntu-latest |
| 99 | + steps: |
| 100 | + - name: Checkout |
| 101 | + uses: actions/checkout@v4 |
| 102 | + # ... your steps |
| 103 | +``` |
| 104 | + |
| 105 | +## Checklist Before Creating a New Workflow |
| 106 | + |
| 107 | +- [ ] Can this be added to `ci.yml` instead? |
| 108 | +- [ ] Is this for external consumption (workflow_call)? |
| 109 | +- [ ] Have I checked if similar functionality already exists? |
| 110 | +- [ ] Will this cause duplicate runs with existing workflows? |
| 111 | +- [ ] Have I documented why a separate workflow is necessary? |
| 112 | + |
| 113 | +## Questions? |
| 114 | + |
| 115 | +If you're unsure whether to create a new workflow or modify `ci.yml`, ask yourself: |
| 116 | + |
| 117 | +1. **Does this need to run on the same triggers?** → Add to `ci.yml` |
| 118 | +2. **Is this a variation of existing checks?** → Add conditional logic to `ci.yml` |
| 119 | +3. **Is this for other repos to consume?** → Create reusable workflow with `workflow_call` |
| 120 | +4. **Is this completely unrelated to CI?** → Maybe OK, but document why |
| 121 | + |
| 122 | +## History |
| 123 | + |
| 124 | +- **2025-12-31**: Consolidated 3 workflows into 1 |
| 125 | + - Removed: `performance-audit-slack.yml` |
| 126 | + - Removed: `performance-audit-slack-on-failure.yml` |
| 127 | + - Enhanced: `ci.yml` with all functionality |
| 128 | + - Created: This README to prevent future duplication |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +**Remember: One workflow to rule them all! 💍** |
| 133 | + |
0 commit comments