-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (92 loc) · 4.22 KB
/
run_regression_tests.yml
File metadata and controls
104 lines (92 loc) · 4.22 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
name: Run Regression Tests
on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
VERSION_NUMBER:
required: true
type: string
REGRESSION_TESTS_PEM:
type: string
default: false
secrets:
REGRESSION_TESTS_PEM:
required: true
jobs:
run_regression_tests:
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: write
steps:
- name: Checkout local github actions
uses: actions/checkout@v5
with:
ref: ${{ env.BRANCH_NAME }}
fetch-depth: 0
- name: Generate a token to authenticate regression testing
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.REGRESSION_TESTS_APP_ID }}
private-key: ${{ secrets.REGRESSION_TESTS_PEM }}
owner: "NHSDigital"
repositories: "electronic-prescription-service-api-regression-tests"
# using git commit sha for version of action to ensure we have stable version
- name: Install asdf
uses: asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
with:
asdf_branch: v0.11.3
- 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@1902764435ca0dd2f3388eea723a4f92a4eb8302
with:
asdf_branch: v0.11.3
env:
PYTHON_CONFIGURE_OPTS: --enable-shared
- name: Run Regression Testing
working-directory: scripts
env:
TARGET_ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
VERSION_NUMBER: ${{ inputs.VERSION_NUMBER }}
GITHUB-TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
if [[ "$TARGET_ENVIRONMENT" != "prod" && "$TARGET_ENVIRONMENT" != "ref" ]]; then
REGRESSION_TEST_REPO_TAG="v3.4.12" # This is the tag or branch of the regression test code to run, usually a version tag like v3.1.0 or a branch name
REGRESSION_TEST_WORKFLOW_TAG="v3.4.12" # This is the tag of the github workflow to run, usually the same as REGRESSION_TEST_REPO_TAG
if [[ -z "$REGRESSION_TEST_REPO_TAG" || -z "$REGRESSION_TEST_WORKFLOW_TAG" ]]; then
echo "Error: One or both tag variables are not set" >&2
exit 1
fi
# HELPER IF STATEMENT - It will automatically determine the correct Git URL to use based on the REGRESSION_TEST_WORKFLOW_TAG value
if [[ "$REGRESSION_TEST_WORKFLOW_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "REGRESSION_TEST_WORKFLOW_TAG is a version tag, using tag link"
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
else
echo "REGRESSION_TEST_WORKFLOW_TAG doesn't look like a version tag, using branch link"
curl "https://raw.githubusercontent.com/NHSDigital/electronic-prescription-service-api-regression-tests/refs/heads/${REGRESSION_TEST_REPO_TAG}/scripts/run_regression_tests.py" -o run_regression_tests.py
fi
if [[ ! -f run_regression_tests.py ]]; then
echo "Error: run_regression_tests.py not found" >&2
exit 1
fi
poetry install
echo Running regression tests in the "$TARGET_ENVIRONMENT" environment
poetry run python -u run_regression_tests.py \
--env="$TARGET_ENVIRONMENT" \
--pr_label="$VERSION_NUMBER" \
--token=${{ steps.generate-token.outputs.token }} \
--is_called_from_github=true \
--product=CPTS-UI \
--regression_test_repo_tag "${REGRESSION_TEST_REPO_TAG}" \
--regression_test_workflow_tag "${REGRESSION_TEST_WORKFLOW_TAG}"
fi