Try to improve GitHub Actions cache efficiency

Previously, every individual smoke test would write to and read from
the GitHub Actions cache. This quickly exhausted to 10GB limit,
resulting in cache misses and time spent downloading Gradle and
dependencies.

This commit configures each smoke test's workflow to only read from
the GitHub Actions cache and to never write to it. To populate the
cache, it introduces a new Warm Caches workflow that has read-write
access to the cache. It runs once per branch per day before the
branch's smoke tests run. The intent is that the Warm Caches workflow
will populate the GitHub Actions cache and that each of the
individual smoke tests will then reuse this cache. With each branch
only have a single workflow that writes to the cache, the 10GB limit
should not be exhausted, increasing cache hits.
This commit is contained in:
Andy Wilkinson
2025-01-17 11:16:17 +00:00
parent 5b511adc55
commit c57e2dfcea
13 changed files with 215 additions and 19 deletions

12
.github/workflows/3.0.x-warm-caches.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: 3.0.x | Warm Caches
on:
schedule:
- cron : '0 0 * * *'
workflow_dispatch:
jobs:
warm_caches:
uses: ./.github/workflows/warm-caches.yml
secrets: inherit
with:
checkout_repository: spring-projects/spring-aot-smoke-tests
checkout_ref: 3.0.x

12
.github/workflows/3.1.x-warm-caches.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: 3.1.x | Warm Caches
on:
schedule:
- cron : '10 0 * * *'
workflow_dispatch:
jobs:
warm_caches:
uses: ./.github/workflows/warm-caches.yml
secrets: inherit
with:
checkout_repository: spring-projects/spring-aot-smoke-tests
checkout_ref: 3.1.x

12
.github/workflows/3.2.x-warm-caches.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: 3.2.x | Warm Caches
on:
schedule:
- cron : '20 0 * * *'
workflow_dispatch:
jobs:
warm_caches:
uses: ./.github/workflows/warm-caches.yml
secrets: inherit
with:
checkout_repository: spring-projects/spring-aot-smoke-tests
checkout_ref: 3.2.x

12
.github/workflows/3.3.x-warm-caches.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: 3.3.x | Warm Caches
on:
schedule:
- cron : '30 0 * * *'
workflow_dispatch:
jobs:
warm_caches:
uses: ./.github/workflows/warm-caches.yml
secrets: inherit
with:
checkout_repository: spring-projects/spring-aot-smoke-tests
checkout_ref: 3.3.x

12
.github/workflows/3.4.x-warm-caches.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: 3.4.x | Warm Caches
on:
schedule:
- cron : '40 0 * * *'
workflow_dispatch:
jobs:
warm_caches:
uses: ./.github/workflows/warm-caches.yml
secrets: inherit
with:
checkout_repository: spring-projects/spring-aot-smoke-tests
checkout_ref: main

View File

@@ -52,6 +52,8 @@ jobs:
distribution: 'liberica'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
with:
cache-read-only: true
- name: Configure Gradle user.name
run: |
mkdir -p ~/.gradle

37
.github/workflows/warm-caches.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Smoke Test
on:
workflow_call:
inputs:
checkout_repository:
required: true
type: string
checkout_ref:
required: true
type: string
jobs:
warm_caches:
name: ${{ inputs.task }}
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
repository: ${{ inputs.checkout_repository }}
ref: ${{ inputs.checkout_ref }}
- name: Set up Java
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: ${{ inputs.java_version }}
distribution: 'liberica'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
- name: Configure Gradle user.name
run: |
mkdir -p ~/.gradle
echo 'systemProp.user.name=spring-builds+github' >> ~/.gradle/gradle.properties
- name: Warm Caches
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
REPO_SPRING_IO_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
REPO_SPRING_IO_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: ./gradlew warmCaches