Skip to content

Commit

Permalink
Merge pull request hyperledger#30 from jflo/gha_artifacts
Browse files Browse the repository at this point in the history
build artifacts on release draft
  • Loading branch information
jflo authored Jan 4, 2024
2 parents d5fbe0d + d27adf1 commit 6a49cc1
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 133 deletions.
83 changes: 78 additions & 5 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,76 @@
name: acceptance-tests
on:
workflow_dispatch:
workflow_call:
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
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 unitTested = statuses && statuses.filter(({ context }) => context === 'pre-review');
const failedUnits = unitTested && unitTested.filter(({state}) => state === 'failure' || state === 'pending');
const acceptanceTested = statuses && statuses.filter(({ context }) => context === 'acceptance-tests');
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]' && (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: 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/set-commit-status-action@v2.0.0
with:
status: pending
sha: ${{ github.event.pull_request.head.sha || github.sha }}
acceptanceTestEthereum:
runs-on: ubuntu-22.04
name: "Acceptance Runner #${{ matrix.runner_index }}: Run acceptance tests in parallel"
# TODO: return check for PR approval here!
if: ${{ github.actor != 'dependabot[bot]'}}
needs: pend
name: "Acceptance Runner"
permissions:
statuses: write
checks: write
if: ${{ needs.shouldRun.outputs.shouldRun == 'true'}}
strategy:
fail-fast: false
matrix:
Expand All @@ -22,7 +81,7 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: adopt
distribution: temurin
java-version: 17
- name: get acceptance test report
uses: dawidd6/action-download-artifact@v2
Expand Down Expand Up @@ -50,6 +109,20 @@ jobs:
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/set-commit-status-action@v2.0.0
if: failure()
with:
status: ${{ job.status }}
context: acceptance-tests-${{matrix.runner_index}}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
description: fail acceptance test batch ${{matrix.runner_index}}
- name: flag passed unit tests
uses: myrotvorets/set-commit-status-action@v2.0.0
if: success()
with:
status: ${{ job.status }}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
- name: cleanup tempfiles
run: rm testList.txt gradleArgs.txt
- name: Upload Acceptance Test Results
Expand All @@ -59,6 +132,6 @@ jobs:
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
if: (success() || failure()) # always run even if the build step fails
with:
report_paths: 'acceptance-tests/tests/build/test-results/acceptanceTest/TEST-*.xml'
13 changes: 9 additions & 4 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,36 @@ name: artifacts

on:
workflow_dispatch:
release:
types:
- created

jobs:
artifacts:
runs-on: ubuntu-22.04
steps:
# TODO: ensure all checks have passed already
- name: checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
distribution: 'temurin'
java-version: '17'
- name: setup gradle
uses: gradle/gradle-build-action@v2
- name: assemble distributions
run: ./gradlew assemble -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
- name: short sha
id: shortSha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: upload tarball
uses: actions/upload-artifact@v3
with:
name: 'tarball'
name: besu-${{ steps.shortSha.outputs.sha }}.tar.gz
path: 'build/distributions/besu*.tar.gz'
- name: upload zipfile
uses: actions/upload-artifact@v3
with:
name: 'zipfile'
name: besu-${{ steps.shortSha.outputs.sha }}.zip
path: 'build/distributions/besu*.zip'

106 changes: 37 additions & 69 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,74 @@
name: "Container Images"
name: docker
on:
workflow_dispatch:

release:
types:
- created

