Skip to content

Commit

Permalink
Run Unit tests, ITs in parallel if PR is approved. (#17611)
Browse files Browse the repository at this point in the history
Instead of running the unit tests first and then running ITs, and other JDK tests, we will rather run all in parallel for faster build time. This is done only when the PR is approved so we are still not wasting gha runner bandwidth.
  • Loading branch information
abhishekagarwal87 authored Jan 15, 2025
1 parent 1db4557 commit 2c7c00f
Showing 1 changed file with 56 additions and 13 deletions.
69 changes: 56 additions & 13 deletions .github/workflows/unit-and-integration-tests-unified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down

0 comments on commit 2c7c00f

Please sign in to comment.