Skip to content

TSPS-124 integration test infrastructure working with GHA #26

TSPS-124 integration test infrastructure working with GHA

TSPS-124 integration test infrastructure working with GHA #26

Workflow file for this run

name: Run TSPS e2e tests with BEE
on:
pull_request:
branches: [ '**' ]
# There is an issue with GitHub required checks and paths-ignore. We don't really need to
# run the tests if there are only irrelevant changes (see paths-ignore above). However,
# we require tests to pass by making a "required check" rule on the branch. If the action
# is not triggered, the required check never passes and you are stuck. Therefore, we have
# to run tests even when we only change a markdown file. So don't do what I did and put a
# paths-ignore right here!
workflow_dispatch: {}
#'on':
# schedule:
# # run twice a day at 10:00 and 22:00 UTC every day of the week
# - cron: "0 10/12 * * 1-5"
# workflow_dispatch:
env:
BEE_NAME: 'tsps-${{ github.run_id }}-${{ github.run_attempt}}-dev'
TOKEN: '${{ secrets.BROADBOT_TOKEN }}'
ATTACH_BP_TO_LZ_RUN_NAME: 'attach-billing-project-to-landing-zone-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
RUN_NAME_SUFFIX: ${{ github.event.repository.name }}-${{ github.run_id }}-${{github.run_attempt }}
jobs:
init-github-context:
runs-on: ubuntu-latest
outputs:
branch: '${{ steps.extract-inputs.outputs.branch }}'
delete-bee: '${{ steps.extract-inputs.outputs.delete-bee }}'
steps:
- name: Get inputs or use defaults
id: extract-inputs
run: >
echo "branch=${{ inputs.branch || 'develop' }}" >> "$GITHUB_OUTPUT"
echo "delete-bee=${{ inputs.delete-bee || false }}" >> "$GITHUB_OUTPUT"
params-gen:
runs-on: ubuntu-latest
outputs:
project-name: '${{ steps.gen.outputs.project_name }}'
bee-name: '${{ env.BEE_NAME }}'
steps:
- uses: actions/checkout@v4
- 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
create-bee-workflow:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Get actions
uses: actions/checkout@v4
- name: dispatch to terra-github-workflows
id: FirstAttemptCreateBee
continue-on-error: true
uses: ./.github/actions/create-bee
with:
run_name: "bee-create-${{ env.BEE_NAME }}"
bee_name: ${{ env.BEE_NAME }}
token: '${{ env.TOKEN }}'
- name: retry dispatch to terra-github-workflows in case of failure
if: steps.FirstAttemptCreateBee.outcome == 'failure'
uses: ./.github/actions/create-bee
with:
run_name: "bee-create-${{ env.BEE_NAME }}-retry"
bee_name: ${{ env.BEE_NAME }}
token: ${{ env.TOKEN }}
attach-landing-zone-to-bee-workflow:
runs-on: ubuntu-latest
needs: [ init-github-context, create-bee-workflow, params-gen ]
steps:
- name: Get actions
uses: actions/checkout@v4
- name: dispatch to terra-github-workflows
id: FirstAttemptLandingZone
continue-on-error: true
uses: ./.github/actions/landing-zone-attach
with:
run_name: "${{ env.ATTACH_BP_TO_LZ_RUN_NAME }}"
bee_name: ${{ env.BEE_NAME }}
token: '${{ env.TOKEN }}'
project_name: ${{ needs.params-gen.outputs.project-name }}
- name: retry dispatch to terra-github-workflows in case of failure
if: steps.FirstAttemptLandingZone.outcome == 'failure'
uses: ./.github/actions/landing-zone-attach
with:
run_name: "${{ env.ATTACH_BP_TO_LZ_RUN_NAME }}-retry"
bee_name: ${{ env.BEE_NAME }}
token: '${{ env.TOKEN }}'
project_name: ${{ needs.params-gen.outputs.project-name }}
run-e2e-test-job:
needs:
- attach-landing-zone-to-bee-workflow
- params-gen
permissions:
contents: read
id-token: write
uses: broadinstitute/dsp-reusable-workflows/.github/workflows/run_tsps_e2e_tests.yaml@93db8b7158b168bb302036b95887bf347176a378
with:
billing-project-name: '${{ needs.params-gen.outputs.project-name }}'
bee-name: '${{ needs.params-gen.outputs.bee-name }}'
destroy-bee-workflow:
runs-on: ubuntu-latest
needs:
- run-e2e-test-job
- attach-landing-zone-to-bee-workflow
- init-github-context
if: '${{ needs.init-github-context.outputs.delete-bee && always() }}'
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/workflow-dispatch@v3
with:
workflow: bee-destroy
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
wait-for-completion: false
token: '${{ env.TOKEN }}'
inputs: '{ "bee-name": "${{ env.BEE_NAME }}" }'
report-workflow:
uses: broadinstitute/sherlock/.github/workflows/client-report-workflow.yaml@main
if: github.ref == 'refs/heads/main'
with:
notify-slack-channels-upon-workflow-failure: "#terra-tsps-alerts"
permissions:
id-token: write