Skip to content

Commit c62ec80

Browse files
committed
ci: Adding the same logic between workflows
1 parent c24ee64 commit c62ec80

File tree

1 file changed

+128
-10
lines changed

1 file changed

+128
-10
lines changed

.github/workflows/push_dev.workflow.yml

Lines changed: 128 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,147 @@ jobs:
2727
uses: ./.github/actions/lint
2828

2929
e2e-tests:
30-
name: E2E Cypress tests
30+
name: E2E Test - ${{ matrix.spec }}
3131
needs: ['lint']
3232
runs-on: ubuntu-24.04
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
spec:
37+
- login
38+
- users
39+
- roles
40+
- profiles
41+
- resetpassword
42+
- JSONEditor
43+
- chartView
44+
- formView
45+
- treeview
46+
- '404'
47+
- api-actions
48+
- collections
49+
- docs
50+
- environments
51+
- indexes
52+
- search
53+
- watch
54+
3355
steps:
3456
- name: Checkout repository
3557
uses: actions/checkout@v4
3658

37-
- name: Start Kuzzle
38-
run: docker compose up --wait
59+
- name: Setup Node
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: ${{ env.NODE_VERSION }}
63+
cache: 'npm'
3964

40-
- name: Cypress run
41-
uses: cypress-io/github-action@v6
65+
- name: Cache Cypress binary
66+
uses: actions/cache@v3
4267
with:
43-
build: npm run build
44-
start: npm run preview
45-
browser: chrome
68+
path: ~/.cache/Cypress
69+
key: cypress-binary-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
70+
71+
- name: Install dependencies
72+
run: npm ci
73+
74+
- name: Start Kuzzle
75+
run: |
76+
docker compose up --wait
77+
docker ps
78+
curl -v http://localhost:7512/_healthcheck
79+
80+
- name: Build
81+
run: npm run build
82+
83+
- name: Start preview server
84+
run: |
85+
npx vite preview --host 0.0.0.0 --port 8080 &
86+
echo $! > preview.pid
87+
88+
echo "Waiting for preview server..."
89+
timeout=30
90+
until curl -s http://localhost:8080 > /dev/null; do
91+
sleep 1
92+
timeout=$((timeout-1))
93+
if [ $timeout -eq 0 ]; then
94+
echo "Preview server failed to start"
95+
exit 1
96+
fi
97+
done
98+
echo "Preview server is ready!"
99+
100+
- name: Run Cypress test
101+
id: cypress
102+
run: |
103+
START_TIME=$(date +%s)
46104
47-
- name: Upload screenshots
105+
npx cypress run \
106+
--spec "test/e2e/cypress/integration/single-backend/${{ matrix.spec }}.spec.js" \
107+
--browser chrome \
108+
--config baseUrl=http://localhost:8080,retries=2
109+
110+
END_TIME=$(date +%s)
111+
DURATION=$((END_TIME - START_TIME))
112+
echo "duration=$DURATION" >> $GITHUB_OUTPUT
113+
114+
- name: Cleanup
115+
if: always()
116+
run: |
117+
if [ -f preview.pid ]; then
118+
kill $(cat preview.pid) || true
119+
fi
120+
121+
- name: Upload test results
122+
if: always()
48123
uses: actions/upload-artifact@v4
124+
with:
125+
name: cypress-results-${{ matrix.spec }}
126+
path: |
127+
cypress/videos
128+
cypress/screenshots
129+
cypress/results
130+
retention-days: 5
131+
132+
- name: Upload failure screenshots
49133
if: failure()
134+
uses: actions/upload-artifact@v4
50135
with:
51-
name: cypress-snapshots
136+
name: cypress-snapshots-${{ matrix.spec }}
52137
path: test/e2e/failed-test
138+
retention-days: 5
139+
140+
test-summary:
141+
name: Tests Summary
142+
needs: [lint, e2e-tests]
143+
if: always()
144+
runs-on: ubuntu-24.04
145+
steps:
146+
- name: Create Summary
147+
run: |
148+
echo "# Test Results Summary 📊" >> $GITHUB_STEP_SUMMARY
149+
echo "## Status" >> $GITHUB_STEP_SUMMARY
150+
151+
if [ "${{ needs.e2e-tests.result }}" = "success" ] && [ "${{ needs.lint.result }}" = "success" ]; then
152+
echo "✅ All tests passed successfully!" >> $GITHUB_STEP_SUMMARY
153+
else
154+
echo "❌ Some tests failed" >> $GITHUB_STEP_SUMMARY
155+
fi
156+
157+
echo "## Details" >> $GITHUB_STEP_SUMMARY
158+
echo "- Lint: ${{ needs.lint.result }}" >> $GITHUB_STEP_SUMMARY
159+
echo "- E2E Tests: ${{ needs.e2e-tests.result }}" >> $GITHUB_STEP_SUMMARY
160+
161+
# Set exit code based on test results
162+
if [ "${{ needs.e2e-tests.result }}" = "failure" ]; then
163+
echo "❌ E2E tests failed"
164+
exit 1
165+
elif [ "${{ needs.lint.result }}" = "failure" ]; then
166+
echo "❌ Lint failed"
167+
exit 1
168+
else
169+
echo "✅ All tests passed!"
170+
fi
53171
54172
deploy-staging:
55173
name: Deploy Admin Console to staging - next-console.kuzzle.io

0 commit comments

Comments
 (0)