Skip to content

Commit

Permalink
simplify the gha jdk selection and enable the build cache for graalvm
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Sep 29, 2024
1 parent e32eccd commit b643bfe
Show file tree
Hide file tree
Showing 40 changed files with 128 additions and 136 deletions.
71 changes: 28 additions & 43 deletions .github/actions/run-gradle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ inputs:
default: '21'
required: false
description: The GraalVM version
token:
cache-encryption-key:
required: false
description: 'A Github PAT'
description: A Gradle cache encryption key
attempt-limit:
default: '1'
required: false
Expand All @@ -29,68 +29,53 @@ inputs:
runs:
using: composite
steps:
- name: Prepare OpenJDK
if: inputs.java != 'GraalVM'
shell: bash
run: echo "JAVA_VERSION=${{ inputs.java }}" >> $GITHUB_ENV
- name: Prepare GraalVM
if: inputs.java == 'GraalVM'
- name: Read Gradle JDK toolchain version
shell: bash
run: |
echo "GRAALVM=true" >> $GITHUB_ENV
echo "JAVA_VERSION=${{ inputs.graal }}" >> $GITHUB_ENV
- name: Set up JDK ${{ inputs.java }}
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
if: (inputs.early-access != inputs.java) && (inputs.java != 'GraalVM')
toolchainVersion=$(grep -oP '(?<=^toolchainVersion=).*' gradle/gradle-daemon-jvm.properties)
echo "toolchainVersion=${toolchainVersion}" >> $GITHUB_ENV
- name: Set up JDK ${{ env.toolchainVersion }}
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
java-version: ${{ inputs.java }}
java-version: ${{ env.toolchainVersion }}
distribution: temurin
- name: Set up JDK ${{ inputs.java }}
uses: oracle-actions/setup-java@2e744f723b003fdd759727d0ff654c8717024845 # v1.4.0
if: (inputs.early-access == inputs.java) && (inputs.java != 'GraalVM')
with:
release: ${{ inputs.java }}
website: jdk.java.net
version: latest
- name: Set up GraalVM
uses: graalvm/setup-graalvm@22cc13fe88ef133134b3798e128fb208df55e1f5 # v1.2.3
if: inputs.java == 'GraalVM'
- name: Prepare JDK toolchain
shell: bash
run: |
if [[ "${{ inputs.java }}" == "GraalVM" ]]; then
echo "JAVA_VENDOR=GraalVM Community" >> $GITHUB_ENV
echo "JAVA_VERSION=${{ inputs.graal }}" >> $GITHUB_ENV
else
echo "JAVA_VENDOR=Adoptium" >> $GITHUB_ENV
echo "JAVA_VERSION=${{ inputs.java }}" >> $GITHUB_ENV
fi
- name: Set up JDK
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
distribution: 'graalvm'
github-token: ${{ inputs.token }}
java-version: ${{ env.JAVA_VERSION }}
java-version: ${{
inputs.java == 'GraalVM' && inputs.graal ||
(inputs.early-access == inputs.java && format('{0}-ea', inputs.java) || inputs.java) }}
distribution: ${{ inputs.java == 'GraalVM' && 'graalvm' || 'temurin' }}
- name: Prepare JDK ${{ inputs.java }}
shell: bash
run: |
if [[ "${{ inputs.java }}" == "GraalVM" ]]; then
echo "GRAALVM_HOME=$JAVA_HOME" >> $GITHUB_ENV
fi
echo "JDK_CI=$JAVA_HOME" >> $GITHUB_ENV
echo "JDK_EA=${{ inputs.early-access == inputs.java }}" >> $GITHUB_ENV
- name: Read Gradle JDK toolchain version
id: read-jdk-version
shell: bash
run: |
toolchainVersion=$(grep -oP '(?<=^toolchainVersion=).*' gradle/gradle-daemon-jvm.properties)
echo "toolchainVersion=${toolchainVersion}" >> $GITHUB_ENV
- name: Set up JDK ${{ env.toolchainVersion }}
id: setup-gradle-jdk
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
if: inputs.java != 'GraalVM'
with:
java-version: ${{ env.toolchainVersion }}
distribution: temurin
- name: Setup Gradle
id: setup-gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
env:
JAVA_HOME: ${{ steps.setup-gradle-jdk.outputs.path }}
ORG_GRADLE_PROJECT_org.gradle.java.installations.auto-download: 'false'
with:
add-job-summary: never
cache-read-only: false
gradle-home-cache-strict-match: true
cache-encryption-key: ${{ inputs.cache-encryption-key }}
- name: Run ${{ inputs.arguments }}
if: ${{ inputs.arguments != '' }}
env:
JAVA_HOME: ${{ steps.setup-gradle-jdk.outputs.path }}
ORG_GRADLE_PROJECT_org.gradle.java.installations.auto-download: 'false'
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
allowed-endpoints: >
api.github.com:443
github.com:443
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: actionlint
uses: reviewdog/action-actionlint@12f7cb8c93ab327c99dec3a1d502c0f314978afd # v1.55.0
env:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Forbidden Apis
uses: ./.github/actions/run-gradle
with:
java: ${{ env.JAVA_VERSION }}
arguments: forbiddenApis -DforbiddenApis
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

