-
Notifications
You must be signed in to change notification settings - Fork 5
144 lines (121 loc) · 4.12 KB
/
run-e2e-tests.yml
File metadata and controls
144 lines (121 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Run E2E Tests
on:
push:
branches: [main]
paths:
- "builder-frontend/**"
- "builder-api/**"
- "library-api/**"
pull_request:
branches: [main]
paths:
- "builder-frontend/**"
- "builder-api/**"
- "library-api/**"
env:
PROJECT_ID: "benefit-decision-toolkit-play"
WORKLOAD_IDENTITY_PROVIDER: "projects/1034049717668/locations/global/workloadIdentityPools/github-actions-google-cloud/providers/github"
jobs:
run-e2e-tests:
runs-on: "ubuntu-latest"
# Add these permissions for Workload Identity Federation
permissions:
contents: read
id-token: write
steps:
# Bootstrapping #
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Load ENV files from examples
run: |
mv builder-frontend/.env.example builder-frontend/.env
mv builder-api/.env.example builder-api/.env
mv .env.example .env
# 1) Devbox Setup #
- name: Setup devbox
uses: ./.github/actions/devbox-setup
# 2) Prepare app dependencies #
- name: "Cache Maven dependencies"
# Cache Maven dependencies to speed up builds
uses: "actions/cache@v4"
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('builder-api/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('builder-api/pom.xml') }}
- id: "auth" # Configure Workload Identity Federation and generate an access token
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "${{ env.WORKLOAD_IDENTITY_PROVIDER }}"
service_account: cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
project_id: ${{ env.PROJECT_ID }}
- name: Cache node modules
uses: actions/cache@v4
with:
path: builder-frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('builder-frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies
working-directory: builder-frontend
run: devbox run install-builder-frontend-ci
- name: Load E2E emulator data
run: |
rm -rf emulator-data
cp -r e2e/e2e-emulator-data emulator-data
# 3) Run App + E2E Test #
- name: Run all Devbox services
run: devbox services up -b
continue-on-error: true
- name: Install Playwright dependencies
run: npm ci
working-directory: e2e
- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: e2e
- name: Run a bash command and print output
run: |
echo "Listing devbox processes:"
devbox services ls
shell: bash
- name: Wait for App to be available
uses: nev7n/wait_for_response@v1
with:
url: "http://localhost:5173/"
responseCode: 200
timeout: 60000
interval: 1000
continue-on-error: true
- name: Run a bash command and print output
run: |
echo "Listing devbox processes:"
devbox services ls
shell: bash
- name: Run a bash command and print output
run: |
echo "Listing devbox processes:"
tail -n 100 /tmp/process-compose-${{ env.USER }}.log
shell: bash
- name: Run Playwright tests
run: npx playwright test
working-directory: e2e
continue-on-error: true
- name: Run a bash command and print output
run: |
echo "Listing devbox processes:"
devbox services ls
shell: bash
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 30
# 4) Cleanup #
- name: Stop all Devbox services
run: devbox services stop
continue-on-error: true