forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub Actions CI/CD (hyperledger#6427)
Implements a CI/CD pipeline using Github Actions, to replace the current CircleCI implementation. https://wiki.hyperledger.org/pages/viewpage.action?pageId=80774216 --------- Signed-off-by: Justin Florentine <justin+github@florentine.us> Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: jflo <justin+github@florentine.us> Signed-off-by: RoboCopsGoneSock <158174948+RoboCopsGoneSock@users.noreply.github.com> Signed-off-by: Danno Ferrin (shemnon) <danno.ferrin@shemnon.com> Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com> Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net> Signed-off-by: ahamlat <ameziane.hamlat@consensys.net> Signed-off-by: garyschulte <garyschulte@gmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Gabriel Fukushima <gabrielfukushima@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: RoboCopsGoneSock <158174948+RoboCopsGoneSock@users.noreply.github.com> Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com> Co-authored-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: garyschulte <garyschulte@gmail.com>
- Loading branch information
1 parent
c10cb3d
commit 9cb6600
Showing
20 changed files
with
869 additions
and
142 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
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 | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
shouldRun: ${{steps.shouldRun.outputs.result}} | ||
steps: | ||
- name: required check | ||
id: shouldRun | ||
uses: actions/github-script@v7.0.1 | ||
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-tests'); | ||
const alreadyRun = acceptanceTested && acceptanceTested.find(({ state }) => state === 'success') > 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; | ||
acceptanceTestEthereum: | ||
runs-on: ubuntu-22.04 | ||
name: "Acceptance Runner" | ||
needs: shouldRun | ||
permissions: | ||
statuses: write | ||
checks: write | ||
if: ${{ needs.shouldRun.outputs.shouldRun == 'true'}} | ||
strategy: | ||
fail-fast: true | ||
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@v4.1.1 | ||
- name: Set up Java | ||
uses: actions/setup-java@v4.0.0 | ||
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.12.0 | ||
- 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: cleanup tempfiles | ||
run: rm testList.txt gradleArgs.txt | ||
- name: Upload Acceptance Test Results | ||
uses: actions/upload-artifact@v3.1.0 | ||
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' | ||
acceptance-tests: | ||
runs-on: ubuntu-22.04 | ||
needs: [ acceptanceTestEthereum ] | ||
permissions: | ||
checks: write | ||
statuses: write | ||
steps: | ||
- name: consolidation | ||
run: echo "consolidating statuses" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
name: artifacts | ||
|
||
on: | ||
release: | ||
types: | ||
- prereleased | ||
|
||
jobs: | ||
artifacts: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4.1.1 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4.0.0 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- name: setup gradle | ||
uses: gradle/gradle-build-action@v2.12.0 | ||
- name: assemble distributions | ||
run: | ||
./gradlew -Prelease.releaseVersion=${{github.ref_name}} assemble -Dorg.gradle.parallel=true -Dorg.gradle.caching=true | ||
- name: hashes | ||
id: hashes | ||
run: | | ||
cd build/distributions | ||
echo "zipSha=$(shasum -a 256 besu*.zip)" >> $GITHUB_OUTPUT | ||
echo "tarSha=$(shasum -a 256 besu*.tar.gz)" >> $GITHUB_OUTPUT | ||
- name: upload tarball | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: 'build/distributions/besu*.tar.gz' | ||
name: besu-${{ github.ref_name }}.tar.gz | ||
- name: upload zipfile | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: 'build/distributions/besu*.zip' | ||
name: besu-${{ github.ref_name }}.zip | ||
- name: Upload Release assets | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
append_body: true | ||
files: | | ||
build/distributions/besu*.tar.gz | ||
build/distributions/besu*.zip | ||
body: | | ||
${{steps.hashes.outputs.tarSha}} | ||
${{steps.hashes.outputs.zipSha}} | ||
testWindows: | ||
runs-on: windows-2022 | ||
needs: artifacts | ||
timeout-minutes: 10 | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
steps: | ||
- name: Set up Java | ||
uses: actions/setup-java@v4.0.0 | ||
with: | ||
distribution: adopt | ||
java-version: 17 | ||
- name: Download zip | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: besu-${{ github.ref_name }}.zip | ||
- name: test Besu | ||
run: | | ||
unzip besu-*.zip -d besu-tmp | ||
cd besu-tmp | ||
mv besu-* ../besu | ||
cd .. | ||
besu\bin\besu.bat --help | ||
besu\bin\besu.bat --version | ||
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.