name: Set up Java and Gradle description: >- Installs the repository's pinned Temurin JDK, then configures Gradle through the official setup-gradle action, which validates every checked-in wrapper jar and manages the Gradle cache. # A Gradle job is two lines: checkout, then this action. `actions/checkout` cannot move in here: a # `./.gitea/actions/...` reference is resolved from the checked-out working copy, so this file does # not exist until checkout has run. # # Full URLs, because the runner resolves a bare `owner/name` against its own default action host, # 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. Only a run # on main saves the entry, the rule setup-gradle follows below: the key is fixed and the first entry # saved under it stays, so a branch that saved it first would decide the JDK every later main run # restores, without review. runs: using: composite steps: - if: ${{ github.ref == 'refs/heads/main' }} 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.ref != 'refs/heads/main' }} 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 java-version: "21.0.11+10.0.LTS" # Gradle's own caching, not setup-java's `cache: gradle`. The two cache the same directory with # different keys, and running both is how a job restores one cache and saves the other. - uses: https://github.com/gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # gradle/actions@v6 with: build-scan-publish: false cache-read-only: ${{ github.ref != 'refs/heads/main' }}