@@ -2,6 +2,18 @@ name: Regression test run
22
33on :
44 workflow_call :
5+ inputs :
6+ github_ref :
7+ description : The git reference for deploying containerized mavis application
8+ type : string
9+ required : false
10+ secrets :
11+ HTTP_AUTH_TOKEN_FOR_TESTS :
12+ description : HTTP Basic Auth token for the environment under test
13+ required : true
14+ MAVIS_TESTING_REPO_ACCESS_TOKEN :
15+ description : Access token for the manage-vaccinations-in-schools-testing repository
16+ required : true
517
618permissions : { }
719
3749 id-token : write
3850 steps :
3951 - name : Checkout code
40- uses : actions/checkout@v5
52+ uses : actions/checkout@v6
53+ with :
54+ ref : ${{ inputs.github_ref || github.ref }}
4155 - name : Configure AWS Credentials
4256 uses : aws-actions/configure-aws-credentials@v5
4357 with :
@@ -71,19 +85,26 @@ jobs:
7185 with :
7286 role-to-assume : arn:aws:iam::393416225559:role/GitHubAssuranceTestRole
7387 aws-region : eu-west-2
74- - name : Render task definition
75- id : render-task-definition
88+ - name : Render task definition 1
89+ id : render-task-definition-1
7690 uses : aws-actions/amazon-ecs-render-task-definition@v1
7791 with :
7892 task-definition-family : " assurance-testing-regression-task-definition-template"
79- container-name : " mavis-regression"
93+ container-name : " mavis-regression-web"
94+ image : " 393416225559.dkr.ecr.eu-west-2.amazonaws.com/mavis/regression:${{ github.sha }}"
95+ - name : Render task definition 2
96+ id : render-task-definition-2
97+ uses : aws-actions/amazon-ecs-render-task-definition@v1
98+ with :
99+ task-definition : ${{ steps.render-task-definition-1.outputs.task-definition }}
100+ container-name : " mavis-regression-sidekiq"
80101 image : " 393416225559.dkr.ecr.eu-west-2.amazonaws.com/mavis/regression:${{ github.sha }}"
81102 - name : Prepare deployment
82103 id : prepare-deployment
83104 run : |
84105 file_path="assurance-testing-regression-task-definition.json"
85106 family_name="assurance-testing-regression-task-definition"
86- echo "$(jq --arg f "$family_name" '.family = $f' "${{ steps.render-task-definition.outputs.task-definition }}")" > "$file_path"
107+ echo "$(jq --arg f "$family_name" '.family = $f' "${{ steps.render-task-definition-2 .outputs.task-definition }}")" > "$file_path"
87108 cat "$file_path" #TODO: Debugging, remove later
88109
89110 subnet_id=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=assurance-testing-subnet --query 'Subnets[0].SubnetId' --output text)
@@ -176,9 +197,12 @@ jobs:
176197 run : |
177198 TASK_ARN=$(echo '${{ needs.launch-dockerized-devimage.outputs.run_task_arn }}' | jq -r '.[0]')
178199 TASK_ID=$(sed 's:^.*/::' <<< $TASK_ARN)
179- CLOUDWATCH_URL="https://eu-west-2.console.aws.amazon.com/cloudwatch/home?region=eu-west-2#logsV2:log-groups/log-group/assurance-testing-ecs/log-events/assurance-testing-logs\$252Fmavis-regression\$252F${TASK_ID}\$3Fstart\$3D$(date +%s)000\$26end\$3D$(date -d '+30 minutes' +%s)000"
200+ WEB_CLOUDWATCH_URL="https://eu-west-2.console.aws.amazon.com/cloudwatch/home?region=eu-west-2#logsV2:log-groups/log-group/assurance-testing-ecs/log-events/assurance-testing-logs\$252Fmavis-regression-web\$252F${TASK_ID}\$3Fstart\$3D$(date +%s)000\$26end\$3D$(date -d '+30 minutes' +%s)000"
201+ SIDEKIQ_CLOUDWATCH_URL="https://eu-west-2.console.aws.amazon.com/cloudwatch/home?region=eu-west-2#logsV2:log-groups/log-group/assurance-testing-ecs/log-events/assurance-testing-logs\$252Fmavis-regression-sidekiq\$252F${TASK_ID}\$3Fstart\$3D$(date +%s)000\$26end\$3D$(date -d '+30 minutes' +%s)000"
180202 echo "**Task ID:** $TASK_ID" >> $GITHUB_STEP_SUMMARY
181- echo "**Container Logs:** $CLOUDWATCH_URL" >> $GITHUB_STEP_SUMMARY
203+ echo "**Container Logs:** " >> $GITHUB_STEP_SUMMARY
204+ echo " * WEB logs: $WEB_CLOUDWATCH_URL" >> $GITHUB_STEP_SUMMARY
205+ echo " * SIDEKIQ logs: $SIDEKIQ_CLOUDWATCH_URL" >> $GITHUB_STEP_SUMMARY
182206 NETWORK_INTERFACE=$(aws ecs describe-tasks \
183207 --cluster assurance-testing \
184208 --tasks "$TASK_ARN" \
@@ -190,30 +214,39 @@ jobs:
190214 echo "container_ip=$CONTAINER_IP" >> $GITHUB_OUTPUT
191215 echo "task_arn=$TASK_ARN" >> $GITHUB_OUTPUT
192216 echo "Started task: $TASK_ARN"
193- echo "Logs for server: ${CLOUDWATCH_URL}"
217+ echo "Logs for server: [web](${WEB_CLOUDWATCH_URL}) and [sidekiq](${SIDEKIQ_CLOUDWATCH_URL})"
218+ find-correct-test-branch :
219+ needs : [wait-for-task-stability]
220+ if : ${{ !cancelled() && needs.wait-for-task-stability.result == 'success'}}
221+ runs-on : ubuntu-latest
222+ permissions :
223+ contents : read
224+ outputs :
225+ test_branch : ${{ steps.check-branch.outputs.test_branch }}
226+ steps :
227+ - name : Check if branch exists
228+ id : check-branch
229+ run : |
230+ if git ls-remote --exit-code --heads https://github.com/NHSDigital/manage-vaccinations-in-schools-testing.git "$BRANCH_TO_CHECK" > /dev/null 2>&1; then
231+ echo "test_branch=$BRANCH_TO_CHECK" >> $GITHUB_OUTPUT
232+ else
233+ echo "test_branch=main" >> $GITHUB_OUTPUT
234+ fi
235+ env :
236+ BRANCH_TO_CHECK : ${{ github.head_ref }}
194237 call-functional-tests :
195- needs : [launch-dockerized-devimage, wait-for-task-stability]
238+ needs : [launch-dockerized-devimage, wait-for-task-stability, find-correct-test-branch ]
196239 if : ${{ !cancelled() && needs.launch-dockerized-devimage.result == 'success' && needs.wait-for-task-stability.result == 'success'}}
197- uses : NHSDigital/manage-vaccinations-in-schools-testing/.github/workflows/functional_selected_device.yaml@make-workflow-callable # TODO: Change once this is in main
240+ uses : NHSDigital/manage-vaccinations-in-schools-testing/.github/workflows/functional_selected_device.yaml@containerized_regression_tests_for_PRs # TODO: Change once this is in main
198241 permissions :
199242 contents : write
200243 with :
201- tests : ' '
202- device : ' Desktop Chrome'
203- programmes : ' FLU,HPV,MENACWY,MMR,TD_IPV'
204- endpoint : " http://${{ needs.wait-for-task-stability.outputs.container_ip }}:4000"
205- screenshot_all_steps : ' false'
206- enable_reruns : ' true'
207- test_workers : ' 4'
208- set_feature_flags : ' false'
209- additional_feature_flags : ' '
244+ cross_service_tests : false
245+ github_ref : ${{ needs.find-correct-test-branch.outputs.test_branch }}
246+ endpoint : ' http://${{ needs.wait-for-task-stability.outputs.container_ip }}:4000'
210247 secrets :
211248 HTTP_AUTH_TOKEN_FOR_TESTS : ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }}
212- # IMMS_API_KEY: ${{ secrets.IMMS_API_KEY }}
213- # IMMS_API_KID: ${{ secrets.IMMS_API_KID }}
214- # IMMS_API_PEM: ${{ secrets.IMMS_API_PEM }}
215- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
216- #
249+ MAVIS_TESTING_REPO_ACCESS_TOKEN : ${{ secrets.MAVIS_TESTING_REPO_ACCESS_TOKEN }}
217250 stop-docker-environment :
218251 needs : [call-functional-tests, launch-dockerized-devimage, wait-for-task-stability]
219252 if : ${{ always() && needs.launch-dockerized-devimage.result != 'skipped'}}
0 commit comments