Skip to content

Commit df4cd3a

Browse files
Merge pull request #132 from DataIntegrationGroup/TAM-patch-CI-CD
[BDMS-264] Patch CI/CD Cypress Testing
2 parents a5a60fb + 7a095aa commit df4cd3a

12 files changed

Lines changed: 579 additions & 275 deletions

File tree

.github/workflows/CI_cypress.yml

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,31 @@ on:
44
pull_request:
55

66
jobs:
7-
install:
7+
integration-tests:
88
runs-on: ubuntu-24.04
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v4
12-
13-
- name: Cypress install
14-
uses: cypress-io/github-action@v6
15-
with:
16-
# Disable running of tests within install job
17-
runTests: false
18-
build: npm run build
19-
env:
20-
VITE_BASE_URL: http://localhost:4173
21-
VITE_OCOTILLO_API_URL: http://127.0.0.1:4010
229

23-
- name: Save build folder
24-
uses: actions/upload-artifact@v4
25-
with:
26-
name: build
27-
if-no-files-found: error
28-
path: dist
10+
env:
11+
NODE_ENV: test
12+
OCOTILLO_API_URL: http://localhost:8000
13+
VITE_OCOTILLO_API_URL: http://localhost:8000
14+
POSTGRES_USER: ${{ secrets.PG_TEST_USER }}
15+
POSTGRES_PASSWORD: ${{ secrets.PG_TEST_PW }}
16+
POSTGRES_DB: ${{ secrets.PG_TEST_DB }}
17+
MODE: development
18+
AUTHENTIK_DISABLE_AUTHENTICATION: ${{ secrets.AUTHENTIK_TEST }}
2919

30-
cypress-run:
31-
runs-on: ubuntu-24.04
32-
needs: install
3320
steps:
34-
- name: Checkout
21+
- name: Checkout frontend
3522
uses: actions/checkout@v4
3623

37-
- name: Setup Node.js
24+
- name: Checkout FastAPI backend (NMSampleLocations staging)
25+
uses: actions/checkout@v4
26+
with:
27+
repository: DataIntegrationGroup/NMSampleLocations
28+
ref: staging
29+
path: api-repo
30+
31+
- name: Set up Node.js
3832
uses: actions/setup-node@v4
3933
with:
4034
node-version: '22.x'
@@ -43,21 +37,41 @@ jobs:
4337
- name: Install dependencies
4438
run: npm ci
4539

46-
- name: Download the build folder
47-
uses: actions/download-artifact@v4
48-
with:
49-
name: build
50-
path: dist
51-
52-
- name: Start mock server
40+
- name: Start FastAPI backend (Docker Compose)
41+
working-directory: ./api-repo
42+
env:
43+
INSTALL_DEV: true
5344
run: |
54-
# Start mock server in background
55-
npm run mock:server:cypress &
56-
# Wait for server to start
57-
sleep 10
58-
59-
- name: Cypress run
45+
docker compose build --build-arg INSTALL_DEV=$INSTALL_DEV app
46+
docker compose up -d
47+
echo "Waiting for FastAPI to be ready..."
48+
timeout 180 bash -c 'until curl -f http://localhost:8000/docs; do sleep 3; done'
49+
echo "FastAPI is up and healthy"
50+
51+
- name: Seed database
52+
working-directory: ./api-repo
53+
run: docker compose exec -T app python -m transfers.seed
54+
55+
- name: Build frontend
56+
run: npm run build
57+
env:
58+
VITE_BASE_URL: http://localhost:4173
59+
VITE_OCOTILLO_API_URL: http://localhost:8000
60+
61+
- name: Run Cypress e2e tests
6062
uses: cypress-io/github-action@v6
6163
with:
6264
start: npm start
63-
browser: chrome
65+
browser: chrome
66+
spec: |
67+
cypress/e2e/test-api-connectivity.cy.ts
68+
cypress/e2e/ocotillo/**/*.cy.ts
69+
env:
70+
DEBUG: cypress:network:*,cypress:server:request
71+
VITE_OCOTILLO_API_URL: http://localhost:8000
72+
73+
- name: Stop API containers
74+
if: always()
75+
working-directory: ./api-repo
76+
run: docker compose down
77+

cypress.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export default defineConfig({
99
},
1010

1111
e2e: {
12-
baseUrl: 'http://localhost:4173',
12+
baseUrl: process.env.CI
13+
? "http://localhost:4173"
14+
: "http://localhost:5173",
1315
setupNodeEvents(on, config) {
1416
process.env.NODE_ENV = 'test'
1517
},

0 commit comments

Comments
 (0)