@@ -11,9 +11,8 @@ concurrency:
1111 cancel-in-progress : false
1212
1313jobs :
14- test :
14+ unit :
1515 runs-on : ubuntu-latest
16-
1716 steps :
1817 - name : Checkout
1918 uses : actions/checkout@v4
@@ -27,42 +26,67 @@ jobs:
2726 - name : Install dependencies
2827 run : npm ci
2928
30- - name : Run tests
29+ - name : Run unit tests
3130 run : npm test -- --runInBand
3231
33- deploy :
32+ integration :
3433 runs-on : ubuntu-latest
35- needs : test
36- environment : production
37-
3834 steps :
39- - name : Deploy over SSH
40- uses : appleboy/ssh-action@v1.2.0
41- env :
42- DEPLOY_BRANCH : main
43- DEPLOY_PATH : ${{ vars.VPS_NEXTJS_APP_DIR }}
44- IMAGE_NAME : nextjs-app
35+ - name : Checkout
36+ uses : actions/checkout@v4
37+
38+ - name : Setup Node.js
39+ uses : actions/setup-node@v4
4540 with :
46- host : ${{ secrets.VPS_HOST }}
47- username : ${{ secrets.VPS_USER }}
48- key : ${{ secrets.VPS_SSH_KEY }}
49- port : ${{ secrets.VPS_PORT }}
50- script_stop : true
51- envs : DEPLOY_BRANCH,DEPLOY_PATH,IMAGE_NAME
52- script : |
53- set -euo pipefail
41+ node-version : 20
42+ cache : npm
43+
44+ - name : Install dependencies
45+ run : npm ci
46+
47+ # Integration tests spin up real MySQL + Redis via testcontainers.
48+ # Docker is preinstalled and running on ubuntu-latest runners.
49+ - name : Run integration tests
50+ run : npm run test:integration
5451
55- cd "$DEPLOY_PATH"
56- git fetch origin "$DEPLOY_BRANCH"
57- git checkout "$DEPLOY_BRANCH"
58- git reset --hard "origin/$DEPLOY_BRANCH"
52+ e2e :
53+ runs-on : ubuntu-latest
54+ steps :
55+ - name : Checkout
56+ uses : actions/checkout@v4
57+
58+ - name : Setup Node.js
59+ uses : actions/setup-node@v4
60+ with :
61+ node-version : 20
62+ cache : npm
5963
60- docker build -t "$IMAGE_NAME" .
64+ - name : Install dependencies
65+ run : npm ci
6166
62- cd ~/app
67+ - name : Install Playwright browsers
68+ run : npx playwright install --with-deps chromium
6369
64- docker compose up -d mysql_nextjs redis
65- docker compose run --rm -e RUN_MIGRATIONS=1 nextjs true
66- docker compose up -d nextjs
70+ # All /api/* calls are mocked in the specs, so no real backend is needed.
71+ # These dummy env vars only let `next dev` boot cleanly.
72+ - name : Run e2e tests
73+ run : npm run test:e2e
74+ env :
75+ MYSQL_HOST : localhost
76+ MYSQL_PORT : " 3306"
77+ MYSQL_USER : ci
78+ MYSQL_PASSWORD : ci
79+ MYSQL_DATABASE : ci
80+ REDIS_HOST : localhost
81+ REDIS_PORT : " 6379"
82+ REDIS_PASSWORD : " "
83+ PYTHON_MICROSERVICE_BASE_URL : http://localhost:8000
6784
68- docker image prune -f
85+ - name : Upload Playwright report
86+ if : ${{ !cancelled() }}
87+ uses : actions/upload-artifact@v4
88+ with :
89+ name : playwright-report
90+ path : playwright-report/
91+ retention-days : 7
92+ if-no-files-found : ignore
0 commit comments