Skip to content

Commit eacfd77

Browse files
committed
Harmonize CI configuration
This commit harmonizes our CI configuration with Spring Boot, in particular the clever use of reusable custom actions that simplify the workflow definition quite a bit. One main difference compared to Spring Boot is that we can now specify a different distribution for a Java version to test, in preparation for the support of building against 23-ea See gh-32090
1 parent 89338c9 commit eacfd77

File tree

6 files changed

+136
-73
lines changed

6 files changed

+136
-73
lines changed

.github/actions/build/action.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 'Build'
2+
description: 'Builds the project, optionally publishing it to a local deployment repository'
3+
inputs:
4+
java-version:
5+
required: false
6+
default: '17'
7+
description: 'The Java version to compile and test with'
8+
java-distribution:
9+
required: false
10+
default: 'liberica'
11+
description: 'The Java distribution to use for the build'
12+
java-toolchain:
13+
required: false
14+
default: 'false'
15+
description: 'Whether a Java toolchain should be used'
16+
publish:
17+
required: false
18+
default: 'false'
19+
description: 'Whether to publish artifacts ready for deployment to Artifactory'
20+
develocity-access-key:
21+
required: false
22+
description: 'The access key for authentication with ge.spring.io'
23+
outputs:
24+
build-scan-url:
25+
description: 'The URL, if any, of the build scan produced by the build'
26+
value: ${{ (inputs.publish == 'true' && steps.publish.outputs.build-scan-url) || steps.build.outputs.build-scan-url }}
27+
version:
28+
description: 'The version that was built'
29+
value: ${{ steps.read-version.outputs.version }}
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Prepare Gradle Build
34+
uses: ./.github/actions/prepare-gradle-build
35+
with:
36+
develocity-access-key: ${{ inputs.develocity-access-key }}
37+
java-version: ${{ inputs.java-version }}
38+
java-distribution: ${{ inputs.java-distribution }}
39+
java-toolchain: ${{ inputs.java-toolchain }}
40+
- name: Build
41+
id: build
42+
if: ${{ inputs.publish == 'false' }}
43+
shell: bash
44+
run: ./gradlew check antora
45+
- name: Publish
46+
id: publish
47+
if: ${{ inputs.publish == 'true' }}
48+
shell: bash
49+
run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository build publishAllPublicationsToDeploymentRepository
50+
- name: Read Version From gradle.properties
51+
id: read-version
52+
shell: bash
53+
run: |
54+
version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties)
55+
echo "Version is $version"
56+
echo "version=$version" >> $GITHUB_OUTPUT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'Prepare Gradle Build'
2+
description: 'Prepares a Gradle build. Sets up Java and Gradle and configures Gradle properties'
3+
inputs:
4+
java-version:
5+
required: false
6+
default: '17'
7+
description: 'The Java version to use for the build'
8+
java-distribution:
9+
required: false
10+
default: 'liberica'
11+
description: 'The Java distribution to use for the build'
12+
java-toolchain:
13+
required: false
14+
default: 'false'
15+
description: 'Whether a Java toolchain should be used'
16+
develocity-access-key:
17+
required: false
18+
description: 'The access key for authentication with ge.spring.io'
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Set Up Java
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: ${{ inputs.java-distribution }}
26+
java-version: |
27+
${{ inputs.java-version }}
28+
${{ inputs.java-toolchain == 'true' && '17' || '' }}
29+
- name: Set Up Gradle
30+
uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2
31+
with:
32+
cache-read-only: false
33+
develocity-access-key: ${{ inputs.develocity-access-key }}
34+
- name: Configure Gradle Properties
35+
shell: bash
36+
run: |
37+
mkdir -p $HOME/.gradle
38+
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
39+
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
40+
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
41+
echo 'org.gradle.daemon=4' >> $HOME/.gradle/gradle.properties
42+
- name: Configure Toolchain Properties
43+
if: ${{ inputs.java-toolchain == 'true' }}
44+
shell: bash
45+
run: |
46+
echo toolchainVersion=${{ inputs.java-version }} >> $HOME/.gradle/gradle.properties
47+
echo systemProp.org.gradle.java.installations.auto-detect=false >> $HOME/.gradle/gradle.properties
48+
echo systemProp.org.gradle.java.installations.auto-download=false >> $HOME/.gradle/gradle.properties
49+
echo systemProp.org.gradle.java.installations.paths=${{ format('$JAVA_HOME_{0}_X64', inputs.java-version) }} >> $HOME/.gradle/gradle.properties

