Skip to content

Commit 5f851a5

Browse files
WIP github action for running services.
1 parent ee8aa87 commit 5f851a5

File tree

3 files changed

+105
-34
lines changed

3 files changed

+105
-34
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Run E2e Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
8+
env:
9+
PROJECT_ID: 'benefit-decision-toolkit-play'
10+
WORKLOAD_IDENTITY_PROVIDER: 'projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github'
11+
12+
jobs:
13+
run-e2e-tests:
14+
runs-on: 'ubuntu-latest'
15+
16+
# Add these permissions for Workload Identity Federation
17+
permissions:
18+
contents: read
19+
id-token: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: lts/*
28+
29+
# Devbox Setup #
30+
- name: 'Create .env file' # Devbox needs a .env file to exist, even if it's empty
31+
run: touch .env
32+
33+
- name: Rename env files
34+
run: |
35+
mv builder-frontend/.env.example builder-frontend/.env
36+
mv builder-api/.env.example e2e/.env
37+
38+
- name: 'Install devbox' # Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK
39+
uses: 'jetify-com/[email protected]'
40+
with:
41+
enable-cache: true
42+
43+
- id: 'auth' # Configure Workload Identity Federation and generate an access token
44+
name: 'Authenticate to Google Cloud'
45+
uses: 'google-github-actions/auth@v2'
46+
with:
47+
workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}'
48+
service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
49+
project_id: ${{ env.PROJECT_ID }}
50+
51+
- name: Install Devbox Stuff
52+
run: devbox install
53+
continue-on-error: true
54+
55+
- name: Cache node modules
56+
uses: actions/cache@v4
57+
with:
58+
path: builder-frontend/node_modules
59+
key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }}
60+
restore-keys: |
61+
${{ runner.os }}-node-
62+
63+
- name: Install frontend dependencies
64+
working-directory: builder-frontend
65+
run: devbox run install-builder-frontend-ci
66+
67+
- name: Run all Devbox services
68+
run: devbox run devbox services up
69+
continue-on-error: true
70+
71+
- uses: nev7n/wait_for_response@v1
72+
with:
73+
url: 'http://localhost:5173/'
74+
responseCode: 200
75+
timeout: 180000
76+
interval: 1000
77+
78+
# E2E Testing #
79+
- name: Install dependencies
80+
run: npm ci
81+
working-directory: e2e
82+
83+
- name: Install Playwright Browsers
84+
run: npx playwright install --with-deps
85+
working-directory: e2e
86+
87+
- name: Run Playwright tests
88+
run: npx playwright test
89+
working-directory: e2e
90+
91+
- uses: actions/upload-artifact@v4
92+
if: ${{ !cancelled() }}
93+
with:
94+
name: playwright-report
95+
path: e2e/playwright-report/
96+
retention-days: 30
97+
98+
# Devbox Cleanup #
99+
- name: Stop all Devbox services
100+
run: devbox services stop
101+
continue-on-error: true

e2e/.github/workflows/playwright.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

e2e/tests/example.spec.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { test, expect } from '@playwright/test';
22

33
test('has title', async ({ page }) => {
4-
await page.goto('https://playwright.dev/');
4+
await page.goto('http://localhost:5173/');
55

66
// Expect a title "to contain" a substring.
7-
await expect(page).toHaveTitle(/Playwright/);
7+
await expect(page).toHaveTitle(/Benefit Decision Toolkit/);
88
});
99

1010
test('get started link', async ({ page }) => {
11-
await page.goto('https://playwright.dev/');
11+
await page.goto('http://localhost:5173/');
1212

1313
// Click the get started link.
14-
await page.getByRole('link', { name: 'Get started' }).click();
15-
16-
// Expects page to have a heading with the name of Installation.
17-
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
14+
await page.getByRole('button', { name: "Continue with Google" });
1815
});

0 commit comments

Comments
 (0)