Skip to content

consolidate status to get rid of shard-specific ones #14

consolidate status to get rid of shard-specific ones

consolidate status to get rid of shard-specific ones #14

name: integration-tests
on:
pull_request:
pull_request_review:
types:
- submitted
env:
GRADLE_OPTS: "-Xmx6g -Dorg.gradle.daemon=false"
jobs:
shouldRun:
name: checks to ensure we should run
runs-on: ubuntu-22.04
outputs:
shouldRun: ${{steps.shouldRun.outputs.result}}
steps:
- name: required check
id: shouldRun
uses: actions/[email protected]
env:
# fun fact, this changes based on incoming event, it will be different when we run this on pushes to main
RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
with:
script: |
const { RELEVANT_SHA } = process.env;
const { data: { statuses } } = await github.rest.repos.getCombinedStatusForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: RELEVANT_SHA,
});
const unitTested = statuses && statuses.filter(({ context }) => context === 'pre-review');
const failedUnits = unitTested && unitTested.filter(({state}) => state === 'failure' || state === 'pending');
const intTested = statuses && statuses.filter(({ context }) => context === 'integration-tests');
const alreadyRun = intTested && intTested.find(({ state }) => state === 'success' || state === 'pending') > 0;
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const approvingReviews = reviews && reviews.filter(review => review.state === 'APPROVED');
const shouldRun = !alreadyRun && github.actor != 'dependabot[bot]' && (failedUnits.length === 0) && (approvingReviews.length > 0);
console.log("tests should be run = %j", shouldRun);
console.log("alreadyRun = %j", alreadyRun);
console.log("failedUnits = %j", failedUnits.length);
console.log("approvingReviews = %j", approvingReviews.length);
return shouldRun;
pend:
name: integration testing pending
needs: shouldRun
if: ${{ needs.shouldRun.outputs.shouldRun == 'true' }}
runs-on: ubuntu-22.04
permissions:
statuses: write
steps:
- name: pending
uses: myrotvorets/[email protected]
with:
status: pending
sha: ${{ github.event.pull_request.head.sha || github.sha }}
integrationTest:
runs-on: ubuntu-22.04
needs: pend
if: ${{ needs.shouldRun.outputs.shouldRun == 'true' }}
permissions:
statuses: write
checks: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: setup gradle
uses: gradle/gradle-build-action@v2
- name: run integration tests
run: ./gradlew integrationTest -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
- name: flag passed unit tests
uses: myrotvorets/[email protected]
if: success()
with:
status: ${{ job.status }}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: (success() || failure())
with:
report_paths: '**/build/test-results/integrationTest/TEST-*.xml'