Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/actions/setup-maven/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 'Set up Maven'
description: 'Restores the Maven caches and installs the wrapper-pinned distribution.'

inputs:
cache-read-only:
description: 'Restore the dependency cache without writing a branch-scoped copy of it.'
required: false
default: 'false'

runs:
using: composite
steps:
# Keyed on the pinned Maven version alone, so dependency updates never evict
# it. It is small enough to always write back, which keeps pull requests from
# re-fetching the distribution from repo.maven.apache.org.
- uses: actions/cache@v6.1.0
with:
path: ~/.m2/wrapper/dists
key: maven-dist-${{ runner.os }}-${{ hashFiles('.mvn/wrapper/maven-wrapper.properties') }}

# The restore keys matter more than the exact hit: a dependency bump then
# resolves against the previous repository and only fetches what changed,
# instead of pulling the whole tree from Maven Central again.
- if: inputs.cache-read-only != 'true'
uses: actions/cache@v6.1.0
with:
path: ~/.m2/repository
key: maven-repo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-repo-${{ runner.os }}-${{ runner.arch }}-

- if: inputs.cache-read-only == 'true'
uses: actions/cache/restore@v6.1.0
with:
path: ~/.m2/repository
key: maven-repo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-repo-${{ runner.os }}-${{ runner.arch }}-

# A cold cache is the only time this reaches the network, but a single
# failed fetch would otherwise take the whole job down with it.
- if: runner.os != 'Windows'
shell: bash
run: |
for attempt in 1 2 3; do
if ./mvnw -v; then
exit 0
fi
echo "Maven distribution download failed (attempt ${attempt} of 3)"
rm -rf ~/.m2/wrapper/dists
sleep $((attempt * 15))
done
echo "::error::Could not install the Maven distribution pinned in .mvn/wrapper/maven-wrapper.properties"
exit 1

- if: runner.os == 'Windows'
shell: pwsh
run: |
foreach ($attempt in 1..3) {
./mvnw.cmd -v
if ($LASTEXITCODE -eq 0) {
exit 0
}
Write-Host "Maven distribution download failed (attempt $attempt of 3)"
Remove-Item -Recurse -Force "$HOME/.m2/wrapper/dists" -ErrorAction SilentlyContinue
Start-Sleep -Seconds (15 * $attempt)
}
Write-Host "::error::Could not install the Maven distribution pinned in .mvn/wrapper/maven-wrapper.properties"
exit 1
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ updates:
actions:
patterns:
- "*"

# "/" only covers .github/workflows, so the composite action needs its own entry.
- package-ecosystem: "github-actions"
directory: "/.github/actions/setup-maven"
schedule:
interval: "monthly"
groups:
actions:
patterns:
- "*"
14 changes: 8 additions & 6 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Grant Permission
run: chmod +x ./mvnw
- uses: actions/setup-java@v6.0.0
with:
distribution: 'corretto'
java-version: '11'
cache-jdk: true
- uses: ./.github/actions/setup-maven
- name: Verify
run: ./mvnw -B -ntp clean verify -DskipTests -Dgpg.skip=true

Expand All @@ -23,12 +23,12 @@ jobs:
needs: Verify
steps:
- uses: actions/checkout@v7
- name: Grant Permission
run: chmod +x ./mvnw
- uses: actions/setup-java@v6.0.0
with:
distribution: 'corretto'
java-version: '11'
cache-jdk: true
- uses: ./.github/actions/setup-maven
- name: Run Tests
run: ./mvnw -B -ntp test -Ddocker.tests=true -Dexternal.tests=true

Expand All @@ -37,12 +37,12 @@ jobs:
needs: Verify
steps:
- uses: actions/checkout@v7
- name: Grant Permission
run: chmod +x ./mvnw
- uses: actions/setup-java@v6.0.0
with:
distribution: 'corretto'
java-version: '11'
cache-jdk: true
- uses: ./.github/actions/setup-maven
- name: Run Tests
run: ./mvnw -B -ntp test -Dexternal.tests=true

Expand All @@ -55,5 +55,7 @@ jobs:
with:
distribution: 'corretto'
java-version: '11'
cache-jdk: true
- uses: ./.github/actions/setup-maven
- name: Run Tests
run: ./mvnw.cmd -B -ntp test "-Dexternal.tests=true"
13 changes: 8 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ jobs:
with:
distribution: 'corretto'
java-version: '11'
- name: Grant Permission
run: chmod +x ./mvnw
cache-jdk: true
- uses: ./.github/actions/setup-maven
with:
cache-read-only: ${{ github.event_name == 'pull_request' }}
- name: Compile and API compatibility check
run: ./mvnw -B -ntp clean verify -DskipTests -Dgpg.skip=true

Expand All @@ -55,9 +57,10 @@ jobs:
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.jdk }}
- name: Grant Permission
if: runner.os != 'Windows'
run: chmod +x ./mvnw
cache-jdk: true
- uses: ./.github/actions/setup-maven
with:
cache-read-only: ${{ github.event_name == 'pull_request' }}
- name: Run Tests (Linux)
if: runner.os == 'Linux'
run: ./mvnw -B -ntp clean test -Ddocker.tests=true
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ jobs:
with:
distribution: 'corretto'
java-version: '11'
cache-jdk: true

- name: Grant Permission
run: chmod +x ./mvnw
- uses: ./.github/actions/setup-maven
with:
cache-read-only: true

- name: Configure Git User
if: inputs.release == true
Expand Down
Loading