Skip to content

Commit

Permalink
Try a different approach
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekagarwal87 committed Jan 9, 2025
1 parent 1a972ef commit 296ec27
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:
needs: build
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
- name: Check PR Approval (if applicable)
id: check
if: ${{ env.isPR == 'true' }}
uses: actions/github-script@v6
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: 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: 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 296ec27

Please sign in to comment.