Bump gradle/actions from 3 to 4 #2049
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: CI | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
pull_request: | |
env: | |
build_java_version: 17 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: ${{ env.build_java_version }} | |
- name: Set Up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Build | |
run: ./gradlew build | |
- name: Check project files unmodified | |
run: | | |
directoryState="$(git status --porcelain)" | |
if [ -n "$directoryState" ]; then | |
echo "Some files were modified during build. Please run the build locally before checking in, as it ensures some source file conventions (like copyright header)." | |
echo "The following files were modified:" | |
echo "$directoryState" | |
exit 1 | |
fi | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
test_java_version: | |
- 8 | |
- 11 | |
- 17 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Build JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: ${{ env.build_java_version }} | |
- name: Set up Test JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: ${{ matrix.test_java_version }} | |
- name: Provide installed JDKs | |
uses: actions/github-script@v7 | |
id: provideJdkPaths | |
with: | |
script: | | |
for ( let envVarName in process.env ) { | |
if (/JAVA_HOME_\d.*64/.test(envVarName)) { | |
const version = envVarName.match(/JAVA_HOME_(\d+).*64/)[1]; | |
if (version === "${{ matrix.test_java_version }}") { | |
core.exportVariable('test_jdk_path', process.env[envVarName]); | |
} else if (version === "${{ env.build_java_version }}") { | |
core.exportVariable('build_jdk_path', process.env[envVarName]); | |
} | |
} | |
} | |
- name: Set Up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Test | |
run: ./gradlew test -PallTests -PtestJavaVersion=${{ matrix.test_java_version }} -Porg.gradle.java.installations.paths=${{ env.test_jdk_path }} | |
env: | |
JAVA_HOME: ${{ env.build_jdk_path }} | |
integration-test: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
test_java_version: | |
- 8 | |
- 11 | |
- 17 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Build JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: ${{ env.build_java_version }} | |
- name: Set up Test JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: ${{ matrix.test_java_version }} | |
- name: Provide installed JDKs | |
uses: actions/github-script@v7 | |
id: provideJdkPaths | |
with: | |
script: | | |
for ( let envVarName in process.env ) { | |
if (/JAVA_HOME_\d.*64/.test(envVarName)) { | |
const version = envVarName.match(/JAVA_HOME_(\d+).*64/)[1]; | |
if (version === "${{ matrix.test_java_version }}") { | |
core.exportVariable('test_jdk_path', process.env[envVarName]); | |
} else if (version === "${{ env.build_java_version }}") { | |
core.exportVariable('build_jdk_path', process.env[envVarName]); | |
} | |
} | |
} | |
- name: Set Up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Publish to Maven Local | |
run: ./gradlew build -xtest -xspotbugsMain -xjavadoc publishToMavenLocal | |
env: | |
JAVA_HOME: ${{ env.build_jdk_path }} | |
- name: Integration test | |
run: ./gradlew runMavenTest -PtestJavaVersion=${{ matrix.test_java_version }} -Porg.gradle.java.installations.paths=${{ env.test_jdk_path }} | |
env: | |
JAVA_HOME: ${{ env.build_jdk_path }} |