Skip to content

rawls-run-azure-e2e-tests #1745

rawls-run-azure-e2e-tests

rawls-run-azure-e2e-tests #1745

name: rawls-run-azure-e2e-tests
# This workflow can be run on schedule OR dispatched (manually or by another dispatcher workflow)
# When thw workflow is triggered on schedule, it will use the parameters specified on
# the RHS of || in init-github-context.extract-inputs step. Otherwise, if the workflow is
# triggered by a dispatch event, it will use the parameters specified on LHS of || in
# the init-github-context.extract-inputs step.
#
# Ex.
#
# echo "student-subjects=${{ toJson(inputs.student-subjects || '["[email protected]","[email protected]"]') }}" >> "$GITHUB_OUTPUT"
#
# On schedule: student-subjects output will use '["[email protected]","[email protected]"]'
# Dispatch event: student-subjects output will use inputs.student-subjects
on:
schedule:
# run twice a day at 10:00 and 22:00 UTC every day of the week
- cron: "0 10/12 * * *"
workflow_dispatch:
inputs:
build-branch:
description: 'Build a custom image of Rawls from the specified branch. Default is false, meaning tests are run against the version specified by bee-version-template.'
required: true
default: 'false'
type: choice
options:
- true
- false
branch:
description: 'Branch of Rawls to build a custom image from. Ignored if custom image option is false.'
required: false
default: 'develop'
type: string
bee-version-template:
description: 'The version of services to install on the bee (default is dev, staging is supported). If the custom image option is false, this will also specify the Rawls version.'
required: true
default: 'dev'
type: string
delete-bee:
description: 'Delete created bee after running tests'
required: true
default: 'true'
type: choice
options:
- true
- false
owner-subject:
description: 'Owner subject (used for creating billing project in E2E testing)'
required: true
default: '[email protected]'
type: string
student-subjects:
description: 'A JSON array of Student subjects used for E2E testing'
required: true
default: '["[email protected]","[email protected]"]'
type: string
service-account:
description: 'Email address or unique identifier of the Google Cloud service account for which to generate credentials'
required: true
default: '[email protected]'
type: string
# E2E_ENV is the name of a .env file that contains envvars for E2E tests
env:
RAWLS_BUILD_RUN_NAME: 'rawls-build-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
RAWLS_SWAT_TESTS_RUN_NAME: 'rawls-swat-tests-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
BEE_CREATE_RUN_NAME: 'bee-create-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
BEE_DESTROY_RUN_NAME: 'bee-destroy-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
ATTACH_BP_TO_LZ_RUN_NAME: 'attach-billing-project-to-landing-zone-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
DEL_BP_V2_RUN_NAME: 'delete-billing-project-v2-from-bee-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
BEE_NAME: '${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}-dev'
TOKEN: '${{ secrets.BROADBOT_TOKEN }}' # github token for access to kick off a job in the private repo
E2E_ENV: 'azure_e2e.env'
STAGING_CHANNELS: 'C03F21QEWV7,C53JYBV9A' # C53JYBV9A channel is for #dsde-qa
DEV_CHANNELS: 'C03F21QEWV7' #dsp-workspaces-test-alerts
jobs:
init-github-context:
runs-on: ubuntu-latest
outputs:
build-branch: ${{ steps.extract-inputs.outputs.build-branch }}
branch: ${{ steps.extract-inputs.outputs.branch }}
bee-version-template: ${{ steps.extract-inputs.outputs.bee-version-template }}
fully-specified-branch: refs/heads/${{ steps.extract-inputs.outputs.branch }}
delete-bee: ${{ steps.extract-inputs.outputs.delete-bee }}
student-subjects: ${{ steps.extract-inputs.outputs.student-subjects }}
owner-subject: ${{ steps.extract-inputs.outputs.owner-subject }}
service-account: ${{ steps.extract-inputs.outputs.service-account }}
steps:
- name: Get inputs or use defaults
id: extract-inputs
run: |
echo "build-branch=${{ inputs.build-branch || 'false' }}" >> "$GITHUB_OUTPUT"
echo "branch=${{ inputs.branch || 'develop' }}" >> "$GITHUB_OUTPUT"
echo "bee-version-template=${{ inputs.bee-version-template || 'dev' }}" >> "$GITHUB_OUTPUT"
echo "delete-bee=${{ inputs.delete-bee || 'true' }}" >> "$GITHUB_OUTPUT"
echo "owner-subject=${{ inputs.owner-subject || '[email protected]' }}" >> "$GITHUB_OUTPUT"
echo "student-subjects=${{ toJson(inputs.student-subjects || '["[email protected]","[email protected]"]') }}" >> "$GITHUB_OUTPUT"
echo "service-account=${{ inputs.service-account || '[email protected]' }}" >> "$GITHUB_OUTPUT"
rawls-build-tag-publish-job:
runs-on: ubuntu-latest
needs:
- init-github-context
permissions:
contents: 'read'
id-token: 'write'
outputs:
custom-version-json: ${{ needs.init-github-context.outputs.build-branch == 'true' && steps.render-rawls-version.outputs.custom-version-json || ''}}
steps:
- uses: 'actions/checkout@v3'
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
with:
ref: ${{ needs.init-github-context.outputs.branch }}
- name: Bump the tag to a new version
uses: databiosphere/github-actions/actions/[email protected]
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
id: tag
env:
DEFAULT_BUMP: patch
GITHUB_TOKEN: ${{ env.TOKEN }}
RELEASE_BRANCHES: main
WITH_V: true
- name: dispatch build to terra-github-workflows
uses: broadinstitute/[email protected]
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
with:
run-name: "${{ env.RAWLS_BUILD_RUN_NAME }}"
workflow: rawls-build
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: |
{
"run-name": "${{ env.RAWLS_BUILD_RUN_NAME }}",
"repository": "${{ github.event.repository.full_name }}",
"ref": "${{ needs.init-github-context.outputs.fully-specified-branch }}",
"rawls-release-tag": "${{ steps.tag.outputs.tag }}"
}
- name: Render Rawls version
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
id: render-rawls-version
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo "$GITHUB_CONTEXT"
echo "custom-version-json={\\\"rawls\\\":{\\\"appVersion\\\":\\\"${{ steps.tag.outputs.tag }}\\\"}}" >> $GITHUB_OUTPUT
create-bee-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- rawls-build-tag-publish-job
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Echo Rawls version and version template
run: |
echo "built custom Rawls=${{ needs.init-github-context.outputs.build-branch}}"
echo "custom build Rawls version=${{ needs.rawls-build-tag-publish-job.outputs.custom-version-json }}"
echo "version-template=${{ needs.init-github-context.outputs.bee-version-template }}"
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.BEE_CREATE_RUN_NAME }}"
workflow: bee-create
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.BEE_CREATE_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"bee-template-name": "rawls-e2e-azure-tests",
"version-template": "${{ needs.init-github-context.outputs.bee-version-template }}",
"custom-version-json": "${{ needs.rawls-build-tag-publish-job.outputs.custom-version-json }}"
}'
# This job can be used for generating parameters for E2E tests (e.g. a random project name).
params-gen:
runs-on: ubuntu-latest
outputs:
project-name: ${{ steps.gen.outputs.project_name }}
steps:
- uses: 'actions/checkout@v3'
- name: Generate a random billing project name
id: 'gen'
run: |
project_name=$(echo "tmp-billing-project-$(uuidgen)" | cut -c -30)
echo "project_name=${project_name}" >> $GITHUB_OUTPUT
# Azure Managed App Coordinates are defined in the following workflow:
# https://github.com/broadinstitute/terra-github-workflows/blob/main/.github/workflows/attach-landing-zone-to-bee.yaml
attach-billing-project-to-landing-zone-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- create-bee-workflow
- params-gen
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.ATTACH_BP_TO_LZ_RUN_NAME }}"
workflow: attach-billing-project-to-landing-zone.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.ATTACH_BP_TO_LZ_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"billing-project": "${{ needs.params-gen.outputs.project-name }}",
"billing-project-creator": "${{ needs.init-github-context.outputs.owner-subject }}",
"service-account": "${{ needs.init-github-context.outputs.service-account }}"
}'
rawls-swat-e2e-test-job:
runs-on: ubuntu-latest
needs:
- init-github-context
- create-bee-workflow
- params-gen
- attach-billing-project-to-landing-zone-workflow
steps:
- name: Configure the user subjects for the test
run: |
escapedJSON=$(echo '${{ needs.init-github-context.outputs.student-subjects }}' | sed 's/"/\"/g')
echo "USER_SUBJECTS={\"service_account\":\"${{ needs.init-github-context.outputs.service-account }}\", \"owners\": [\"${{ needs.init-github-context.outputs.owner-subject }}\"], \"students\": $escapedJSON}" >> $GITHUB_ENV
- name: dispatch to terra-github-workflows
env:
rawls_test_command: "testOnly -- -l ProdTest -l NotebooksCanaryTest -n org.broadinstitute.dsde.test.api.WorkspacesAzureTest"
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.RAWLS_SWAT_TESTS_RUN_NAME }}"
workflow: .github/workflows/rawls-swat-tests.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: |
{
"additional-args": "{\"logging\":\"true\",\"java-version\":\"17\",\"billing-project\":\"${{ needs.params-gen.outputs.project-name }}\"}",
"run-name": "${{ env.RAWLS_SWAT_TESTS_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"ENV": "qa",
"ref": "${{ needs.init-github-context.outputs.build-branch == 'true' && needs.init-github-context.outputs.fully-specified-branch || '' }}",
"test-group-name": "workspaces_azure",
"test-command": "${{ env.rawls_test_command }}",
"e2e-env": "${{ env.E2E_ENV }}",
"user-subjects": ${{ toJson(env.USER_SUBJECTS) }}
}
delete-billing-project-v2-from-bee-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- params-gen
- rawls-swat-e2e-test-job
if: always()
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.DEL_BP_V2_RUN_NAME }}"
workflow: .github/workflows/delete-billing-project-v2-from-bee.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.DEL_BP_V2_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"billing-project": "${{ needs.params-gen.outputs.project-name }}",
"billing-project-owner": "${{ needs.init-github-context.outputs.owner-subject }}",
"service-account": "${{ needs.init-github-context.outputs.service-account }}",
"silent-on-failure": "false"
}'
destroy-bee-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- rawls-swat-e2e-test-job
- delete-billing-project-v2-from-bee-workflow
if: ${{ needs.init-github-context.outputs.delete-bee == 'true' }}
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.BEE_DESTROY_RUN_NAME }}"
workflow: bee-destroy
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.BEE_DESTROY_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}"
}'
wait-for-completion: false
notify-slack-on-success:
runs-on: ubuntu-latest
needs:
- init-github-context
- destroy-bee-workflow
if: ${{ success() }}
steps:
- name: Notify slack
uses: slackapi/[email protected]
with:
channel-id: ${{ needs.init-github-context.outputs.bee-version-template == 'staging' && env.STAGING_CHANNELS || env.DEV_CHANNELS }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Azure Workspaces E2E Test*"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Environment:*\n${{ needs.init-github-context.outputs.build-branch == 'true' && needs.init-github-context.outputs.branch || needs.init-github-context.outputs.bee-version-template }}"
},
{
"type": "mrkdwn",
"text": "*Result:*\n✅ PASSED"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Link to workflow run>"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACKBOT_TOKEN }}
notify-slack-on-failure:
runs-on: ubuntu-latest
needs:
- init-github-context
- destroy-bee-workflow
if: ${{ failure() }}
steps:
- name: Notify slack
uses: slackapi/[email protected]
with:
channel-id: ${{ needs.init-github-context.outputs.bee-version-template == 'staging' && env.STAGING_CHANNELS || env.DEV_CHANNELS }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Azure Workspaces E2E Test*"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Environment:*\n${{ needs.init-github-context.outputs.build-branch == 'true' && needs.init-github-context.outputs.branch || needs.init-github-context.outputs.bee-version-template }}"
},
{
"type": "mrkdwn",
"text": "*Result:*\n❌ FAILED"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Link to workflow run>"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACKBOT_TOKEN }}