mirror of
https://github.com/actions/setup-java.git
synced 2026-07-31 22:51:39 +08:00
* Restore dependency and wrapper caches concurrently Run primary dependency and wrapper cache restores in parallel while preserving existing outputs and save semantics. Add unit and E2E coverage for concurrent restore behavior, wrapper cache validation, and additional-cache error handling. Include a manual benchmark workflow for baseline-vs-candidate restore timing comparisons across OSes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d43ec3dd-96c7-4eb3-909e-b8123cd12d3c * Address PR review comments Use env variables for cache-hit values in benchmark record steps to avoid expression expansion in run commands, and rename E2E restore step labels for clarity. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d43ec3dd-96c7-4eb3-909e-b8123cd12d3c * Stabilize wrapper cache restore checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d43ec3dd-96c7-4eb3-909e-b8123cd12d3c
449 lines
15 KiB
YAML
449 lines
15 KiB
YAML
name: Validate cache
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- releases/*
|
|
paths-ignore:
|
|
- '**.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
gradle-save:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '17'
|
|
cache: gradle
|
|
- name: Create files to cache
|
|
# Need to avoid using Gradle daemon to stabilize the save process on Windows
|
|
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
|
run: |
|
|
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
|
mkdir -p "$HOME/.gradle/wrapper/dists/setup-java-e2e"
|
|
echo "gradle wrapper cache" > "$HOME/.gradle/wrapper/dists/setup-java-e2e/payload"
|
|
bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
|
bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
|
gradle-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
needs: gradle-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: gradle
|
|
cache-read-only: true
|
|
- name: Confirm that ~/.gradle/caches directory has been made
|
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
|
- name: Confirm that the Gradle Wrapper cache has been restored
|
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
|
maven-save:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for maven
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: maven
|
|
- name: Create files to cache
|
|
run: |
|
|
mvn verify -f __tests__/cache/maven/pom.xml
|
|
mkdir -p "$HOME/.m2/wrapper/dists/setup-java-e2e"
|
|
echo "maven wrapper cache" > "$HOME/.m2/wrapper/dists/setup-java-e2e/payload"
|
|
bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
|
bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
|
maven-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
needs: maven-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for maven
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: maven
|
|
cache-read-only: true
|
|
- name: Confirm that ~/.m2/repository directory has been made
|
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
|
- name: Confirm that the Maven Wrapper cache has been restored
|
|
run: bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
|
sbt-save:
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: __tests__/cache/sbt
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for sbt
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: sbt
|
|
- name: Setup SBT
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: |
|
|
echo ""Installing SBT...""
|
|
brew install sbt
|
|
- name: Create files to cache
|
|
run: sbt update
|
|
|
|
- name: Check files to cache on macos-latest
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
|
- name: Check files to cache on windows-latest
|
|
if: matrix.os == 'windows-latest'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
|
- name: Check files to cache on ubuntu-latest
|
|
if: matrix.os == 'ubuntu-22.04'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
|
sbt-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: __tests__/cache/sbt
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
|
needs: sbt-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for sbt
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: sbt
|
|
cache-read-only: true
|
|
|
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
|
if: matrix.os == 'windows-latest'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
|
- name: Confirm that ~/.cache/coursier directory has been made
|
|
if: matrix.os == 'ubuntu-22.04'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
|
gradle1-save:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '17'
|
|
cache: gradle
|
|
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
|
- name: Create files to cache
|
|
# Need to avoid using Gradle daemon to stabilize the save process on Windows
|
|
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
|
run: |
|
|
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
|
mkdir -p "$HOME/.gradle/wrapper/dists/setup-java-e2e-gradle1"
|
|
echo "gradle wrapper cache gradle1" > "$HOME/.gradle/wrapper/dists/setup-java-e2e-gradle1/payload"
|
|
bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
|
bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
|
gradle1-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
needs: gradle1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: gradle
|
|
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
|
|
- name: Confirm that ~/.gradle/caches directory has been made
|
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
|
- name: Confirm that the Gradle Wrapper cache has been restored
|
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
|
gradle2-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
needs: gradle1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for gradle
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: gradle
|
|
cache-dependency-path: __tests__/cache/gradle2/*.gradle*
|
|
- name: Confirm that ~/.gradle/caches directory has not been made
|
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches" absent
|
|
maven1-save:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for maven
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: maven
|
|
cache-dependency-path: __tests__/cache/maven/pom.xml
|
|
- name: Create files to cache
|
|
run: |
|
|
mvn verify -f __tests__/cache/maven/pom.xml
|
|
mkdir -p "$HOME/.m2/wrapper/dists/setup-java-e2e-maven1"
|
|
echo "maven wrapper cache maven1" > "$HOME/.m2/wrapper/dists/setup-java-e2e-maven1/payload"
|
|
bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
|
bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
|
maven1-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
needs: maven1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for maven
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: maven
|
|
cache-dependency-path: __tests__/cache/maven/pom.xml
|
|
- name: Confirm that ~/.m2/repository directory has been made
|
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
|
- name: Confirm that the Maven Wrapper cache has been restored
|
|
run: bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
|
maven2-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
|
needs: maven1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for maven
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: maven
|
|
cache-dependency-path: __tests__/cache/maven2/pom.xml
|
|
- name: Confirm that ~/.m2/repository directory has not been made
|
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository" absent
|
|
sbt1-save:
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: __tests__/cache/sbt
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for sbt
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: sbt
|
|
cache-dependency-path: __tests__/cache/sbt/*.sbt
|
|
- name: Setup SBT
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: |
|
|
echo ""Installing SBT...""
|
|
brew install sbt
|
|
- name: Create files to cache
|
|
run: sbt update
|
|
|
|
- name: Check files to cache on macos-latest
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
|
- name: Check files to cache on windows-latest
|
|
if: matrix.os == 'windows-latest'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
|
- name: Check files to cache on ubuntu-latest
|
|
if: matrix.os == 'ubuntu-22.04'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
|
sbt1-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: __tests__/cache/sbt
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
|
needs: sbt1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for sbt
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: sbt
|
|
cache-dependency-path: __tests__/cache/sbt/*.sbt
|
|
|
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
|
if: matrix.os == 'windows-latest'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
|
- name: Confirm that ~/.cache/coursier directory has been made
|
|
if: matrix.os == 'ubuntu-22.04'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
|
sbt2-restore:
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: __tests__/cache/sbt2
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
|
needs: sbt1-save
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
persist-credentials: false
|
|
- name: Run setup-java with the cache for sbt
|
|
uses: ./
|
|
id: setup-java
|
|
with:
|
|
distribution: 'adopt'
|
|
java-version: '11'
|
|
cache: sbt
|
|
cache-dependency-path: __tests__/cache/sbt2/*.sbt
|
|
|
|
- name: Confirm that ~/Library/Caches/Coursier directory has not been made
|
|
if: matrix.os == 'macos-15-intel'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier" absent
|
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has not been made
|
|
if: matrix.os == 'windows-latest'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache" absent
|
|
- name: Confirm that ~/.cache/coursier directory has not been made
|
|
if: matrix.os == 'ubuntu-22.04'
|
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" absent
|