2323 - name : Run linter
2424 uses : ./.github/actions/lint
2525
26- test-login :
27- name : Test Login
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- spec : test/e2e/cypress/integration/single-backend/login.spec.js
44-
45- - name : Upload screenshots
46- uses : actions/upload-artifact@v4
47- if : failure()
48- with :
49- name : cypress-snapshots-login
50- path : test/e2e/failed-test
51-
5226 test-users :
5327 name : Test Users
5428 needs : ['lint']
@@ -57,63 +31,59 @@ jobs:
5731 - name : Checkout repository
5832 uses : actions/checkout@v4
5933
60- - name : Start Kuzzle
61- run : docker compose up --wait
62-
63- - name : Cypress run
64- uses : cypress-io/github-action@v6
65- with :
66- build : npm run build
67- start : npm run preview
68- browser : chrome
69- spec : test/e2e/cypress/integration/single-backend/users.spec.js
70-
71- - name : Upload screenshots
72- uses : actions/upload-artifact@v4
73- if : failure()
34+ - name : Setup Node
35+ uses : actions/setup-node@v4
7436 with :
75- name : cypress-snapshots-users
76- path : test/e2e/failed-test
37+ node-version : ${{ env.NODE_VERSION }}
38+ cache : ' npm '
7739
78- test-roles :
79- name : Test Roles
80- needs : ['lint']
81- runs-on : ubuntu-24.04
82- steps :
83- - name : Checkout repository
84- uses : actions/checkout@v4
40+ - name : Install dependencies
41+ run : npm ci
8542
8643 - name : Start Kuzzle
87- run : docker compose up --wait
44+ run : |
45+ docker compose up --wait
46+ docker ps # Debug: check running containers
47+ curl -v http://localhost:7512 # Debug: check if Kuzzle is responding
8848
89- - name : Cypress run
90- uses : cypress-io/github-action@v6
91- with :
92- build : npm run build
93- start : npm run preview
94- browser : chrome
95- spec : test/e2e/cypress/integration/single-backend/roles.spec.js
49+ - name : Build
50+ run : npm run build
51+
52+ - name : Start preview and test
53+ run : |
54+ # Start the preview server and capture its PID
55+ npm run preview &
56+ PREVIEW_PID=$!
57+
58+ # Wait for preview server to be ready
59+ echo "Waiting for preview server..."
60+ for i in {1..30}; do
61+ if curl -s http://localhost:8080 > /dev/null; then
62+ echo "Preview server is up!"
63+ break
64+ fi
65+ if [ $i -eq 30 ]; then
66+ echo "Preview server failed to start"
67+ exit 1
68+ fi
69+ sleep 1
70+ done
71+
72+ # Run Cypress test
73+ npx cypress run --spec "test/e2e/cypress/integration/single-backend/users.spec.js" --browser chrome
74+
75+ # Store the exit code
76+ TEST_EXIT_CODE=$?
77+
78+ # Kill the preview server
79+ kill $PREVIEW_PID
80+
81+ # Exit with the test exit code
82+ exit $TEST_EXIT_CODE
9683
9784 - name : Upload screenshots
9885 uses : actions/upload-artifact@v4
9986 if : failure()
10087 with :
101- name : cypress-snapshots-roles
88+ name : cypress-snapshots-users
10289 path : test/e2e/failed-test
103-
104- test-summary :
105- name : Tests Summary
106- needs : [lint, test-login, test-users, test-roles]
107- if : always()
108- runs-on : ubuntu-24.04
109- steps :
110- - name : Check test results
111- run : |
112- if [ "${{ needs.test-login.result }}" = "failure" ] || \
113- [ "${{ needs.test-users.result }}" = "failure" ] || \
114- [ "${{ needs.test-roles.result }}" = "failure" ]; then
115- echo "One or more tests failed"
116- exit 1
117- else
118- echo "All tests passed!"
119- fi
0 commit comments