-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (117 loc) · 3.71 KB
/
run-e2e-tests.yml
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
name: Run E2E Test Suite
run-name: Run E2E Test Suite on ${{ inputs.environment }}
on:
workflow_dispatch:
inputs:
environment:
description: The environment to run the E2E tests on
default: 'Development'
type: choice
options:
- 'Development'
- 'Test'
- 'Test2'
- 'Pre-production'
workflow_call:
inputs:
environment:
required: true
type: string
permissions:
id-token: write
contents: read
jobs:
pre-test-teardown:
name: Pre-Test Database Teardown
uses: ./.github/workflows/e2e-seed-database.yml
with:
environment: ${{ inputs.environment }}
action: 'Teardown'
secrets: inherit
pre-test-setup:
needs: [ pre-test-teardown ]
name: Pre-Test Database Setup
uses: ./.github/workflows/e2e-seed-database.yml
with:
environment: ${{ inputs.environment }}
action: 'Setup'
secrets: inherit
run-test-suite:
needs: [ pre-test-setup ]
name: ${{ matrix.job_name }}
strategy:
fail-fast: false
matrix:
suite: [ find-e2e-tests, manage-e2e-tests ]
include:
- suite: find-e2e-tests
job_name: E2E - Find UI
base_url: ${{ vars.PLAYWRIGHT_FIND_BASE_URL }}
- suite: manage-e2e-tests
job_name: E2E - Manage UI
base_url: ${{ vars.PLAYWRIGHT_MANAGE_BASE_URL }}
runs-on: ubuntu-24.04
environment: ${{ inputs.environment }}
defaults:
run:
working-directory: "test/${{ matrix.suite }}"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: "lts/Jod" # 22 LTS
- name: Install NPM Packages
shell: bash
run: npm i
- name: Install Playwright Dependencies
shell: bash
run: npx playwright install-deps
- name: Get Playwright Version
id: playwright-version
shell: bash
run: |
ARRAY=($(npx playwright --version))
VERSION=${ARRAY[1]}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Playwright Browser Cache
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-PlayWright-${{ steps.playwright-version.outputs.VERSION }}
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: npx playwright install
- name: Create Environment Variables
shell: bash
run: |
cat <<'EOF' > .env
BASE_URL='${{ vars.PLAYWRIGHT_ENVIRONMENT_PREFIX }}${{ matrix.base_url }}'
USER_NAME='${{ secrets.PLAYWRIGHT_USER_NAME }}'
PASSWORD='${{ secrets.PLAYWRIGHT_PASSWORD }}'
DFE_ADMIN_USER='${{ secrets.PLAYWRIGHT_GOVLOGIN_DFE_ADMIN_USER }}'
GOV_LOGIN_PASSWORD='${{ secrets.PLAYWRIGHT_GOVLOGIN_PASSWORD }}'
EOF
- name: Run Playwright Test Suite
shell: bash
run: npx playwright test
- name: Upload Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.suite }}
path: "**/playwright-report/"
# Intentionally doesn't run after test failure to facilitate analysis
post-test-teardown:
needs: [ run-test-suite ]
name: Post-Test Database Teardown
uses: ./.github/workflows/e2e-seed-database.yml
with:
environment: ${{ inputs.environment }}
action: 'Teardown'
secrets: inherit