.github/actions/send-notification/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Send notification
1+
name: Send Notification
22
description: Sends a Google Chat message as a notification of the job's outcome
33
inputs:
44
webhook-url:
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
1-
name: Build and deploy snapshot
1+
name: Build and Deploy Snapshot
22
on:
33
push:
44
branches:
55
- 6.1.x
6+
permissions:
7+
actions: write
68
concurrency:
79
group: ${{ github.workflow }}-${{ github.ref }}
810
jobs:
911
build-and-deploy-snapshot:
10-
if: ${{ github.repository == 'spring-projects/spring-framework' }}
11-
name: Build and deploy snapshot
12+
name: Build and Deploy Snapshot
1213
runs-on: ubuntu-latest
14+
if: ${{ github.repository == 'spring-projects/spring-framework' }}
1315
steps:
14-
- name: Set up Java
15-
uses: actions/setup-java@v4
16-
with:
17-
distribution: 'liberica'
18-
java-version: 17
19-
- name: Check out code
16+
- name: Check Out Code
2017
uses: actions/checkout@v4
21-
- name: Set up Gradle
22-
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
18+
- name: Build and Publish
19+
id: build-and-publish
20+
uses: ./.github/actions/build
2321
with:
24-
cache-read-only: false
25-
- name: Configure Gradle properties
26-
shell: bash
27-
run: |
28-
mkdir -p $HOME/.gradle
29-
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
30-
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
31-
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
32-
echo 'org.gradle.daemon=4' >> $HOME/.gradle/gradle.properties
33-
- name: Build and publish
34-
id: build
35-
env:
36-
CI: 'true'
37-
GRADLE_ENTERPRISE_URL: 'https://ge.spring.io'
38-
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
39-
run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository build publishAllPublicationsToDeploymentRepository
22+
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
23+
publish: true
4024
- name: Deploy
41-
uses: spring-io/[email protected]
25+
uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1
4226
with:
4327
uri: 'https://repo.spring.io'
4428
username: ${{ secrets.ARTIFACTORY_USERNAME }}
@@ -52,11 +36,13 @@ jobs:
5236
/**/framework-api-*.zip::zip.name=spring-framework,zip.deployed=false
5337
/**/framework-api-*-docs.zip::zip.type=docs
5438
/**/framework-api-*-schema.zip::zip.type=schema
55-
- name: Send notification
39+
- name: Send Notification
5640
uses: ./.github/actions/send-notification
5741
if: always()
5842
with:
5943
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
6044
status: ${{ job.status }}
61-
build-scan-url: ${{ steps.build.outputs.build-scan-url }}
62-
run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }}
45+
build-scan-url: ${{ steps.build-and-publish.outputs.build-scan-url }}
46+
run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }}
47+
outputs:
48+
version: ${{ steps.build-and-publish.outputs.version }}

.github/workflows/ci.yml

+11-37
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.ref }}
88
jobs:
99
ci:
10+
name: '${{ matrix.os.name}} | Java ${{ matrix.java.version}}'
11+
runs-on: ${{ matrix.os.id }}
1012
if: ${{ github.repository == 'spring-projects/spring-framework' }}
1113
strategy:
1214
matrix:
@@ -23,56 +25,28 @@ jobs:
2325
name: Linux
2426
java:
2527
version: 17
26-
name: '${{ matrix.os.name}} | Java ${{ matrix.java.version}}'
27-
runs-on: ${{ matrix.os.id }}
2828
steps:
29-
- name: Set up Java
30-
uses: actions/setup-java@v4
31-
with:
32-
distribution: 'liberica'
33-
java-version: |
34-
${{ matrix.java.version }}
35-
${{ matrix.java.toolchain && '17' || '' }}
3629
- name: Prepare Windows runner
3730
if: ${{ runner.os == 'Windows' }}
3831
run: |
3932
git config --global core.autocrlf true
4033
git config --global core.longPaths true
4134
Stop-Service -name Docker
42-
- name: Check out code
35+
- name: Check Out Code
4336
uses: actions/checkout@v4
44-
- name: Set up Gradle
45-
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
46-
with:
47-
cache-read-only: false
48-
- name: Configure Gradle properties
49-
shell: bash
50-
run: |
51-
mkdir -p $HOME/.gradle
52-
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
53-
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
54-
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
55-
echo 'org.gradle.daemon=4' >> $HOME/.gradle/gradle.properties
56-
- name: Configure toolchain properties
57-
if: ${{ matrix.java.toolchain }}
58-
shell: bash
59-
run: |
60-
echo toolchainVersion=${{ matrix.java.version }} >> $HOME/.gradle/gradle.properties
61-
echo systemProp.org.gradle.java.installations.auto-detect=false >> $HOME/.gradle/gradle.properties
62-
echo systemProp.org.gradle.java.installations.auto-download=false >> $HOME/.gradle/gradle.properties
63-
echo systemProp.org.gradle.java.installations.paths=${{ format('$JAVA_HOME_{0}_X64', matrix.java.version) }} >> $HOME/.gradle/gradle.properties
6437
- name: Build
6538
id: build
66-
env:
67-
CI: 'true'
68-
GRADLE_ENTERPRISE_URL: 'https://ge.spring.io'
69-
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
70-
run: ./gradlew check antora
71-
- name: Send notification
39+
uses: ./.github/actions/build
40+
with:
41+
java-version: ${{ matrix.java.version }}
42+
java-distribution: ${{ matrix.java.distribution || 'liberica' }}
43+
java-toolchain: ${{ matrix.java.toolchain }}
44+
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
45+
- name: Send Notification
7246
uses: ./.github/actions/send-notification
7347
if: always()
7448
with:
7549
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
7650
status: ${{ job.status }}
7751
build-scan-url: ${{ steps.build.outputs.build-scan-url }}
78-
run-name: ${{ format('{0} | {1} | Java {2}', github.ref_name, matrix.os.name, matrix.java.version) }}
52+
run-name: ${{ format('{0} | {1} | Java {2}', github.ref_name, matrix.os.name, matrix.java.version) }}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
name: "Validate Gradle Wrapper"
22
on: [push, pull_request]
3-
43
permissions:
54
contents: read
6-
75
jobs:
86
validation:
9-
name: "Validation"
7+
name: "Validate Gradle Wrapper"
108
runs-on: ubuntu-latest
119
steps:
1210
- uses: actions/checkout@v4
13-
- uses: gradle/wrapper-validation-action@v2
11+
- uses: gradle/actions/wrapper-validation@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2

0 commit comments

Comments
 (0)