diff --git a/.github/workflows/unit-and-integration-tests-unified.yml b/.github/workflows/unit-and-integration-tests-unified.yml index 11a7d17944be..f5b79853642b 100644 --- a/.github/workflows/unit-and-integration-tests-unified.yml +++ b/.github/workflows/unit-and-integration-tests-unified.yml @@ -157,6 +157,56 @@ jobs: echo ${{ needs.set-env-var.outputs.DRUID_PREVIOUS_IT_IMAGE_NAME }} docker save "${{ needs.set-env-var.outputs.DRUID_PREVIOUS_IT_IMAGE_NAME }}" | gzip > druid-container-jdk${{ matrix.jdk }}-version${{ needs.set-env-var.outputs.DRUID_PREVIOUS_VERSION }}.tar.gz + # check if it is a PR and if it is approved. For approved PRs, we do not want to run tests sequentially + check-approval: + runs-on: ubuntu-latest + outputs: + approved: ${{ steps.check.outputs.isApproved }} + steps: + - name: Check if Triggered by a PR + id: determine-trigger + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "isPR=true" >> $GITHUB_ENV + else + echo "isPR=false" >> $GITHUB_ENV + fi + + - name: Check PR Approval (if applicable) + id: check + if: ${{ env.isPR == 'true' }} + uses: actions/github-script@v7 + with: + script: | + const reviews = await github.rest.pulls.listReviews({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + const approved = reviews.data.some(review => review.state === 'APPROVED'); + core.setOutput("isApproved", approved); + + - name: Default to Approved for Branch + id: default-check + if: ${{ env.isPR == 'false' }} + run: echo "::set-output name=isApproved::true" + + unit-tests-unapproved: + name: "unit tests - PR unapproved - (jdk17)" + uses: ./.github/workflows/unit-tests.yml + needs: [build, check-approval] + if: ${{ needs.check-approval.outputs.approved != 'true' }} + with: + jdk: 17 + + unit-tests-approved: + name: "unit tests - PR approved - (jdk17)" + uses: ./.github/workflows/unit-tests.yml + needs: [build, check-approval] + if: ${{ needs.check-approval.outputs.approved == 'true' }} + with: + jdk: 17 + unit-tests-phase2: strategy: fail-fast: false @@ -165,26 +215,19 @@ jobs: jdk: [ '11', '21.0.4' ] name: "unit tests (jdk${{ matrix.jdk }})" uses: ./.github/workflows/unit-tests.yml - needs: unit-tests - if: ${{ always() && (needs.unit-tests.result == 'success' || needs.unit-tests.outputs.continue_tests) }} + needs: [unit-tests-unapproved, check-approval] + if: ${{ always() && (needs.check-approval.outputs.approved == 'true' || needs.unit-tests-unapproved.result == 'success' || needs.unit-tests-unapproved.outputs.continue_tests) }} with: jdk: ${{ matrix.jdk }} - unit-tests: - name: "unit tests (jdk17)" - uses: ./.github/workflows/unit-tests.yml - needs: build - with: - jdk: 17 - standard-its: - needs: unit-tests - if: ${{ always() && (needs.unit-tests.result == 'success' || needs.unit-tests.outputs.continue_tests) }} + needs: [unit-tests-unapproved, check-approval] + if: ${{ always() && (needs.check-approval.outputs.approved == 'true' || needs.unit-tests-unapproved.result == 'success' || needs.unit-tests-unapproved.outputs.continue_tests) }} uses: ./.github/workflows/standard-its.yml revised-its: - needs: [unit-tests, set-env-var] - if: ${{ always() && (needs.unit-tests.result == 'success' || needs.unit-tests.outputs.continue_tests) }} + needs: [unit-tests-unapproved, check-approval, set-env-var] + if: ${{ always() && (needs.check-approval.outputs.approved == 'true' || needs.unit-tests-unapproved.result == 'success' || needs.unit-tests-unapproved.outputs.continue_tests) }} uses: ./.github/workflows/revised-its.yml with: BACKWARD_COMPATIBILITY_IT_ENABLED: ${{ needs.set-env-var.outputs.BACKWARD_COMPATIBILITY_IT_ENABLED }}