@@ -117,9 +117,14 @@ jobs:
117117 runs-on : ubuntu-latest
118118 permissions :
119119 id-token : write
120+ contents : write
120121 timeout-minutes : 180
122+ env :
123+ RESULT_PATH : ${{ inputs.testToRun }}/${{ inputs.URN }}/${{ github.run_number }}
121124 steps :
122125 - uses : actions/checkout@v5
126+ - name : Set timestamp
127+ run : echo "timestamp=$(date '+%Y%m%d%H%M%S')" >> $GITHUB_ENV
123128 - name : Configure AWS credentials
124129 uses : aws-actions/configure-aws-credentials@v5
125130 with :
@@ -134,6 +139,7 @@ jobs:
134139 image : " 393416225559.dkr.ecr.eu-west-2.amazonaws.com/performancetest:${{ github.sha }}"
135140 environment-variables : |
136141 TEST_TO_RUN=${{ inputs.testToRun }}
142+ RESULT_PATH=${{ env.RESULT_PATH }}
137143 URN=${{ inputs.URN }}
138144 DURATION=${{ inputs.duration }}
139145 THREADS=${{ inputs.threads }}
@@ -154,16 +160,15 @@ jobs:
154160 --output text
155161 )
156162 echo "task_definition_arn=$task_definition_arn" >> $GITHUB_OUTPUT
157- - name : Run ECS Task
163+ - name : Start performance test
158164 id : run-task
159165 run : |
160166 echo "Starting ECS task for ${{ inputs.testToRun }} test against URN: ${{ inputs.URN }}"
161167
162- # Prepare network configuration
163168 subnet_id=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=performancetest-subnet --query 'Subnets[0].SubnetId' --output text)
164169 security_group_id=$(aws ec2 describe-security-groups --filters Name=group-name,Values=performancetest-sg --query 'SecurityGroups[0].GroupId' --output text)
165170
166- aws ecs run-task \
171+ task_arn=$( aws ecs run-task \
167172 --cluster performancetest \
168173 --task-definition ${{ steps.register-task-definition.outputs.task_definition_arn }} \
169174 --launch-type FARGATE \
@@ -172,5 +177,64 @@ jobs:
172177 "containerOverrides": [{
173178 "name": "performancetest-container"
174179 }]
175- }'
176-
180+ }' \
181+ --query 'tasks[0].taskArn' \
182+ --output text)
183+
184+ echo "task_arn=$task_arn" >> $GITHUB_OUTPUT
185+ echo "Started task: $task_arn"
186+ - name : Wait for performance test to complete
187+ run : |
188+ echo "Waiting for task to complete: ${{ steps.run-task.outputs.task_arn }}"
189+ aws ecs wait tasks-stopped \
190+ --cluster performancetest \
191+ --tasks ${{ steps.run-task.outputs.task_arn }}
192+
193+ task_status=$(aws ecs describe-tasks \
194+ --cluster performancetest \
195+ --tasks ${{ steps.run-task.outputs.task_arn }} \
196+ --query 'tasks[0].lastStatus' \
197+ --output text)
198+
199+ exit_code=$(aws ecs describe-tasks \
200+ --cluster performancetest \
201+ --tasks ${{ steps.run-task.outputs.task_arn }} \
202+ --query 'tasks[0].containers[0].exitCode' \
203+ --output text)
204+
205+ echo "Task final status: $task_status"
206+ echo "Container exit code: $exit_code"
207+
208+ if [ "$exit_code" != "0" ]; then
209+ echo "ECS task failed with exit code: $exit_code"
210+ exit 1
211+ fi
212+ - name : Collect test result
213+ id : collect-results
214+ run : |
215+ echo "Downloading test results from S3"
216+ S3_PATH="s3://performancetest-reports/${{ env.RESULT_PATH }}"
217+ aws s3 sync "${S3_PATH}" ./test-results --no-progress
218+
219+ if [ "${{ inputs.testToRun }}" == "consent-journey" ]; then
220+ echo "REPORT_DIR=test-results/consent/report" >> $GITHUB_OUTPUT
221+ elif [ "${{ inputs.testToRun }}" == "nurse-journey" ]; then
222+ echo "REPORT_DIR=test-results/nurse/report" >> $GITHUB_OUTPUT
223+ fi
224+ - name : Publish report to GH Pages
225+ uses : peaceiris/actions-gh-pages@v4
226+ with :
227+ github_token : ${{ secrets.GITHUB_TOKEN }}
228+ publish_branch : gh-pages
229+ publish_dir : ${{ steps.collect-results.outputs.REPORT_DIR }}
230+ destination_dir : JMeter/${{ env.RESULT_PATH }}
231+ keep_files : true
232+ - name : Set Job Summary
233+ run : |
234+ echo "## Performance Test Results" >> $GITHUB_STEP_SUMMARY
235+ echo "" >> $GITHUB_STEP_SUMMARY
236+ echo "- **Test Type:** ${{ inputs.testToRun }}" >> $GITHUB_STEP_SUMMARY
237+ echo "- **URN:** ${{ inputs.URN }}" >> $GITHUB_STEP_SUMMARY
238+ echo "- **Run Number:** ${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
239+ echo "" >> $GITHUB_STEP_SUMMARY
240+ echo "📊 View Test Report: https://nhsdigital.github.io/manage-vaccinations-in-schools-testing/JMeter/${{ env.RESULT_PATH }}/" >> $GITHUB_STEP_SUMMARY
0 commit comments