jobs:
buildX64Docker:
runs-on: [X64, Linux]
if: ${{ github.actor != 'dependabot[bot]' }}
hadolint:
runs-on: ubuntu-22.04
steps:
- name: export runner UID
run: echo "runner_uid=$UID" >> $GITHUB_ENV
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 17
cache: gradle
- name: hadoLint_openjdk_11
run: docker run --rm -i hadolint/hadolint < docker/openjdk-11/Dockerfile
- name: hadoLint_openjdk_11_debug
run: docker run --rm -i hadolint/hadolint < docker/openjdk-11-debug/Dockerfile
- name: setup gradle
uses: gradle/gradle-build-action@v2
- name: hadoLint_openj9-jdk_17
run: docker run --rm -i hadolint/hadolint < docker/openj9-jdk-17/Dockerfile
- name: hadoLint_openjdk_17
run: docker run --rm -i hadolint/hadolint < docker/openjdk-17/Dockerfile
- name: hadoLint_openjdk_17_debug
run: docker run --rm -i hadolint/hadolint < docker/openjdk-17-debug/Dockerfile
- name: hadoLint_openjdk_latest
run: docker run --rm -i hadolint/hadolint < docker/openjdk-latest/Dockerfile
- name: hadoLint_graalvm
run: docker run --rm -i hadolint/hadolint < docker/graalvm/Dockerfile
- name: distDocker
uses: gradle/gradle-build-action@v2
with:
arguments: distDocker
- name: test image
run: |
mkdir -p docker/reports
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.9/goss-linux-amd64 -o ./docker/tests/goss-linux-amd64
- name: distDocker
uses: gradle/gradle-build-action@v2
env:
architecture: amd64
with:
arguments: testDocker
- name: Login to DockerHub
if: ${{ github.actor != 'dependabot[bot]' && (contains('refs/heads/release-', github.ref) || github.ref == 'refs/heads/main') }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER_RW }}
password: ${{ secrets.DOCKER_PASSWORD_RW }}
- name: publish
if: ${{ github.actor != 'dependabot[bot]' && (contains('refs/heads/release-', github.ref) || github.ref == 'refs/heads/main') }}
run: ./gradlew --no-daemon "-Pbranch=${{ github.head_ref || github.ref_name }}" dockerUpload
- name: Correct Ownership in GITHUB_WORKSPACE directory
uses: peter-murray/reset-workspace-ownership-action@v1
with:
user_id: ${{ env.runner_uid }}
buildArm64Docker:
runs-on: [self-hosted, ARM64, Linux]
if: ${{ github.actor != 'dependabot[bot]' }}
buildDocker:
runs-on: ubuntu-22.04
needs: hadolint
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
steps:
- name: export runner UID
run: echo "runner_uid=$UID" >> $GITHUB_ENV
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: zulu
architecture: arm64
distribution: adopt
java-version: 17
cache: gradle
- name: Docker login
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: buildDocker
- name: setup gradle
uses: gradle/gradle-build-action@v2
- name: distDocker
uses: gradle/gradle-build-action@v2
env:
architecture: arm64
with:
arguments: distDocker
- name: download image test binary
- name: test image
run: |
mkdir -p docker/reports
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.9/goss-linux-arm -o ./docker/tests/goss-linux-arm64
- name: testDocker
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.9/goss-$PLATFORM-PAIR -o ./docker/tests/goss-$PLATFORM-PAIR
- name: test docker
uses: gradle/gradle-build-action@v2
env:
architecture: arm64
with:
arguments: testDocker
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.actor != 'dependabot[bot]' && (contains('refs/heads/release-', github.ref) || github.ref == 'refs/heads/main') }}
with:
username: ${{ secrets.DOCKER_USER_RW }}
password: ${{ secrets.DOCKER_PASSWORD_RW }}
- name: publish
if: ${{ github.actor != 'dependabot[bot]' && (contains('refs/heads/release-', github.ref) || github.ref == 'refs/heads/main') }}
uses: gradle/gradle-build-action@v2
env:
architecture: arm64
with:
arguments: "-Pbranch=${{ github.head_ref || github.ref_name }} dockerUpload"
- name: Correct Ownership in GITHUB_WORKSPACE directory
uses: peter-murray/reset-workspace-ownership-action@v1
with:
user_id: ${{ env.runner_uid }}
run: ./gradlew --no-daemon -PdockerOrgName=${{ secrets.DOCKER_ORG }} dockerUpload
Loading

0 comments on commit 6a49cc1

Please sign in to comment.