From 5dd0b5c9e7f6e9ee62a9c9c04527772368c27df5 Mon Sep 17 00:00:00 2001 From: Glen Goulter <37945000+goulter@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:07:08 -0800 Subject: [PATCH] starting adding Teams notifications to scheduled tests --- .github/workflows/scheduled-idp-web-tests.yml | 96 ++++++++++++++++++- docker-compose.yml | 4 +- 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scheduled-idp-web-tests.yml b/.github/workflows/scheduled-idp-web-tests.yml index 87005f5..cb5a799 100644 --- a/.github/workflows/scheduled-idp-web-tests.yml +++ b/.github/workflows/scheduled-idp-web-tests.yml @@ -1,4 +1,4 @@ -name: No Slack - Scheduled UW IdP Test Matrix +name: Scheduled UW IdP Test Matrix on: push: @@ -77,6 +77,45 @@ jobs: with: gcloud-token: ${{ secrets.TEST_RUNNER_GOOGLE_TOKEN }} + - name: Notify Teams of Test Run Start + env: + IDP_ENV: ${{ steps.configure.outputs.idp-env }} + INPUT_REASON: ${{ steps.configure.outputs.input-reason }} + run: | + curl -H "Content-Type: application/json" \ + -d '{ + "type": "message", + "attachments": [ + { + "contentType": "application/vnd.microsoft.card.adaptive", + "content": { + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.4", + "body": [ + { + "type": "TextBlock", + "size": "Large", + "weight": "Bolder", + "text": "Completed - IDP Test Run Notification" + }, + { + "type": "TextBlock", + "text": "'"$test_result"'", + "wrap": true + }, + { + "type": "FactSet", + "facts": [ + {"title": "Reason for Test Run", "value": "GlenHardcodedReason"} + ] + } + ] + } + } + ] + }' \ + "${{ secrets.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }}" - name: Run tests run: ./scripts/run-tests.sh -- --env ${{ matrix.idp_env }} @@ -105,9 +144,62 @@ jobs: - if: > always() - && steps.post-run.outputs.upload_storyboards =='true' + && steps.post-run.outputs.upload_storyboards == 'true' && steps.upload-storyboards.outcome == 'success' name: Set notices on workflow env: storyboard_link: ${{ steps.config.outputs.storyboard_link }} run: echo "::notice::Storyboards located at ${{ env.storyboard_link }}" + + - name: Notify Teams of Test Run Completion + env: + TEST_STATUS: ${{ steps.run-tests.outputs.test-status }} + REPORT_URL: ${{ steps.configure.outputs.report-url }} + INPUT_REASON: ${{ steps.configure.outputs.input-reason }} + IDP_ENV: ${{ steps.configure.outputs.idp-env }} + if: always() + run: | + # Set the message body dynamically based on TEST_STATUS + echo "TEST_STATUS=${{ env.TEST_STATUS }}" + if [ "$TEST_STATUS" = "succeeded" ]; then + test_result="Test run for IDP passed successfully ✅" + else + test_result="Test run for IDP failed ❌" + fi + + # Notify Teams with the status of the test run + curl -H "Content-Type: application/json" \ + -d '{ + "type": "message", + "attachments": [ + { + "contentType": "application/vnd.microsoft.card.adaptive", + "content": { + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.4", + "body": [ + { + "type": "TextBlock", + "size": "Large", + "weight": "Bolder", + "text": "Completed - IDP Test Run Notification" + }, + { + "type": "TextBlock", + "text": "'"$test_result"'", + "wrap": true + }, + { + "type": "FactSet", + "facts": [ + {"title": "Reason for Test Run", "value": "GlenHardcodedReason"} + ] + } + ] + } + } + ] + }' \ + "${{ secrets.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }}" + diff --git a/docker-compose.yml b/docker-compose.yml index cbed1ef..c7fef6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,8 +33,8 @@ services: volumes: - ${CREDENTIAL_MOUNT_POINT}:/secrets:ro - ${REPORT_MOUNT_POINT}:/tmp/webdriver-report - command: pytest ${PYTEST_ARGS} --selenium-server selenium:4444 - # command: echo "The test would start here" #If you don't want the tests to run, and test other things like notifications, use this command instead of the above. + # command: pytest ${PYTEST_ARGS} --selenium-server selenium:4444 + command: echo "The test would start here" #If you don't want the tests to run, and test other things like notifications, use this command instead of the above. selenium: image: selenium/standalone-chrome:4