1- name : Run e2e Tests
1+ name : FHIR API and Batch Automation - E2E Tests
22
33on :
44 workflow_call :
1212 sub_environment :
1313 required : true
1414 type : string
15+ service_under_test :
16+ required : true
17+ type : string
18+ suite_to_run :
19+ required : true
20+ type : string
1521 secrets :
1622 APIGEE_PASSWORD :
1723 required : true
1824 APIGEE_BASIC_AUTH_TOKEN :
1925 required : true
2026 APIGEE_OTP_KEY :
2127 required : true
28+ CIS2_E2E_USERNAME :
29+ required : true
2230 STATUS_API_KEY :
2331 required : true
2432 workflow_dispatch :
3341 - internal-qa
3442 - int
3543 - ref
36- - prod
3744 environment :
3845 type : string
3946 description : Select the backend environment
4047 options :
4148 - dev
4249 - preprod
43- - prod
4450 sub_environment :
4551 type : string
4652 description : Set the sub environment name e.g. pr-xxx, or green/blue in higher environments
53+ service_under_test :
54+ description : Select the service you want to test
55+ required : true
56+ type : choice
57+ options :
58+ - fhir_api
59+ - batch
60+ - all
61+ suite_to_run :
62+ description : Select the suite you would like to run
63+ default : " functional"
64+ type : choice
65+ options :
66+ - smoke
67+ - functional
68+ - sandbox
69+ - proxy_smoke
4770
4871env :
72+ APIGEE_AUTH_ENV : ${{ inputs.apigee_environment == 'int' && inputs.apigee_environment || 'internal-dev' }}
4973 APIGEE_ENVIRONMENT : ${{ inputs.apigee_environment }}
5074 ENVIRONMENT : ${{ inputs.environment }}
5175 SUB_ENVIRONMENT : ${{ inputs.sub_environment }}
6084 contents : read
6185 runs-on : ubuntu-latest
6286 environment : ${{ inputs.apigee_environment }}
63- outputs :
64- # Workaround for environment-level variables being unavailable in `jobs.<job-id>.if`.
65- RUN_BATCH_E2E_TESTS : ${{ vars.RUN_BATCH_E2E_TESTS }}
6687 steps :
6788 - name : Wait for API to be available
89+ if : github.event_name != 'workflow_dispatch'
6890 run : |
6991 endpoint=""
7092 if [[ ${APIGEE_ENVIRONMENT} =~ "prod" ]]; then
@@ -106,16 +128,18 @@ jobs:
106128 exit 1
107129 fi
108130
109- e2e-tests :
131+ e2e-automation- tests :
110132 permissions :
111133 id-token : write
112- contents : read
134+ checks : write
135+ contents : write
113136 runs-on : ubuntu-latest
114137 needs : [wait-for-deployment]
115138 environment : ${{ inputs.apigee_environment }}
116139 env :
117140 APIGEE_USERNAME : ${{ vars.APIGEE_USERNAME }}
118- TF_OUTPUTS_REQUIRED : ${{ vars.RUN_FULL_E2E_TESTS == 'true' || vars.RUN_PROXY_E2E_TESTS == 'true' }}
141+ TF_OUTPUTS_REQUIRED : ${{ inputs.suite_to_run != 'sandbox' }}
142+
119143 steps :
120144 - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
121145
@@ -146,11 +170,7 @@ jobs:
146170 if : ${{ env.TF_OUTPUTS_REQUIRED == 'true' }}
147171 working-directory : infrastructure/instance
148172 run : |
149- echo "IMMS_DELTA_TABLE_NAME=$(make -s output name=imms_delta_table_name)" >> $GITHUB_ENV
150173 echo "AWS_DOMAIN_NAME=$(make -s output name=service_domain_name)" >> $GITHUB_ENV
151- echo "DYNAMODB_TABLE_NAME=$(make -s output name=dynamodb_table_name)" >> $GITHUB_ENV
152- echo "AWS_SQS_QUEUE_NAME=$(make -s output name=aws_sqs_queue_name)" >> $GITHUB_ENV
153- echo "AWS_SNS_TOPIC_NAME=$(make -s output name=aws_sns_topic_name)" >> $GITHUB_ENV
154174
155175 - name : Install poetry
156176 run : pip install poetry==2.1.4
@@ -159,21 +179,21 @@ jobs:
159179 with :
160180 python-version : 3.11
161181 cache : " poetry"
162- cache-dependency-path : tests/e2e /poetry.lock
182+ cache-dependency-path : tests/e2e_automation /poetry.lock
163183
164184 - name : Install e2e test dependencies
165- working-directory : tests/e2e
185+ working-directory : tests/e2e_automation
166186 run : poetry install --no-root
167187
168188 - name : Get Apigee access token
169- if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
170- working-directory : tests/e2e
189+ if : inputs.apigee_environment != 'int'
190+ working-directory : tests/e2e_automation
171191 env :
172192 APIGEE_PASSWORD : ${{ secrets.APIGEE_PASSWORD }}
173193 APIGEE_BASIC_AUTH_TOKEN : ${{ secrets.APIGEE_BASIC_AUTH_TOKEN }}
174194 APIGEE_OTP_KEY : ${{ secrets.APIGEE_OTP_KEY }}
175195 run : |
176- CODE=$(poetry run python utils /compute_totp_code.py "$APIGEE_OTP_KEY")
196+ CODE=$(poetry run python utilities /compute_totp_code.py "$APIGEE_OTP_KEY")
177197 echo "::add-mask::$CODE"
178198
179199 echo "Requesting access token from Apigee..."
@@ -187,55 +207,73 @@ jobs:
187207 echo "::add-mask::$token"
188208 echo "APIGEE_ACCESS_TOKEN=$token" >> $GITHUB_ENV
189209
190- - name : Run proxy e2e test suite
191- if : ${{ vars.RUN_PROXY_E2E_TESTS == 'true' }}
192- working-directory : tests/e2e
193- run : poetry run python -m unittest test_proxy
194-
195- - name : Run sandbox e2e test suite
196- if : ${{ vars.RUN_SANDBOX_E2E_TESTS == 'true' }}
197- working-directory : tests/e2e
198- run : poetry run python -m unittest test_proxy.TestProxyHealthcheck
199-
200- - name : Run full e2e test suite
201- if : ${{ vars.RUN_FULL_E2E_TESTS == 'true' }}
202- working-directory : tests/e2e
203- run : poetry run python -m unittest
204-
205- batch-e2e-tests :
206- permissions :
207- id-token : write
208- contents : read
209- needs : [wait-for-deployment, e2e-tests]
210- # Only actually depend on wait-for-deployment, but run after e2e-tests
211- if : ${{ !cancelled() && needs.wait-for-deployment.result == 'success' && needs.wait-for-deployment.outputs.RUN_BATCH_E2E_TESTS == 'true' }}
212- runs-on : ubuntu-latest
213- environment : ${{ inputs.apigee_environment }}
214- steps :
215- - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
210+ - name : Run Pytest-BDD ${{ inputs.service_under_test }} tests with the ${{ inputs.suite_to_run }} filter
211+ working-directory : tests/e2e_automation
212+ env :
213+ S3_env : ${{ inputs.sub_environment }}
214+ auth_url : https://${{ env.APIGEE_AUTH_ENV }}.api.service.nhs.uk/oauth2-mock/authorize
215+ token_url : https://${{ env.APIGEE_AUTH_ENV }}.api.service.nhs.uk/oauth2-mock/token
216+ baseUrl : https://${{ inputs.apigee_environment }}.api.service.nhs.uk/${{env.SERVICE_BASE_PATH}}
217+ callback_url : " https://oauth.pstmn.io/v1/callback"
218+ username : ${{ secrets.CIS2_E2E_USERNAME }}
219+ scope : " nhs-cis2"
220+ USE_STATIC_APPS : ${{ inputs.apigee_environment == 'int' && 'True' || 'False' }}
221+ Postman_Auth_client_Id : ${{ secrets.Postman_Auth_client_Id }} # The following static app values are only needed in INT
222+ Postman_Auth_client_Secret : ${{ secrets.Postman_Auth_client_Secret }}
223+ RAVS_client_Id : ${{ secrets.RAVS_client_Id }}
224+ RAVS_client_Secret : ${{ secrets.RAVS_client_Secret }}
225+ MAVIS_client_Id : ${{ secrets.MAVIS_client_Id }}
226+ MAVIS_client_Secret : ${{ secrets.MAVIS_client_Secret }}
227+ EMIS_client_Id : ${{ secrets.OPTUM_client_Id }}
228+ EMIS_client_Secret : ${{ secrets.OPTUM_client_Secret }}
229+ TPP_client_Id : ${{ secrets.TPP_client_Id }}
230+ TPP_client_Secret : ${{ secrets.TPP_client_Secret }}
231+ SONAR_client_Id : ${{ secrets.SONAR_client_Id }}
232+ SONAR_client_Secret : ${{ secrets.SONAR_client_Secret }}
233+ MEDICUS_client_Id : ${{ secrets.MEDICUS_client_Id }}
234+ MEDICUS_client_Secret : ${{ secrets.MEDICUS_client_Secret }}
235+ aws_token_refresh : " False"
236+ TEST_PATH : ${{ inputs.service_under_test == 'batch' && 'features/batchTests' || inputs.service_under_test == 'fhir_api' && 'features/APITests' || 'features' }}
237+ TEST_FILTER : ${{ inputs.suite_to_run == 'proxy_smoke' && 'Status_feature' || inputs.suite_to_run }}
238+ run : poetry run pytest "$TEST_PATH" -m "$TEST_FILTER" --junitxml=output/test-results.xml --alluredir=output/allure-results
216239
217- - name : Connect to AWS
218- uses : aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708
240+ - uses : dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5
241+ if : always()
219242 with :
220- aws-region : eu-west-2
221- role-to-assume : arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/auto-ops
222- role-session-name : github-actions
243+ name : BDD Test Summary
244+ path : " **/output/test-results.xml"
245+ reporter : java-junit
246+ fail-on-error : false
223247
224- - name : Install poetry
225- run : pip install poetry==2.1.4
248+ - name : Load test report history
249+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
250+ if : always()
251+ continue-on-error : true
252+ with :
253+ ref : gh-pages
254+ path : gh-pages
226255
227- - uses : actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
256+ - name : Build Allure report
257+ if : always()
258+ uses : simple-elf/allure-report-action@53ebb757a2097edc77c53ecef4d454fc2f2f774c
228259 with :
229- python-version : 3.11
230- cache : " poetry"
231- cache-dependency-path : tests/e2e_batch/poetry.lock
260+ allure_results : tests/e2e_automation/output/allure-results
261+ gh_pages : gh-pages
262+ allure_report : allure-report
263+ allure_history : allure-history
232264
233- - name : Install e2e test dependencies
234- working-directory : tests/e2e_batch
235- run : poetry install --no-root
265+ - name : Publish Allure report to GitHub Pages
266+ if : always()
267+ uses : peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847
268+ with :
269+ github_token : ${{ secrets.GITHUB_TOKEN }}
270+ publish_branch : gh-pages
271+ publish_dir : allure-history
236272
237- - name : Run batch e2e test suite
238- working-directory : tests/e2e_batch
239- env :
240- ENVIRONMENT : ${{ inputs.sub_environment }}
241- run : poetry run python -m unittest -c -v
273+ - name : Add link to Allure report
274+ if : always()
275+ uses : actions/github-script@v6
276+ with :
277+ script : |
278+ const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/`;
279+ core.summary.addHeading('Allure Report').addLink('View Report', url).write();
0 commit comments