Scheduled UW IdP Test Matrix #649
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: Scheduled UW IdP Test Matrix | |
on: | |
push: | |
branches: | |
# You can test this workflow by pushing to this branch | |
- run-scheduled-idp-web-tests | |
schedule: | |
# The cron string must be quoted! | |
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule | |
# Do not change this without also changing stop-test-service-providers.yml | |
- cron: '0 10 * * *' # 3am PDT, 2am PST | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: > | |
The reason for running this test suite; can be helpful to | |
provide context and distinguish different runs. **Note, this form only really exists to a dev can test the workflow.** The standard way of running test on demand is with the "Run UW IdP Web Tests" workflow. | |
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-web-tests: | |
strategy: | |
matrix: | |
include: | |
- idp_env: eval | |
- idp_env: prod | |
fail-fast: false # Don't cancel prod tests if eval fails and vice versa | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
actions: write | |
env: | |
ARTIFACT_BUCKET: ${{ secrets.IDENTITY_ARTIFACT_BUCKET }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: config | |
run: | | |
set -x | |
timestamp=$(date "+%Y.%d.%m-%H.%m.%S") | |
storyboard_path="idp/schedule/${{ matrix.idp_env }}/${timestamp}" | |
report_dir="web-tests/${storyboard_path}" | |
echo timestamp=${timestamp} >> $GITHUB_OUTPUT | |
echo storyboard_path=${storyboard_path} >> $GITHUB_OUTPUT | |
echo report_dir=${report_dir} >> $GITHUB_OUTPUT | |
echo storyboard_link=${storyboard_url}/${report_dir}/index.html >> $GITHUB_OUTPUT | |
echo workflow_link=${{ env.workflow_link }} >> $GITHUB_OUTPUT | |
env: | |
storyboard_url: https://identity-artifact.iamdev.s.uw.edu/ | |
workflow_link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
- uses: UWIT-IAM/actions/[email protected] | |
with: | |
gcloud-token: ${{ secrets.TEST_RUNNER_GOOGLE_TOKEN }} | |
- id: configure | |
env: | |
INPUT_REASON: ${{ github.event.inputs.reason }} | |
run: | | |
source ./.github/scripts/configure-workflow.sh | |
configure-workflow | |
- name: Notify Teams of Test Run Start | |
env: | |
IDP_ENV: ${{ matrix.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": "Scheduled UW IdP Test Matrix Run" | |
}, | |
{ | |
"type": "TextBlock", | |
"text": "Starting - IDP Tests ⏳", | |
"wrap": true | |
}, | |
{ | |
"type": "FactSet", | |
"facts": [ | |
{"title": "IdP Web Tests running on ", "value": "'${{ env.IDP_ENV }}'"}, | |
{"title": "Reason for Test Run", "value": "${{ env.INPUT_REASON }}"} | |
] | |
} | |
] | |
} | |
} | |
] | |
}' \ | |
"${{ env.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }}" | |
- name: Run tests | |
id: run-tests | |
run: | | |
exit_status=0 | |
if ./scripts/run-tests.sh -- --env ${{ matrix.idp_env }} | |
then | |
echo "All tests succeeded for ${{ matrix.idp_env }}! " | |
test_status=succeeded | |
else | |
exit_status=$? | |
echo "Tests for ${{ matrix.idp_env }} failed with status $exit_status" | |
test_status=failed | |
fi | |
echo "test-status=$test_status" >> $GITHUB_OUTPUT | |
echo "upload-artifacts=true" >> $GITHUB_OUTPUT | |
exit $exit_status | |
- name: Determine post-test actions | |
if: always() | |
run: | | |
if test -f webdriver-report/index.html | |
then | |
mkdir -pv ${{ steps.config.outputs.report_dir }} | |
cp -r webdriver-report/* ${{ steps.config.outputs.report_dir }} | |
echo upload_storyboards='true' >> $GITHUB_OUTPUT | |
fi | |
id: post-run | |
- if: always() && steps.post-run.outputs.upload_storyboards == 'true' | |
name: Upload storyboards to identity-artifact | |
id: upload-storyboards | |
uses: google-github-actions/upload-cloud-storage@v2 | |
with: | |
path: 'web-tests' | |
destination: ${{ secrets.IDENTITY_ARTIFACT_BUCKET }} | |
- if: > | |
always() | |
&& 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.config.outputs.storyboard_link }} | |
INPUT_REASON: ${{ steps.configure.outputs.input-reason }} | |
IDP_ENV: ${{ matrix.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 - Scheduled UW IdP Test Matrix Run" | |
}, | |
{ | |
"type": "TextBlock", | |
"text": "'"$test_result"'", | |
"wrap": true | |
}, | |
{ | |
"type": "FactSet", | |
"facts": [ | |
{"title": "IdP Web Tests ran on ", "value": "'${{ env.IDP_ENV }}'"}, | |
{"title": "Reason for Test Run", "value": "${{ env.INPUT_REASON }}"}, | |
{"title": "Storyboards:", "value": "['"$REPORT_URL"']('"$REPORT_URL"')"} | |
] | |
} | |
] | |
} | |
} | |
] | |
}' \ | |
"${{ secrets.TEAMS_INTEGRATIONS_DAILY_WEB_TESTS }}" | |