Validate cache #17
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: Validate cache | |
on: | |
push: | |
branches: | |
- main | |
- releases/* | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
gradle-save: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, windows-latest, ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run setup-java with the cache for gradle | |
uses: ./ | |
id: setup-java | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
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 | |
if [ ! -d ~/.gradle/caches ]; then | |
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly" | |
exit 1 | |
fi | |
gradle-restore: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, windows-latest, ubuntu-latest] | |
needs: gradle-save | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run setup-java with the cache for gradle | |
uses: ./ | |
id: setup-java | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
cache: gradle | |
- name: Confirm that ~/.gradle/caches directory has been made | |
run: | | |
if [ ! -d ~/.gradle/caches ]; then | |
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly" | |
exit 1 | |
fi | |
ls ~/.gradle/caches/ | |
maven-save: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, windows-latest, ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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 | |
if [ ! -d ~/.m2/repository ]; then | |
echo "::error::The ~/.m2/repository directory does not exist unexpectedly" | |
exit 1 | |
fi | |
maven-restore: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, windows-latest, ubuntu-latest] | |
needs: maven-save | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run setup-java with the cache for maven | |
uses: ./ | |
id: setup-java | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
cache: maven | |
- name: Confirm that ~/.m2/repository directory has been made | |
run: | | |
if [ ! -d ~/.m2/repository ]; then | |
echo "::error::The ~/.m2/repository directory does not exist unexpectedly" | |
exit 1 | |
fi | |
ls ~/.m2/repository | |
sbt-save: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: __tests__/cache/sbt | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, windows-latest, ubuntu-24.04] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- 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-13' | |
run: | | |
echo ""Installing SBT..."" | |
brew install sbt | |
- name: Setup SBT on ubuntu-latest | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
echo ""Installing SBT..."" | |
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list | |
curl -fsL https://repo.scala-sbt.org/scalasbt/debian/sbt-apt-key.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sbt.gpg > /dev/null | |
sudo apt-get update | |
sudo apt-get install -y sbt | |
- name: Create files to cache | |
run: sbt update | |
- name: Check files to cache on macos-latest | |
if: matrix.os == 'macos-13' | |
run: | | |
if [ ! -d ~/Library/Caches/Coursier ]; then | |
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly" | |
exit 1 | |
fi | |
- name: Check files to cache on windows-latest | |
if: matrix.os == 'windows-latest' | |
run: | | |
if [ ! -d ~/AppData/Local/Coursier/Cache ]; then | |
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly" | |
exit 1 | |
fi | |
- name: Check files to cache on ubuntu-latest | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
if [ ! -d ~/.cache/coursier ]; then | |
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly" | |
exit 1 | |
fi | |
sbt-restore: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: __tests__/cache/sbt | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, windows-latest, ubuntu-24.04] | |
needs: sbt-save | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Run setup-java with the cache for sbt | |
uses: ./ | |
id: setup-java | |
with: | |
distribution: 'adopt' | |
java-version: '11' | |
cache: sbt | |
- name: Confirm that ~/Library/Caches/Coursier directory has been made | |
if: matrix.os == 'macos-13' | |
run: | | |
if [ ! -d ~/Library/Caches/Coursier ]; then | |
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly" | |
exit 1 | |
fi | |
ls ~/Library/Caches/Coursier | |
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made | |
if: matrix.os == 'windows-latest' | |
run: | | |
if [ ! -d ~/AppData/Local/Coursier/Cache ]; then | |
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly" | |
exit 1 | |
fi | |
ls ~/AppData/Local/Coursier/Cache | |
- name: Confirm that ~/.cache/coursier directory has been made | |
if: matrix.os == 'ubuntu-24.04' | |
run: | | |
if [ ! -d ~/.cache/coursier ]; then | |
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly" | |
exit 1 | |
fi | |
ls ~/.cache/coursier |