Skip to content

Commit c24ee64

Browse files
authored
Fix the e2e tests (#1006)
* Trying to fix the e2e tests * Trying a new way of doing cypress jobs * Update CI * Update CI * Update CI * Update CI * Update CI * Separate job in CI * Add debug for the CI * Add tests * Trying to fix cypress preview * Trying to fix cypress preview * Last improvments
1 parent 9596093 commit c24ee64

File tree

4 files changed

+175
-51
lines changed

4 files changed

+175
-51
lines changed

.github/workflows/pull_request.workflow.yml

Lines changed: 148 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ name: Pull request checks
22

33
on: [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+
510
env:
6-
NODE_VERSION: "20"
11+
NODE_VERSION: '20'
712

813
jobs:
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

.github/workflows/push_dev.workflow.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 4-dev
77

88
env:
9-
NODE_VERSION: "20"
9+
NODE_VERSION: '20'
1010

1111
jobs:
1212
lint:
@@ -26,34 +26,34 @@ jobs:
2626
- name: Run linter
2727
uses: ./.github/actions/lint
2828

29-
# e2e-tests:
30-
# name: E2E Cypress tests
31-
# needs: ['lint']
32-
# runs-on: ubuntu-24.04
33-
# steps:
34-
# - name: Checkout repository
35-
# uses: actions/checkout@v4
29+
e2e-tests:
30+
name: E2E Cypress tests
31+
needs: ['lint']
32+
runs-on: ubuntu-24.04
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
3636

37-
# - name: Start Kuzzle
38-
# run: docker compose up --wait
37+
- name: Start Kuzzle
38+
run: docker compose up --wait
3939

40-
# - name: Cypress run
41-
# uses: cypress-io/github-action@v6
42-
# with:
43-
# build: npm run build
44-
# start: npm run preview
45-
# browser: chrome
40+
- name: Cypress run
41+
uses: cypress-io/github-action@v6
42+
with:
43+
build: npm run build
44+
start: npm run preview
45+
browser: chrome
4646

47-
# - name: Upload screenshots
48-
# uses: actions/upload-artifact@v4
49-
# if: failure()
50-
# with:
51-
# name: cypress-snapshots
52-
# path: test/e2e/failed-test
47+
- name: Upload screenshots
48+
uses: actions/upload-artifact@v4
49+
if: failure()
50+
with:
51+
name: cypress-snapshots
52+
path: test/e2e/failed-test
5353

5454
deploy-staging:
5555
name: Deploy Admin Console to staging - next-console.kuzzle.io
56-
needs: ['lint']
56+
needs: ['e2e-tests']
5757
runs-on: ubuntu-24.04
5858
steps:
5959
- name: Checkout repository

.github/workflows/push_master.workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- master
77

88
env:
9-
NODE_VERSION: "20"
9+
NODE_VERSION: '20'
1010

1111
jobs:
1212
lint:
@@ -48,8 +48,8 @@ jobs:
4848
uses: actions/upload-artifact@v4
4949
if: failure()
5050
with:
51-
name: cypress-snapshots
52-
path: test/e2e/failed-test
51+
name: cypress-snapshots
52+
path: test/e2e/failed-test
5353

5454
deploy-production:
5555
name: Deploy Admin Console to production - console.kuzzle.io

cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineConfig({
88
viewportHeight: 800,
99
viewportWidth: 1400,
1010
defaultCommandTimeout: 60000,
11+
pageLoadTimeout: 60000,
1112
e2e: {
1213
setupNodeEvents(on, config) {},
1314
baseUrl: 'http://localhost:8080',

0 commit comments

Comments
 (0)