Skip to content

Commit 3f36b60

Browse files
committed
Smplify to one CI
1 parent 3ef3e96 commit 3f36b60

4 files changed

Lines changed: 97 additions & 141 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# CI Workflow for WP Code Check by Hypercart
2-
# Validates changes to the toolkit repository
2+
# Consolidated workflow with performance checks, fixture validation, and Slack notifications
33
name: CI
44

55
on:
6+
push:
7+
branches:
8+
- main
9+
- development
610
pull_request:
711
branches:
812
- main
913
- development
14+
workflow_dispatch: # Allow manual triggers
1015

11-
# Prevent duplicate runs: use branch name as concurrency key so both push and
12-
# pull_request events for the same branch share the same group and get deduplicated.
13-
# github.head_ref is set for pull_request (source branch), github.ref for push.
16+
# Prevent duplicate runs: use branch name as concurrency key
1417
concurrency:
1518
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1619
cancel-in-progress: true
@@ -24,27 +27,86 @@ jobs:
2427
- name: Checkout code
2528
uses: actions/checkout@v4
2629

30+
- name: Install jq (for JSON processing and Slack)
31+
run: sudo apt-get update && sudo apt-get install -y jq
32+
2733
- name: Make scripts executable
2834
run: |
2935
chmod +x ./dist/bin/check-performance.sh
3036
chmod +x ./dist/tests/run-fixture-tests.sh
37+
chmod +x ./dist/bin/post-to-slack.sh
3138
32-
- name: Run performance checks
39+
- name: Run performance audit
40+
id: audit
3341
run: |
34-
echo "Running performance checks on toolkit repository..."
35-
./dist/bin/check-performance.sh --paths "." --no-log || EXIT_CODE=$?
36-
if [ "${EXIT_CODE:-0}" -ne 0 ]; then
37-
echo "::warning::Performance checks found issues (exit code: $EXIT_CODE)"
38-
echo "This is informational - the toolkit itself may have intentional patterns for testing"
42+
echo "Running performance audit on toolkit repository..."
43+
44+
# Run in JSON mode for Slack integration
45+
./dist/bin/check-performance.sh \
46+
--paths "." \
47+
--format json \
48+
--strict \
49+
> audit-results.json && EXIT_CODE=0 || EXIT_CODE=$?
50+
51+
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
52+
53+
# Show summary in workflow logs
54+
if [ -f audit-results.json ]; then
55+
echo "## Performance Audit Summary"
56+
jq -r '.summary // "No summary available"' audit-results.json || echo "Could not parse summary"
3957
fi
58+
59+
# Don't fail the step yet - we want to send Slack notification first
4060
exit 0
61+
continue-on-error: true
62+
63+
- name: Post results to Slack (on push to main/development)
64+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development')
65+
env:
66+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
67+
run: |
68+
if [ -n "$SLACK_WEBHOOK_URL" ]; then
69+
echo "📤 Posting results to Slack..."
70+
./dist/bin/post-to-slack.sh audit-results.json --format detailed || {
71+
echo "::warning::Failed to post to Slack"
72+
}
73+
else
74+
echo "ℹ️ SLACK_WEBHOOK_URL not configured, skipping Slack notification"
75+
fi
76+
77+
- name: Post failure to Slack (on PR failures only)
78+
if: github.event_name == 'pull_request' && steps.audit.outputs.exit_code != '0'
79+
env:
80+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
81+
run: |
82+
if [ -n "$SLACK_WEBHOOK_URL" ]; then
83+
echo "📤 Posting failure to Slack..."
84+
./dist/bin/post-to-slack.sh audit-results.json --format detailed || {
85+
echo "::warning::Failed to post to Slack"
86+
}
87+
else
88+
echo "ℹ️ SLACK_WEBHOOK_URL not configured, skipping Slack notification"
89+
fi
90+
91+
- name: Upload audit results
92+
if: always()
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: performance-audit-results-${{ github.run_number }}
96+
path: audit-results.json
97+
retention-days: 30
4198

4299
- name: Display check info
43100
if: always()
44101
run: |
45-
echo "✅ Performance checks completed"
46-
echo "Note: Logs are disabled in CI (--no-log flag)"
47-
echo "The 'dist/tests/' directory is excluded by default"
102+
EXIT_CODE="${{ steps.audit.outputs.exit_code }}"
103+
if [ "${EXIT_CODE:-0}" -ne 0 ]; then
104+
echo "::warning::Performance audit found issues (exit code: $EXIT_CODE)"
105+
echo "Note: The toolkit itself may have intentional patterns for testing"
106+
echo "This is informational for the toolkit repository"
107+
else
108+
echo "✅ Performance checks completed successfully"
109+
fi
48110
49111
validate-test-fixtures:
50112
name: Validate Test Fixtures

.github/workflows/performance-audit-slack-on-failure.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/performance-audit-slack.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444

4545
### Changed
4646

47-
- **GitHub Actions CI Trigger** - Simplified CI workflow to only run on pull requests
48-
- **Before**: Workflow ran on both `push` and `pull_request` events for main, development, and feature branches
49-
- **After**: Workflow only runs on `pull_request` events targeting main or development branches
50-
- **Rationale**: Reduces redundant CI runs and focuses testing on code review stage
51-
- **Impact**: CI runs only when PRs are opened/updated, not on every commit to branches
47+
- **GitHub Actions Workflow Consolidation** - Merged three separate workflows into one comprehensive CI workflow
48+
- **Before**: Three workflows running simultaneously:
49+
- `ci.yml` - Basic performance checks on PRs
50+
- `performance-audit-slack.yml` - Audit with Slack notifications on all events
51+
- `performance-audit-slack-on-failure.yml` - Audit with Slack notifications only on failures
52+
- **After**: Single consolidated `ci.yml` workflow with conditional Slack notifications
53+
- **Triggers**:
54+
- `push` to main/development branches
55+
- `pull_request` to main/development branches
56+
- `workflow_dispatch` for manual runs
57+
- **Slack Notification Logic**:
58+
- On `push` to main/development: Always send results to Slack (if webhook configured)
59+
- On `pull_request`: Only send to Slack if audit fails
60+
- Gracefully handles missing `SLACK_WEBHOOK_URL` secret
61+
- **Benefits**:
62+
- Eliminates duplicate workflow runs (was running 3+ workflows per event)
63+
- Reduces CI noise while maintaining visibility
64+
- Easier to maintain single workflow file
65+
- Consistent artifact naming with run numbers
66+
- **Removed Files**:
67+
- `.github/workflows/performance-audit-slack.yml`
68+
- `.github/workflows/performance-audit-slack-on-failure.yml`
5269

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

0 commit comments

Comments
 (0)