From 8e89f6d43f8040a15b69b004ca32769084956838 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Tue, 2 Jul 2024 14:17:11 -0700 Subject: [PATCH] test run conditionals --- .github/workflows/e2e.yml | 46 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6ce37dd1a0..4216d6ffaa 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - "*" + merge_group: workflow_dispatch: schedule: # run at 6AM UTC Daily @@ -14,16 +15,57 @@ on: - cron: "0 6 * * *" jobs: + matrix-conditionals: + runs-on: ubuntu-22.04 + env: + GH_TOKEN: ${{ github.token }} + outputs: + UPGRADE_TESTS: ${{ steps.matrix-conditionals.outputs.UPGRADE_TESTS }} + LIGHT_UPGRADE_TESTS: ${{ steps.matrix-conditionals.outputs.LIGHT_UPGRADE_TESTS }} + ADMIN_TESTS: ${{ steps.matrix-conditionals.outputs.ADMIN_TESTS }} + steps: + # use cli rather than event context to avoid race conditions (label added after push) + - id: matrix-conditionals + run: | + if [[ ${{ github.event_name }} == 'pull_request' ]]; then + labels=$(gh pr view -R ${{github.repository}} ${{github.event.pull_request.number}} --json labels -q '.labels[].name') + if [[ $labels == *"UPGRADE_TESTS"* ]]; then + if [[ $labels == *"LIGHT_UPGRADE_TESTS"* ]]; then + echo "LIGHT_UPGRADE_TESTS=true" >> $GITHUB_OUTPUT + else + echo "UPGRADE_TESTS=true" >> $GITHUB_OUTPUT + fi + fi + + if [[ $labels == *"ADMIN_TESTS"* ]]; then + echo "ADMIN_TESTS=true" >> $GITHUB_OUTPUT + fi + elif [[ ${{ github.event_name }} == 'merge_group' ]]; then + #TODO: add ability to opt out via MINIMAL_TESTS + echo "LIGHT_UPGRADE_TESTS=true" >> $GITHUB_OUTPUT + elif [[ ${{ github.event_name }} == 'schedule' ]]; then + echo "UPGRADE_TESTS=true" >> $GITHUB_OUTPUT + echo "LIGHT_UPGRADE_TESTS=true" >> $GITHUB_OUTPUT + echo "ADMIN_TESTS=true" >> $GITHUB_OUTPUT + fi + e2e: + needs: matrix-conditionals strategy: matrix: include: - make-target: "start-e2e-test" runs-on: ubuntu-20.04 run: true + - make-target: "start-upgrade-test" + runs-on: ubuntu-20.04 + run: ${{ needs.matrix-conditionals.outputs.UPGRADE_TESTS || false }} - make-target: "start-upgrade-test-light" runs-on: ubuntu-20.04 - run: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'MINIMAL_CI') }} + run: ${{ needs.matrix-conditionals.outputs.LIGHT_UPGRADE_TESTS || false }} + - make-target: "start-e2e-admin-test" + runs-on: ubuntu-20.04 + run: ${{ needs.matrix-conditionals.outputs.ADMIN_TESTS || false }} name: ${{ matrix.make-target }} uses: ./.github/workflows/reusable-e2e.yml with: @@ -33,7 +75,7 @@ jobs: secrets: inherit # this allows you to set a required status check ok: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: e2e steps: - run: echo "e2e tests passed"