1+ # ============================================================================
12# CI Workflow for WP Code Check by Hypercart
2- # Validates changes to the toolkit repository
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+ # ============================================================================
327name : CI
428
529on :
30+ push :
31+ branches :
32+ - main
33+ - development
634 pull_request :
735 branches :
836 - main
937 - development
38+ workflow_dispatch : # Allow manual triggers
1039
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.
40+ # Prevent duplicate runs: use branch name as concurrency key
1441concurrency :
1542 group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1643 cancel-in-progress : true
@@ -24,27 +51,86 @@ jobs:
2451 - name : Checkout code
2552 uses : actions/checkout@v4
2653
54+ - name : Install jq (for JSON processing and Slack)
55+ run : sudo apt-get update && sudo apt-get install -y jq
56+
2757 - name : Make scripts executable
2858 run : |
2959 chmod +x ./dist/bin/check-performance.sh
3060 chmod +x ./dist/tests/run-fixture-tests.sh
61+ chmod +x ./dist/bin/post-to-slack.sh
3162
32- - name : Run performance checks
63+ - name : Run performance audit
64+ id : audit
3365 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"
66+ echo "Running performance audit on toolkit repository..."
67+
68+ # Run in JSON mode for Slack integration
69+ ./dist/bin/check-performance.sh \
70+ --paths "." \
71+ --format json \
72+ --strict \
73+ > audit-results.json && EXIT_CODE=0 || EXIT_CODE=$?
74+
75+ echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
76+
77+ # Show summary in workflow logs
78+ if [ -f audit-results.json ]; then
79+ echo "## Performance Audit Summary"
80+ jq -r '.summary // "No summary available"' audit-results.json || echo "Could not parse summary"
3981 fi
82+
83+ # Don't fail the step yet - we want to send Slack notification first
4084 exit 0
85+ continue-on-error : true
86+
87+ - name : Post results to Slack (on push to main/development)
88+ if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development')
89+ env :
90+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
91+ run : |
92+ if [ -n "$SLACK_WEBHOOK_URL" ]; then
93+ echo "📤 Posting results to Slack..."
94+ ./dist/bin/post-to-slack.sh audit-results.json --format detailed || {
95+ echo "::warning::Failed to post to Slack"
96+ }
97+ else
98+ echo "ℹ️ SLACK_WEBHOOK_URL not configured, skipping Slack notification"
99+ fi
100+
101+ - name : Post failure to Slack (on PR failures only)
102+ if : github.event_name == 'pull_request' && steps.audit.outputs.exit_code != '0'
103+ env :
104+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
105+ run : |
106+ if [ -n "$SLACK_WEBHOOK_URL" ]; then
107+ echo "📤 Posting failure to Slack..."
108+ ./dist/bin/post-to-slack.sh audit-results.json --format detailed || {
109+ echo "::warning::Failed to post to Slack"
110+ }
111+ else
112+ echo "ℹ️ SLACK_WEBHOOK_URL not configured, skipping Slack notification"
113+ fi
114+
115+ - name : Upload audit results
116+ if : always()
117+ uses : actions/upload-artifact@v4
118+ with :
119+ name : performance-audit-results-${{ github.run_number }}
120+ path : audit-results.json
121+ retention-days : 30
41122
42123 - name : Display check info
43124 if : always()
44125 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"
126+ EXIT_CODE="${{ steps.audit.outputs.exit_code }}"
127+ if [ "${EXIT_CODE:-0}" -ne 0 ]; then
128+ echo "::warning::Performance audit found issues (exit code: $EXIT_CODE)"
129+ echo "Note: The toolkit itself may have intentional patterns for testing"
130+ echo "This is informational for the toolkit repository"
131+ else
132+ echo "✅ Performance checks completed successfully"
133+ fi
48134
49135 validate-test-fixtures :
50136 name : Validate Test Fixtures
0 commit comments