[GH-60] Replace slack notifications with Teams notifications on manually run GH test actions. #628
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: No Slack - Run UW IdP Web Tests | |
on: | |
push: | |
branches: | |
# This branch override is meant to act as a way of validating | |
# the workflow itself, which is difficult to do well out | |
# of context. Feel free to push to this branch at any time. | |
# You may need to use `-f` when pushing. | |
- run-uw-idp-web-tests | |
pull_request: | |
paths-ignore: | |
- "*.md" # No reason to run tests when only docs change | |
workflow_dispatch: | |
inputs: | |
target-idp-env: | |
description: > | |
target-idp-env. Acceptable values are `eval`, `prod`. The idp environment | |
you want to test against. | |
required: true | |
default: eval | |
target-idp-host: | |
description: > | |
target-idp-host. Optional. If provided, will add an /etc/hosts entry | |
targeting this host. | |
required: false | |
reason: | |
description: > | |
reason. The reason for running this test suite; can be helpful to | |
provide context and distinguish different runs. | |
required: false | |
pytest-args: | |
description: > | |
pytest-args. Any args you want to send to pytest. You do not ever need to | |
supply `log_cli` arguments. | |
required: false | |
env: | |
############################################### | |
# Do not edit the env values below this line. # | |
# Other defaults are set in .github/scripts/configure-workflow.sh | |
TEAMS_INTEGRATIONS_DAILY_WEB_TESTS: ${{ secrets.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }} | |
ARTIFACT_BUCKET: ${{ secrets.IDENTITY_ARTIFACT_BUCKET }} | |
############################################### | |
jobs: | |
run-idp-web-tests: | |
name: Configure and run tests, and upload test artifacts | |
runs-on: ubuntu-latest | |
env: | |
UPLOAD_STATUS: 'not started' | |
ARTIFACT_HOST: "https://identity-artifact.iamdev.s.uw.edu" | |
outputs: | |
# These outputs come from the configure-workflow.sh script | |
report-object-path: ${{ steps.configure.outputs.report-object-path }} | |
report-url: ${{ steps.configure.outputs.report-url }} | |
short-sha: ${{ steps.configure.outputs.short-sha }} | |
pr-number: ${{ steps.configure.outputs.pr-number }} | |
workflow-id: ${{ steps.configure.outputs.workflow-id }} | |
workflow-snapshot-artifact: ${{ steps.configure.outputs.workflow-snapshot-artifact }} | |
idp-env: ${{ steps.configure.outputs.idp-env }} | |
idp-host: ${{ steps.configure.outputs.idp-host }} | |
run-tests-args: ${{ steps.configure.outputs.run-tests-args }} | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
pull-requests: 'write' | |
steps: | |
- uses: actions/checkout@main | |
- id: configure | |
env: | |
INPUT_TARGET_IDP_ENV: ${{ github.event.inputs.target-idp-env }} | |
INPUT_TARGET_IDP_HOST: ${{ github.event.inputs.target-idp-host }} | |
INPUT_REASON: ${{ github.event.inputs.reason }} | |
INPUT_PYTEST_ARGS: ${{ github.event.inputs.pytest-args }} | |
UWCA_CERT: ${{ secrets.UWCA_CERT }} | |
UWCA_KEY: ${{ secrets.UWCA_KEY }} | |
run: | | |
source ./.github/scripts/configure-workflow.sh | |
configure-workflow | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: ${{ secrets.TEST_RUNNER_GOOGLE_TOKEN }} | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
with: | |
version: '>= 363.0.0' | |
- name: Notify Teams of Test Run Start | |
env: | |
IDP_ENV: ${{ steps.configure.outputs.idp-env }} | |
WORKFLOW_ENV: ${{ steps.configure.outputs.workflow-snapshot-artifact }} | |
run: | # {"title": "workflow-snapshot-artifact ", "value": "'${{ env.WORKFLOW_ENV }}'"} | |
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": "Test Run Notification" | |
}, | |
{ | |
"type": "TextBlock", | |
"text": "Test run for UW IdP tests started ⏳", | |
"wrap": true | |
}, | |
{ | |
"type": "FactSet", | |
"facts": [ | |
{"title": "IdP Web Tests running on ", "value": "'${{ env.IDP_ENV }}'"} | |
] | |
} | |
] | |
} | |
} | |
] | |
}' \ | |
"${{ env.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }}" | |
- env: | |
RUN_TESTS_ARGS: ${{ steps.configure.outputs.run-tests-args }} | |
IDP_ENV: ${{ steps.configure.outputs.idp-env }} | |
run: | | |
exit_status=0 | |
if ./scripts/run-tests.sh ${{ steps.args.outputs.extra }} ${{ env.RUN_TESTS_ARGS }} | |
then | |
echo "All tests succeeded for ${{ env.IDP_ENV }} succeeded! " | |
test_status=succeeded | |
else | |
exit_status=$? | |
echo "Tests for ${{ env.IDP_ENV }} failed with status $exit_status" | |
test_status=failed | |
fi | |
# Only upload artifacts if the test suite actually ran. | |
echo "test-status=$test_status" >> $GITHUB_OUTPUT | |
echo "upload-artifacts=true" >> $GITHUB_OUTPUT | |
exit $exit_status | |
name: Run UW ${{ env.IDP_ENV }} IdP Web Tests | |
id: run-tests | |
- if: ${{ always() && steps.run-tests.outputs.upload-artifacts == 'true' }} | |
id: upload-artifacts | |
with: | |
path: web-tests | |
destination: ${{ secrets.IDENTITY_ARTIFACT_BUCKET }} | |
name: upload storyboards to identity-artifacts | |
uses: google-github-actions/upload-cloud-storage@v2 | |
- if: ${{ always() && github.event_name == 'pull_request' }} | |
id: update-pull-request | |
uses: mshick/add-pr-comment@v1 | |
name: Add storyboard link to pull request | |
env: | |
REPORT_URL: ${{ steps.configure.outputs.report-url }} | |
SHORT_SHA: ${{ steps.configure.outputs.short-sha }} | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
repo-token-user-login: 'github-actions[bot]' # Don't change | |
allow-repeats: true | |
message: | | |
- Test result: ${{ steps.run-tests.outcome }} | |
- [Storyboards](${{ env.REPORT_URL }}) | |
**Commit ${{ env.SHORT_SHA }}** | |
- name: Notify Teams of Test Run Completion | |
env: | |
TEST_STATUS: ${{ steps.run-tests.outputs.test-status }} | |
REPORT_URL: ${{ steps.configure.outputs.report-url }} | |
if: always() | |
run: | | |
# Set the message body dynamically based on TEST_STATUS | |
echo "TEST_STATUS TEST_STATUS TEST_STATUS TEST_STATUS 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": "Test Run Notification" | |
}, | |
{ | |
"type": "TextBlock", | |
"text": "'"$test_result"'", | |
"wrap": true | |
}, | |
{ | |
"type": "FactSet", | |
"facts": [ | |
{"title": "Storyboards:", "value": "['"$REPORT_URL"']('"$REPORT_URL"')"}, | |
{"title": "Initiated By:", "value": "'"${{ github.actor }}"'"} | |
] | |
} | |
] | |
} | |
} | |
] | |
}' \ | |
"${{ secrets.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }}" |