Skip to content

Commit 4a7169e

Browse files
committed
Add Run Regression Tests workflow
1 parent fc67ec3 commit 4a7169e

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

.github/workflows/cdk_release_code.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ on:
2727
LOG_LEVEL:
2828
required: true
2929
type: string
30+
RUN_REGRESSION_TESTS:
31+
type: boolean
32+
default: true
3033
MARK_JIRA_RELEASED:
3134
type: boolean
3235
default: false
@@ -176,3 +179,14 @@ jobs:
176179
git add _data/${{ inputs.TARGET_ENVIRONMENT }}_deployments.csv
177180
git commit -m 'update releases for ${{ inputs.TARGET_ENVIRONMENT }}'
178181
parallel --retries 10 --delay 3 ::: "git pull --rebase && git push"
182+
183+
regression_tests:
184+
name: Regression Tests
185+
uses: ./.github/workflows/run_regression_tests.yml
186+
if: ${{ always() && !failure() && !cancelled() && inputs.RUN_REGRESSION_TESTS == true }}
187+
needs: [release_code]
188+
with:
189+
ENVIRONMENT: ${{ inputs.TARGET_ENVIRONMENT }}
190+
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
191+
secrets:
192+
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
DEPLOY_CODE: true
7373
LOG_RETENTION_IN_DAYS: 30
7474
LOG_LEVEL: DEBUG
75+
RUN_REGRESSION_TESTS: true
7576
secrets:
7677
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
7778
CDK_PULL_IMAGE_ROLE: ${{ secrets.DEV_CDK_PULL_IMAGE_ROLE }}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Run Regression Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ENVIRONMENT:
7+
required: true
8+
type: string
9+
VERSION_NUMBER:
10+
required: true
11+
type: string
12+
REGRESSION_TESTS_PEM:
13+
type: string
14+
default: "false"
15+
secrets:
16+
REGRESSION_TESTS_PEM:
17+
required: true
18+
19+
jobs:
20+
run_regression_tests:
21+
runs-on: ubuntu-22.04
22+
permissions:
23+
id-token: write
24+
contents: write
25+
26+
steps:
27+
- name: Checkout local github actions
28+
uses: actions/checkout@v5
29+
with:
30+
ref: ${{ env.BRANCH_NAME }}
31+
fetch-depth: 0
32+
33+
- name: Generate a token to authenticate regression testing
34+
id: generate-token
35+
uses: actions/create-github-app-token@v2
36+
with:
37+
app-id: ${{ vars.REGRESSION_TESTS_APP_ID }}
38+
private-key: ${{ secrets.REGRESSION_TESTS_PEM }}
39+
owner: "NHSDigital"
40+
repositories: "electronic-prescription-service-api-regression-tests"
41+
42+
# using git commit sha for version of action to ensure we have stable version
43+
- name: Install asdf
44+
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
45+
with:
46+
asdf_branch: v0.11.3
47+
48+
- name: Cache asdf
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
~/.asdf
53+
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
54+
restore-keys: |
55+
${{ runner.os }}-asdf-
56+
57+
- name: Install asdf dependencies in .tool-versions
58+
uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
59+
with:
60+
asdf_branch: v0.11.3
61+
env:
62+
PYTHON_CONFIGURE_OPTS: --enable-shared
63+
64+
- name: Run Regression Testing
65+
working-directory: scripts
66+
env:
67+
TARGET_ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
68+
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
69+
GITHUB-TOKEN: ${{ steps.generate-token.outputs.token }}
70+
run: |
71+
if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then
72+
# this should be the tag of the tests you want to run
73+
REGRESSION_TEST_REPO_TAG=v3.4.0
74+
75+
# this should be the tag of the regression test workflow you want to run
76+
# This will normally be the same as REGRESSION_TEST_REPO_TAG
77+
REGRESSION_TEST_WORKFLOW_TAG=v3.4.0
78+
79+
curl https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/tags/${REGRESSION_TEST_WORKFLOW_TAG}/scripts/run_regression_tests.py -o run_regression_tests.py
80+
poetry install
81+
echo Running regression tests in the "$TARGET_ENVIRONMENT" environment
82+
poetry run python -u run_regression_tests.py \
83+
--env="$TARGET_ENVIRONMENT" \
84+
--pr_label="$VERSION_NUMBER" \
85+
--token=${{ steps.generate-token.outputs.token }} \
86+
--is_called_from_github=true \
87+
--product=EPS-ASSIST-ME \
88+
--regression_test_repo_tag "${REGRESSION_TEST_REPO_TAG}" \
89+
--regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}"
90+
fi

0 commit comments

Comments
 (0)