From 9d7e1241188838cd543b0b53962efbb58bcc4e68 Mon Sep 17 00:00:00 2001 From: Matthew Pope <81593196+popematt@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:04:17 -0700 Subject: [PATCH] Use CodeBuild-hosted runners for perf testing and automated publishing (#801) --- ...n-java-performance-regression-detector.yml | 28 ++++++++++++--- .../workflows/publish-release-artifacts.yml | 26 +++++--------- build.gradle.kts | 34 +++++++++++++++---- src/main/java/com/amazon/ion/Span.java | 17 ++-------- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ion-java-performance-regression-detector.yml b/.github/workflows/ion-java-performance-regression-detector.yml index 41b242b974..37d9dccc31 100644 --- a/.github/workflows/ion-java-performance-regression-detector.yml +++ b/.github/workflows/ion-java-performance-regression-detector.yml @@ -46,10 +46,30 @@ jobs: name: ${{env.test_data_id}} path: testData + select-runner-type: + # If you want to use codebuild runners for your personal fork, follow the instructions to set + # up a codebuild project. https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html + # Then, create a repository variable for your fork named `CODEBUILD_PROJECT_NAME` with the name + # of the project you created. + name: Select Runner Type + runs-on: ubuntu-latest + # We want to run on external PRs, but not on internal ones as push automatically builds + # H/T: https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'amazon-ion/ion-java' + env: + use-codebuild: ${{ vars.CODEBUILD_PROJECT_NAME != '' || github.repository_owner == 'amazon-ion' }} + codebuild-project-name: ${{ vars.CODEBUILD_PROJECT_NAME != '' && vars.CODEBUILD_PROJECT_NAME || 'ion-java' }} + al2-arm: "codebuild-${{ vars.CODEBUILD_PROJECT_NAME != '' && vars.CODEBUILD_PROJECT_NAME || 'ion-java' }}-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-large" + outputs: + runner-type: ${{ env.use-codebuild && env.al2_arm || 'ubuntu-latest' }} + steps: + - name: Dump Config + run: echo '${{ toJSON(env) }}' + detect-regression: name: Detect Regression - runs-on: ubuntu-latest - needs: generate-test-data + runs-on: ${{ needs.select-runner-type.outputs.runner-type }} + needs: [ generate-test-data, select-runner-type ] strategy: matrix: test-data: ['nestedStruct', 'nestedList', 'sexp', 'realWorldDataSchema01', 'realWorldDataSchema02', 'realWorldDataSchema03'] @@ -57,11 +77,11 @@ jobs: fail-fast: false steps: - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4.2.1 with: distribution: 'corretto' - java-version: 11 + java-version: 17 - name: Checkout ion-java-benchmark-cli uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 diff --git a/.github/workflows/publish-release-artifacts.yml b/.github/workflows/publish-release-artifacts.yml index fd4ba6816f..40171fbc2b 100644 --- a/.github/workflows/publish-release-artifacts.yml +++ b/.github/workflows/publish-release-artifacts.yml @@ -25,11 +25,16 @@ permissions: contents: read jobs: - check-tag: - # First, a sanity check to ensure that the library version matches the release version - runs-on: ubuntu-latest + publish-to-github-release: + # only run if `check-tag` completes successfully + needs: check-tag + runs-on: "codebuild-ion-java-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-large" + permissions: + contents: write steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v3.6.0 + with: + submodules: recursive - name: Validate project version matches tag shell: bash run: | @@ -39,21 +44,9 @@ jobs: echo "Project Version: $PROJECT_VERSION" echo "Release Tag: $RELEASE_TAG" [ "$PROJECT_VERSION" = "$RELEASE_TAG" ] || exit 1 - publish-to-github-release: - # only run if `check-tag` completes successfully - needs: check-tag - runs-on: ubuntu-latest - permissions: - contents: write - steps: - # TODO: replace with artifact upload/download -- make sure there's no race condition with other builds also - # uploading an artifact. - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v3.6.0 - with: - submodules: recursive - uses: gradle/gradle-build-action@8baac4c8ef753599f92eeb509c246d09d6250fa6 # v3.3.0 with: - arguments: build cyclonedxBom + arguments: build cyclonedxBom publishToSonatype closeAndReleaseSonatypeStagingRepository - name: Upload Jar to GitHub release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -64,4 +57,3 @@ jobs: run: | gh release upload "v$(