Skip to content

Commit 0ef41f5

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

File tree

3 files changed

+101
-34
lines changed

3 files changed

+101
-34
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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: Rename env files
59+
run: |
60+
mv builder-frontend/.env.example builder-frontend/.env
61+
mv builder-api/.env.example e2e/.env
62+
63+
- name: Run all Devbox services
64+
run: devbox services up
65+
continue-on-error: true
66+
67+
- uses: nev7n/wait_for_response@v1
68+
with:
69+
url: 'http://localhost:5173/'
70+
responseCode: 200
71+
timeout: 180000
72+
interval: 1000
73+
74+
# E2E Testing #
75+
- name: Install dependencies
76+
run: npm ci
77+
working-directory: e2e
78+
79+
- name: Install Playwright Browsers
80+
run: npx playwright install --with-deps
81+
working-directory: e2e
82+
83+
- name: Run Playwright tests
84+
run: npx playwright test
85+
working-directory: e2e
86+
87+
- uses: actions/upload-artifact@v4
88+
if: ${{ !cancelled() }}
89+
with:
90+
name: playwright-report
91+
path: e2e/playwright-report/
92+
retention-days: 30
93+
94+
# Devbox Cleanup #
95+
- name: Stop all Devbox services
96+
run: devbox services stop
97+
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)