ci: Gradle job마다 JDK를 내려받지 않고 runner 캐시에서 복원한다

문제: job 컨테이너가 매번 새것이라 setup-java가 빈 tool cache를 보고 Temurin
21.0.11(약 190MB)을 job마다 GitHub에서 받는다. job 하나에 21~23초, nightly
한 번(Gradle job 28개)에 약 9.5분, release 수동 한 번에 약 4분이다. 11-09에는
같은 GitHub 내려받기가 504로 실패한 job도 있었다.

고른 방법: setup-java 앞에서 actions/cache v4.3.0(node20, 커밋 SHA 고정)으로
setup-java가 설치하는 tool cache 폴더를 복원한다. setup-java는 tool cache를
먼저 보므로 복원되면 내려받지 않는다. 키는 Temurin 빌드 하나를 가리키므로
어느 브랜치에서 저장해도 내용이 같다. pull request는 읽기만 한다(검토 중인
코드가 JDK를 바꿔 넣지 못하게). push·schedule·수동 실행은 쓰기 권한자만
시작할 수 있어 저장을 허용한다.

버린 대안: JDK가 든 runner 이미지 쓰기. runner 설정은 다른 저장소(platform-core)다.

위험·한계: runner 캐시 상한은 5GB다. 이 항목은 압축 후 약 150~200MB다.

검증: runner 수동 실행 두 번째 Gradle job부터 「Trying to download」가 없는지,
setup 시간(이 PR 본문에 적는다).
This commit is contained in:
DongHyeonka
2026-11-12 01:18:24 +09:00
parent deeb1126b5
commit 96caf997f8
@@ -11,9 +11,27 @@ description: >-
# and a pinned commit SHA, the only immutable action reference. The JDK is the version in
# .tool-versions under the name Temurin publishes it (`+10.0.LTS`); setup-java rejects `+10`.
# The JDK comes from the runner's cache when it can. Every job starts in a fresh container, so
# setup-java found an empty tool cache and downloaded the same 190 MB from GitHub in every job (about
# 22 of the 25 seconds a job spent before Gradle, and the step that failed with 504s). setup-java
# looks in the tool cache first, so restoring the directory it installs into is enough. A pull
# request only reads the entry, so code under review cannot put a JDK in it; a push, a schedule or
# a manual run, which only a writer can start, may save it. The key names one Temurin build, so the
# entry is the same whichever branch saves it. setup-gradle below is stricter (main only), because
# a Gradle home differs by branch.
runs:
using: composite
steps:
- if: ${{ github.event_name != 'pull_request' }}
uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache@v4.3.0
with:
path: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
key: jdk-temurin-21.0.11+10.0.LTS-${{ runner.os }}-${{ runner.arch }}
- if: ${{ github.event_name == 'pull_request' }}
uses: https://github.com/actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache/restore@v4.3.0
with:
path: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
key: jdk-temurin-21.0.11+10.0.LTS-${{ runner.os }}-${{ runner.arch }}
- uses: https://github.com/actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # actions/setup-java@v4.7.1
with:
distribution: temurin