pmd:
runs-on: ubuntu-latest
Expand All @@ -49,11 +50,12 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Pmd
uses: ./.github/actions/run-gradle
with:
java: ${{ env.JAVA_VERSION }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: pmdJavaPoet pmdMain pmdCodeGen pmdJmh pmdTest -Dpmd

spotbugs:
Expand All @@ -67,10 +69,11 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }}
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Spotbugs
uses: ./.github/actions/run-gradle
with:
java: ${{ env.JAVA_VERSION }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
spotbugsJavaPoet spotbugsMain spotbugsCodeGen spotbugsJmh spotbugsTest -Dspotbugs
12 changes: 6 additions & 6 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
raw.githubusercontent.com:443
services.gradle.org:443
www.graalvm.org:443
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Compute JMH Benchmark
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
-PincludePattern=ComputeBenchmark
Expand All @@ -66,7 +66,7 @@ jobs:
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
-PincludePattern=GetPutBenchmark
Expand All @@ -88,7 +88,7 @@ jobs:
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
-PincludePattern=PutRemoveBenchmark
Expand All @@ -97,7 +97,7 @@ jobs:
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
-PincludePattern=FrequencySketchBenchmark
Expand All @@ -106,7 +106,7 @@ jobs:
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: caffeine:jmh --no-daemon -q -PincludePattern=TimerWheelBenchmark
- name: Publish JMH benchmarks
if: >
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ env:
schemastore.org:443
www.graalvm.org:443
PUBLISH_JDK: 11
EA_JDK: 24

jobs:
compile:
Expand All @@ -59,18 +58,13 @@ jobs:
egress-policy: block
allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }}
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Prepare GraalVM
if: env.JAVA_VERSION == 'GraalVM'
shell: bash
run: echo "GRADLE_ARGS=--no-build-cache" >> $GITHUB_ENV
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Compile
uses: ./.github/actions/run-gradle
with:
java: ${{ env.JAVA_VERSION }}
early-access: ${{ env.EA_JDK }}
token: ${{ secrets.GITHUB_TOKEN }}
arguments: check -x test ${{ env.GRADLE_ARGS }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Cancel if failed
uses: andymckay/cancel-action@a955d435292c0d409d104b57d8e78435a93a6ef1 # 0.5
continue-on-error: true
Expand Down Expand Up @@ -176,13 +170,13 @@ jobs:
egress-policy: block
allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }}
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Run tests (${{ env.JAVA_VERSION }})
uses: ./.github/actions/run-gradle
with:
java: ${{ env.JAVA_VERSION }}
arguments: ${{ matrix.suite }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Format Test Artifact Name
if: always() && (env.JAVA_VERSION == env.PUBLISH_JDK)
run: |
Expand Down Expand Up @@ -233,7 +227,7 @@ jobs:
storage.googleapis.com:443
uploader.codecov.io:443
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
- name: Download Tests Results
Expand All @@ -245,13 +239,15 @@ jobs:
with:
arguments: check -x test
java: ${{ env.PUBLISH_JDK }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Publish to Coveralls
uses: ./.github/actions/run-gradle
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
with:
arguments: coveralls
java: ${{ env.PUBLISH_JDK }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
continue-on-error: true
- name: Publish to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
Expand All @@ -277,6 +273,7 @@ jobs:
with:
java: ${{ env.PUBLISH_JDK }}
arguments: sonar -Dsonar.branch.name=${GITHUB_REF##*/}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
continue-on-error: true

test-results:
Expand Down Expand Up @@ -351,7 +348,7 @@ jobs:
errorprone.info:443
lightbend.github.io:443
guava.dev:443
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Publish Snapshot
uses: ./.github/actions/run-gradle
env:
Expand All @@ -364,5 +361,5 @@ jobs:
attempt-limit: 3
attempt-delay: 2
java: ${{ env.PUBLISH_JDK }}
token: ${{ secrets.GITHUB_TOKEN }}
arguments: publishToSonatype --no-configuration-cache
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
4 changes: 2 additions & 2 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
registry-1.docker.io:443
*.blob.core.windows.net:443
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Run Codacy Analysis
uses: codacy/codacy-analysis-cli-action@97bf5df3c09e75f5bcd72695998f96ebd701846e # v4.4.5
continue-on-error: true
Expand All @@ -47,7 +47,7 @@ jobs:
if: steps.check_files.outputs.files_exists == 'true'
run: jq -c '.runs |= unique_by({tool, invocations, results})' < results.sarif > codacy.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
if: steps.check_files.outputs.files_exists == 'true'
continue-on-error: true
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ jobs:
uploads.github.com:443
services.gradle.org:443
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup Gradle
uses: ./.github/actions/run-gradle
with:
java: ${{ env.JAVA_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Initialize CodeQL
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/init@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
with:
languages: java
- name: Autobuild
uses: github/codeql-action/autobuild@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/autobuild@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/analyze@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
5 changes: 3 additions & 2 deletions .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,23 @@ jobs:
raw.githubusercontent.com:443
services.gradle.org:443
www.cisa.gov:443
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Run dependency-check
uses: ./.github/actions/run-gradle
continue-on-error: true
env:
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
with:
java: ${{ env.JAVA_VERSION }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: dependencyCheckAggregate --no-configuration-cache
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
with:
files: build/reports/dependency-check-report.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
if: steps.check_files.outputs.files_exists == 'true'
with:
sarif_file: build/reports/dependency-check-report.sarif
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
api.github.com:443
github.com:443
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Dependency Review
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependency-submission-pr-submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
repo.maven.apache.org:443
repo1.maven.org:443
services.gradle.org:443
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
Expand Down
Loading

0 comments on commit b643bfe

Please sign in to comment.