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
33name : CI
44
55on :
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
1417concurrency :
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
0 commit comments