Skip to content

Commit 52d9b35

Browse files
committed
CI comment safeguards
1 parent 3f36b60 commit 52d9b35

3 files changed

Lines changed: 165 additions & 1 deletion

File tree

.github/workflows/README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+

.github/workflows/ci.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1+
# ============================================================================
12
# CI Workflow for WP Code Check by Hypercart
2-
# Consolidated workflow with performance checks, fixture validation, and Slack notifications
3+
# ============================================================================
4+
#
5+
# ⚠️ WARNING: This is the ONLY workflow file that should exist in this repo!
6+
#
7+
# This consolidated workflow handles ALL CI needs:
8+
# - Performance checks and audits
9+
# - Test fixture validation
10+
# - Slack notifications (conditional based on event type)
11+
# - Artifact uploads
12+
#
13+
# DO NOT create additional workflow files for:
14+
# - Slack notifications (already integrated here)
15+
# - Performance audits (already integrated here)
16+
# - Additional CI checks (add them to this file instead)
17+
#
18+
# If you need to modify CI behavior, edit THIS file only.
19+
# Multiple workflows cause duplicate runs and waste CI resources.
20+
#
21+
# History: Consolidated from 3 separate workflows on 2025-12-31
22+
# - Removed: performance-audit-slack.yml
23+
# - Removed: performance-audit-slack-on-failure.yml
24+
# - Kept: ci.yml (this file) with all functionality merged
25+
#
26+
# ============================================================================
327
name: CI
428

529
on:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6666
- **Removed Files**:
6767
- `.github/workflows/performance-audit-slack.yml`
6868
- `.github/workflows/performance-audit-slack-on-failure.yml`
69+
- **Safeguards Added**:
70+
- Added prominent warning comments in `ci.yml` header explaining single-workflow policy
71+
- Created `.github/workflows/README.md` documenting:
72+
- Why we use a single workflow
73+
- How to modify CI behavior without creating new files
74+
- Checklist before creating new workflows
75+
- History of consolidation to prevent regression
6976

7077
- **DRY Refactor: Consolidated Grouping Logic** - Created centralized `group_and_add_finding()` helper function
7178
- **Before**: Duplicate grouping logic in `run_check()` function and admin capability check (92 lines duplicated)

0 commit comments

Comments
 (0)