@@ -2,8 +2,13 @@ name: Pull request checks
22
33on : [pull_request]
44
5+ # Cancel in-progress runs on new pushes
6+ concurrency :
7+ group : ${{ github.workflow }}-${{ github.ref }}
8+ cancel-in-progress : true
9+
510env :
6- NODE_VERSION : " 20 "
11+ NODE_VERSION : ' 20 '
712
813jobs :
914 lint :
@@ -23,27 +28,145 @@ jobs:
2328 - name : Run linter
2429 uses : ./.github/actions/lint
2530
26- # e2e-tests:
27- # name: E2E Cypress tests
28- # needs: ['lint']
29- # runs-on: ubuntu-24.04
30- # steps:
31- # - name: Checkout repository
32- # uses: actions/checkout@v4
33-
34- # - name: Start Kuzzle
35- # run: docker compose up --wait
36-
37- # - name: Cypress run
38- # uses: cypress-io/github-action@v6
39- # with:
40- # build: npm run build
41- # start: npm run preview
42- # browser: chrome
43-
44- # - name: Upload screenshots
45- # uses: actions/upload-artifact@v4
46- # if: failure()
47- # with:
48- # name: cypress-snapshots
49- # path: test/e2e/failed-test
31+ e2e-tests :
32+ name : E2E Test - ${{ matrix.spec }}
33+ needs : ['lint']
34+ runs-on : ubuntu-24.04
35+ strategy :
36+ fail-fast : false
37+ matrix :
38+ spec :
39+ - login
40+ - users
41+ - roles
42+ - profiles
43+ - resetpassword
44+ - JSONEditor
45+ - chartView
46+ - formView
47+ - treeview
48+ - ' 404'
49+ - api-actions
50+ - collections
51+ - docs
52+ - environments
53+ - indexes
54+ - search
55+ - watch
56+
57+ steps :
58+ - name : Checkout repository
59+ uses : actions/checkout@v4
60+
61+ - name : Setup Node
62+ uses : actions/setup-node@v4
63+ with :
64+ node-version : ${{ env.NODE_VERSION }}
65+ cache : ' npm'
66+
67+ - name : Cache Cypress binary
68+ uses : actions/cache@v3
69+ with :
70+ path : ~/.cache/Cypress
71+ key : cypress-binary-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
72+
73+ - name : Install dependencies
74+ run : npm ci
75+
76+ - name : Start Kuzzle
77+ run : |
78+ docker compose up --wait
79+ docker ps
80+ curl -v http://localhost:7512/_healthcheck
81+
82+ - name : Build
83+ run : npm run build
84+
85+ - name : Start preview server
86+ run : |
87+ npx vite preview --host 0.0.0.0 --port 8080 &
88+ echo $! > preview.pid
89+
90+ echo "Waiting for preview server..."
91+ timeout=30
92+ until curl -s http://localhost:8080 > /dev/null; do
93+ sleep 1
94+ timeout=$((timeout-1))
95+ if [ $timeout -eq 0 ]; then
96+ echo "Preview server failed to start"
97+ exit 1
98+ fi
99+ done
100+ echo "Preview server is ready!"
101+
102+ - name : Run Cypress test
103+ id : cypress
104+ run : |
105+ START_TIME=$(date +%s)
106+
107+ npx cypress run \
108+ --spec "test/e2e/cypress/integration/single-backend/${{ matrix.spec }}.spec.js" \
109+ --browser chrome \
110+ --config baseUrl=http://localhost:8080,retries=2
111+
112+ END_TIME=$(date +%s)
113+ DURATION=$((END_TIME - START_TIME))
114+ echo "duration=$DURATION" >> $GITHUB_OUTPUT
115+
116+ - name : Cleanup
117+ if : always()
118+ run : |
119+ if [ -f preview.pid ]; then
120+ kill $(cat preview.pid) || true
121+ fi
122+
123+ - name : Upload test results
124+ if : always()
125+ uses : actions/upload-artifact@v4
126+ with :
127+ name : cypress-results-${{ matrix.spec }}
128+ path : |
129+ cypress/videos
130+ cypress/screenshots
131+ cypress/results
132+ retention-days : 5
133+
134+ - name : Upload failure screenshots
135+ if : failure()
136+ uses : actions/upload-artifact@v4
137+ with :
138+ name : cypress-snapshots-${{ matrix.spec }}
139+ path : test/e2e/failed-test
140+ retention-days : 5
141+
142+ test-summary :
143+ name : Tests Summary
144+ needs : [lint, e2e-tests]
145+ if : always()
146+ runs-on : ubuntu-24.04
147+ steps :
148+ - name : Create Summary
149+ run : |
150+ echo "# Test Results Summary 📊" >> $GITHUB_STEP_SUMMARY
151+ echo "## Status" >> $GITHUB_STEP_SUMMARY
152+
153+ if [ "${{ needs.e2e-tests.result }}" = "success" ] && [ "${{ needs.lint.result }}" = "success" ]; then
154+ echo "✅ All tests passed successfully!" >> $GITHUB_STEP_SUMMARY
155+ else
156+ echo "❌ Some tests failed" >> $GITHUB_STEP_SUMMARY
157+ fi
158+
159+ echo "## Details" >> $GITHUB_STEP_SUMMARY
160+ echo "- Lint: ${{ needs.lint.result }}" >> $GITHUB_STEP_SUMMARY
161+ echo "- E2E Tests: ${{ needs.e2e-tests.result }}" >> $GITHUB_STEP_SUMMARY
162+
163+ # Set exit code based on test results
164+ if [ "${{ needs.e2e-tests.result }}" = "failure" ]; then
165+ echo "❌ E2E tests failed"
166+ exit 1
167+ elif [ "${{ needs.lint.result }}" = "failure" ]; then
168+ echo "❌ Lint failed"
169+ exit 1
170+ else
171+ echo "✅ All tests passed!"
172+ fi
0 commit comments