Skip to content

Commit b5e7d3a

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

File tree

3 files changed

+96
-34
lines changed

3 files changed

+96
-34
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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: 'Install devbox' # Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK
34+
uses: 'jetify-com/[email protected]'
35+
with:
36+
enable-cache: true
37+
38+
- id: 'auth' # Configure Workload Identity Federation and generate an access token
39+
name: 'Authenticate to Google Cloud'
40+
uses: 'google-github-actions/auth@v2'
41+
with:
42+
workload_identity_provider: '${{ env.WORKLOAD_IDENTITY_PROVIDER }}'
43+
service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
44+
project_id: ${{ env.PROJECT_ID }}
45+
46+
- name: Cache node modules
47+
uses: actions/cache@v4
48+
with:
49+
path: builder-frontend/node_modules
50+
key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }}
51+
restore-keys: |
52+
${{ runner.os }}-node-
53+
54+
- name: Install dependencies
55+
working-directory: builder-frontend
56+
run: devbox run install-builder-frontend-ci
57+
58+
- name: Run all Devbox services
59+
run: devbox services up -b
60+
continue-on-error: true
61+
62+
- uses: nev7n/wait_for_response@v1
63+
with:
64+
url: 'http://localhost:5173/'
65+
responseCode: 200
66+
timeout: 2000
67+
interval: 500
68+
69+
# E2E Testing #
70+
- name: Install dependencies
71+
run: npm ci
72+
working-directory: e2e
73+
74+
- name: Install Playwright Browsers
75+
run: npx playwright install --with-deps
76+
working-directory: e2e
77+
78+
- name: Run Playwright tests
79+
run: npx playwright test
80+
working-directory: e2e
81+
82+
- uses: actions/upload-artifact@v4
83+
if: ${{ !cancelled() }}
84+
with:
85+
name: playwright-report
86+
path: e2e/playwright-report/
87+
retention-days: 30
88+
89+
# Devbox Cleanup #
90+
- name: Stop all Devbox services
91+
run: devbox services stop
92+
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)