@@ -24,10 +24,119 @@ jobs:
2424
2525 - name : Install dependencies
2626 run : npm install
27+
2728 - name : Lint checks
2829 run : npm run format-check
30+
2931 - name : Unit test
3032 run : npm run test:ci
33+
34+ - name : Install Cypress dependencies
35+ run : |
36+ cd cypress
37+ npm install
38+
39+ - name : E2E tests
40+ run : |
41+ cd cypress
42+ npm run test:e2e
43+
44+ - name : Check if cypress exists in main
45+ id : check_cypress
46+ run : |
47+ git fetch origin main
48+ if git ls-tree -r origin/main --name-only | grep -q "^cypress/"; then
49+ echo "cypress_exists=true" >> $GITHUB_OUTPUT
50+ echo "✅ Cypress folder exists in main branch"
51+ else
52+ echo "cypress_exists=false" >> $GITHUB_OUTPUT
53+ echo "⚠️ Cypress folder does not exist in main branch - skipping baseline"
54+ fi
55+
56+ - name : Get main branch performance (baseline)
57+ if : steps.check_cypress.outputs.cypress_exists == 'true'
58+ run : |
59+ # Save current branch
60+ CURRENT_BRANCH=$(git branch --show-current)
61+ echo "current_branch=$CURRENT_BRANCH" >> $GITHUB_ENV
62+
63+ # Checkout main and test
64+ git checkout origin/main
65+ cd cypress
66+ npm install
67+ npm run test:performance || true
68+
69+ # Save main branch metrics as baseline
70+ if [ -f performance-results/metrics.json ]; then
71+ cp performance-results/metrics.json performance-results/baseline-metrics.json
72+ echo "✅ Main branch baseline captured"
73+ fi
74+
75+ # Return to PR branch
76+ git checkout $CURRENT_BRANCH
77+
78+ - name : Get PR branch performance
79+ run : |
80+ cd cypress
81+ npm run test:performance
82+
83+ - name : Compare performance (main vs PR)
84+ if : steps.check_cypress.outputs.cypress_exists == 'true'
85+ id : perf_compare
86+ run : |
87+ cd cypress
88+ npm run compare:performance || echo "comparison_failed=true" >> $GITHUB_OUTPUT
89+ continue-on-error : true
90+
91+ - name : Skip comparison message
92+ if : steps.check_cypress.outputs.cypress_exists == 'false'
93+ run : |
94+ echo "⚠️ Skipping performance comparison - cypress folder not in main branch yet"
95+ echo "This is expected for the first PR that adds performance testing"
96+ echo "Future PRs will compare against this baseline"
97+
98+ - name : Upload performance report
99+ uses : actions/upload-artifact@v4
100+ if : always()
101+ with :
102+ name : performance-report
103+ path : cypress/performance-results/comparison-report.md
104+ if-no-files-found : ignore
105+
106+ - name : Comment PR with performance results
107+ uses : actions/github-script@v6
108+ if : github.event_name == 'pull_request' && always()
109+ with :
110+ script : |
111+ const fs = require('fs');
112+ const reportPath = 'cypress/performance-results/comparison-report.md';
113+
114+ if (fs.existsSync(reportPath)) {
115+ const report = fs.readFileSync(reportPath, 'utf8');
116+
117+ github.rest.issues.createComment({
118+ issue_number: context.issue.number,
119+ owner: context.repo.owner,
120+ repo: context.repo.repo,
121+ body: report
122+ });
123+ }
124+
125+ - name : Upload Cypress screenshots on failure
126+ uses : actions/upload-artifact@v4
127+ if : failure()
128+ with :
129+ name : cypress-screenshots
130+ path : cypress/screenshots
131+ if-no-files-found : ignore
132+
133+ - name : Upload Cypress videos
134+ uses : actions/upload-artifact@v4
135+ if : always()
136+ with :
137+ name : cypress-videos
138+ path : cypress/videos
139+ if-no-files-found : ignore
31140
32141 - name : Build
33142 run : npm run react-build
0 commit comments