consolidate status to get rid of shard-specific ones #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: acceptance-tests | |
on: | |
pull_request: | |
pull_request_review: | |
types: [submitted] | |
env: | |
GRADLE_OPTS: "-Xmx6g -Dorg.gradle.daemon=false" | |
total-runners: 16 | |
jobs: | |
shouldRun: | |
name: checks to ensure we should run | |
# necessary because there is no single PR approved event, need to check all comments/approvals/denials | |
# might also be a job running, and additional approvals | |
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 acceptanceTested = statuses && statuses.filter(({ context }) => context === 'acceptance-tested'); | |
const alreadyRun = acceptanceTested && acceptanceTested.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]' && (approvingReviews.length > 0); | |
console.log("tests should be run = %j", shouldRun); | |
console.log("alreadyRun = %j", alreadyRun); | |
console.log("approvingReviews = %j", approvingReviews.length); | |
return shouldRun; | |
pend: | |
name: acceptance testing pending | |
runs-on: ubuntu-22.04 | |
needs: shouldRun | |
if: ${{ needs.shouldRun.outputs.shouldRun == 'true'}} | |
permissions: | |
statuses: write | |
steps: | |
- name: debug | |
run: echo ${{ needs.shouldRun.outputs.shouldRun }} | |
- name: pending | |
uses: myrotvorets/[email protected] | |
with: | |
status: pending | |
sha: ${{ github.event.pull_request.head.sha || github.sha }} | |
context: acceptance-tested | |
acceptanceTestEthereum: | |
runs-on: ubuntu-22.04 | |
needs: pend | |
name: "Acceptance Runner" | |
permissions: | |
statuses: write | |
checks: write | |
if: ${{ needs.shouldRun.outputs.shouldRun == 'true'}} | |
strategy: | |
fail-fast: false | |
matrix: | |
runner_index: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 17 | |
- name: get acceptance test report | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
branch: main | |
name_is_regexp: true | |
name: 'acceptance-node-\d*\d-test-results' | |
path: tmp/junit-xml-reports-downloaded | |
if_no_artifact_found: true | |
- name: setup gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Split tests | |
id: split-tests | |
uses: r7kamura/split-tests-by-timings@v0 | |
with: | |
reports: tmp/junit-xml-reports-downloaded | |
glob: 'acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/**/*Test.java' | |
total: ${{env.total-runners}} | |
index: ${{ matrix.runner_index }} | |
- name: write out test list | |
run: echo "${{ steps.split-tests.outputs.paths }}" >> testList.txt | |
- name: format gradle args | |
#regex means: first truncate file paths to align with package name, then swap path delimiter with package delimiter, | |
#then drop file extension, then insert --tests option between each. | |
run: cat testList.txt | sed -e 's@acceptance-tests/tests/src/test/java/@--tests\ @g;s@/@.@g;s/\.java//g' > gradleArgs.txt | |
- name: run acceptance tests | |
run: ./gradlew acceptanceTest `cat gradleArgs.txt` -Dorg.gradle.parallel=true -Dorg.gradle.caching=true | |
- name: flag failed acceptance tests | |
uses: myrotvorets/[email protected] | |
if: failure() | |
with: | |
status: ${{ job.status }} | |
context: acceptance-tested | |
sha: ${{ github.event.pull_request.head.sha || github.sha }} | |
description: fail acceptance test batch ${{matrix.runner_index}} | |
- name: cleanup tempfiles | |
run: rm testList.txt gradleArgs.txt | |
- name: Upload Acceptance Test Results | |
uses: actions/[email protected] | |
with: | |
name: acceptance-node-${{matrix.runner_index}}-test-results | |
path: 'acceptance-tests/tests/build/test-results/acceptanceTest/TEST-*.xml' | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: (success() || failure()) # always run even if the build step fails | |
with: | |
report_paths: 'acceptance-tests/tests/build/test-results/acceptanceTest/TEST-*.xml' | |
consolidateStatus: | |
runs-on: ubuntu-22.04 | |
needs: acceptanceTestEthereum | |
permissions: | |
statuses: write | |
checks: write | |
steps: | |
- name: status success | |
uses: myrotvorets/[email protected] | |
with: | |
sha: ${{ github.event.pull_request.head.sha || github.sha }} | |
status: success | |
context: acceptance-tested | |
description: acceptance tests passed |