-
Notifications
You must be signed in to change notification settings - Fork 1
174 lines (156 loc) · 5.6 KB
/
regression_tests.yml
File metadata and controls
174 lines (156 loc) · 5.6 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
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
172
173
174
name: Regression Tests
concurrency:
group: ${{ github.workflow }}
on:
workflow_call:
inputs:
environment:
description: "Environment to run tests against"
type: string
required: false
default: "dev"
tags:
description: "Test scenario tags. If you want to specify multiple tags, you should separate them with a colon :"
required: false
type: string
default: "@regression"
log_level:
description: "Log level to output to console"
type: string
required: false
default: "INFO"
id:
description: "Run identifier (Don't change - Only used for CI)"
type: string
required: false
default: "Run during opened pull request"
github_tag:
description: "The github tag to run the test pack from"
type: string
required: true
workflow_dispatch:
inputs:
tags:
description: "Test scenario tags. If you want to specify multiple tags, you should separate them with a colon :"
required: false
type: string
default: "@regression"
environment:
description: "Environment to run tests against"
type: environment
required: true
default: "dev"
log_level:
description: "Log level to output to console"
type: choice
options: ["INFO", "DEBUG"]
required: false
default: "INFO"
id:
description: "Run identifier (Don't change - Only used for CI)"
required: true
default: "Manually Triggered Run"
github_tag:
description: "The github tag to run the test pack from"
required: true
default: "main"
jobs:
regression_tests:
permissions:
id-token: write
issues: write
pull-requests: write
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
steps:
- name: Verify caller repository
run: |
ALLOWED_REPOS=("NHSDigital/eligibility-signposting-api")
CALLER_REPO="${{ github.repository }}"
# If triggered by workflow_call, the calling repo is in github.repository
# If triggered manually, it's this repo itself which is allowed
if [[ "${{ github.event_name }}" == "workflow_call" ]]; then
CALLER_REPO="${{ github.event.workflow_run.repository.full_name || github.repository }}"
fi
ALLOWED=false
for repo in "${ALLOWED_REPOS[@]}"; do
if [[ "$CALLER_REPO" == "$repo" ]]; then
ALLOWED=true
break
fi
done
if [[ "$ALLOWED" == "false" && "${{ github.event_name }}" == "workflow_call" ]]; then
echo "Error: Repository $CALLER_REPO is not allowed to trigger this workflow"
exit 1
fi
echo "Workflow triggered by allowed repository: $CALLER_REPO"
- name: show_input_parameters
env:
tags: ${{ inputs.tags }}
environment: ${{ inputs.environment }}
log_level: ${{ inputs.log_level }}
id: ${{ inputs.id }}
github_tag: ${{ inputs.github_tag }}
run: |
echo "tags: ${tags}"
echo "environment: ${environment}"
echo "log_level: ${log_level}"
echo "id: ${id}"
echo "github_tag: ${github_tag}"
# output to summary
# shellcheck disable=SC2129
echo "tags: ${tags}" >> "$GITHUB_STEP_SUMMARY"
echo "environment: ${environment}" >> "$GITHUB_STEP_SUMMARY"
echo "log_level: ${log_level}" >> "$GITHUB_STEP_SUMMARY"
echo "id: ${id}" >> "$GITHUB_STEP_SUMMARY"
echo "github_tag: ${github_tag}" >> "$GITHUB_STEP_SUMMARY"
- name: ${{github.event.inputs.id}}
env:
ID: ${{github.event.inputs.id}}
ENV: ${{ inputs.environment }}
run: |
echo run identifier "$ID"-"$ENV"
echo run identifier "$ID"-"$ENV" >> "$GITHUB_STEP_SUMMARY"
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ inputs.github_tag }}
# using git commit sha for version of action to ensure we have stable version
- name: Install asdf
uses: asdf-vm/actions/setup@b7bcd026f18772e44fe1026d729e1611cc435d47
with:
asdf_version: 0.18.0
- name: Cache asdf
uses: actions/cache@v5
with:
path: |
~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
- name: Install asdf dependencies in .tool-versions
uses: asdf-vm/actions/install@b7bcd026f18772e44fe1026d729e1611cc435d47
with:
asdf_version: 0.18.0
env:
PYTHON_CONFIGURE_OPTS: --enable-shared
- name: Cache Virtualenv
uses: actions/cache@v5
id: cache-venv
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
- name: Install Dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: make install-python
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v6.1.0
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/Eligibility-Signposting-API-E2E-Regression-Tests
aws-region: eu-west-2
- name: Regression Tests
id: tests
env:
ENVIRONMENT: ${{ inputs.environment }}
LOG_LEVEL: ${{ inputs.log_level }}
INPUT_TAG: ${{ inputs.tags }}
run: |
make run-tests env="$ENVIRONMENT" log_level="$LOG_LEVEL"