-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (159 loc) · 6.25 KB
/
regression_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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Regression Tests
on:
workflow_dispatch:
inputs:
tags:
description: 'Test scenario tags'
required: true
type: string
default: "@regression"
environment:
description: 'Environment to run tests against'
type: environment
required: true
default: "DEV"
product:
description: 'The product we are testing'
type: choice
options:
- CPTS-UI
- EPS-FHIR
- EPS-FHIR-PRESCRIBING
- EPS-FHIR-DISPENSING
- PFP-APIGEE
- PFP-AWS
- PSU
required: false
default: EPS-FHIR
id:
description: 'Unique run identifier (Do not change this)'
required: false
default: "Manually Triggered Run"
pull_request_id:
description: 'The ID of the pull request. This should be in the format pr-xxxx where xxxx is the pull request id'
required: false
default: ""
github_tag:
description: 'The github tag to run the test pack from'
required: false
default: "main"
run_sha1_tests:
description: whether to also run against a sha1 enabled apigee app
required: false
type: boolean
default: false
jobs:
regression_tests:
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
ref: ${{ inputs.github_tag }}
- name: ${{github.event.inputs.id}}
env:
ID: ${{github.event.inputs.id}}
ENV: ${{ inputs.environment }}
PRODUCT: ${{ inputs.product }}
PULL_REQUEST_ID: ${{ inputs.pull_request_id }}
run: |
echo run identifier "$ID"-"$PRODUCT"-"$ENV"-"$PULL_REQUEST_ID"
echo run identifier "$ID"-"$PRODUCT"-"$ENV"-"$PULL_REQUEST_ID" >> "$GITHUB_STEP_SUMMARY"
# using git commit sha for version of action to ensure we have stable version
- name: Install asdf
uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
- name: Cache asdf
uses: actions/cache@v4
with:
path: |
~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-
- name: Install asdf dependencies in .tool-versions
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
env:
PYTHON_CONFIGURE_OPTS: --enable-shared
- name: Cache Virtualenv
uses: actions/cache@v4
id: cache-venv
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-venv-
- name: Install Dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: make install
- name: Regression Tests
id: tests
continue-on-error: true
env:
PRODUCT: ${{ inputs.product }}
ENVIRONMENT: ${{ inputs.environment }}
PULL_REQUEST_ID: ${{ inputs.pull_request_id }}
TAGS: ${{ inputs.tags }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
JWT_KID: ${{ secrets.JWT_KID }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
run: |
export CLIENT_ID="$CLIENT_ID"
export CLIENT_SECRET="$CLIENT_SECRET"
export CERTIFICATE="$CERTIFICATE"
export PRIVATE_KEY="$PRIVATE_KEY"
export JWT_KID="$JWT_KID"
export JWT_PRIVATE_KEY="$JWT_PRIVATE_KEY"
export PULL_REQUEST_ID="$PULL_REQUEST_ID"
echo Pull request ID = "$PULL_REQUEST_ID"
poetry run python ./runner.py --env="$ENVIRONMENT" --product="$PRODUCT" --tags="$TAGS"
- name: SHA1 Regression Tests
id: sha1_tests
continue-on-error: true
if: inputs.run_sha1_tests == true
env:
PRODUCT: ${{ inputs.product }}
ENVIRONMENT: ${{ inputs.environment }}
PULL_REQUEST_ID: ${{ inputs.pull_request_id }}
TAGS: ${{ inputs.tags }}
CLIENT_ID: ${{ secrets.SHA1_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.SHA1_CLIENT_SECRET }}
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
JWT_KID: ${{ secrets.JWT_KID }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
run: |
export CLIENT_ID="$CLIENT_ID"
export CLIENT_SECRET="$CLIENT_SECRET"
export CERTIFICATE="$CERTIFICATE"
export PRIVATE_KEY="$PRIVATE_KEY"
export JWT_KID="$JWT_KID"
export JWT_PRIVATE_KEY="$JWT_PRIVATE_KEY"
export PULL_REQUEST_ID="$PULL_REQUEST_ID"
echo Pull request ID = "$PULL_REQUEST_ID"
poetry run python ./runner.py --env="$ENVIRONMENT" --product="$PRODUCT" --tags="$TAGS"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: allure-results
path: allure-results
if-no-files-found: error
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.REGRESSION_TESTS_APP_ID }}
private-key: ${{ secrets.REGRESSION_TESTS_PEM }}
owner: "NHSDigital"
repositories: "electronic-prescription-service-api-regression-tests,eps-test-reports"
- name: Report failure on test failure
if: steps.tests.outcome != 'success' || ( steps.sha1_tests.outcome != 'success' && steps.sha1_tests.outcome != 'skipped' )
run: |
poetry run python scripts/send_test_results.py --token=${{ steps.generate-token.outputs.token }} --run_id ${{GITHUB.RUN_ID}}
echo The regression tests step failed, this likely means there are test failures.
echo A test report will be generated shortly and can be viewed at: https://nhsdigital.github.io/eps-test-reports
exit 1