diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d034c4bc9f..d864302eaf 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -35,11 +35,11 @@ jobs: java-package: 'jdk+fx' cache-jdk: true - # Nest hosts github.com/gradle/actions as actions/gradle-actions. - # On Gitea, setup-gradle's default GitHub Actions cache hits ECONNREFUSED; org repos - # (ForestryMC/IC2) use cache-provider external off github.com and cache Gradle home below. + # Nest mirrors github.com/gradle/actions as actions/gradle-actions (also as gradle/actions). + # v5 rejects cache-provider; v6 supports it. Default on v6 is "enhanced" (commercial) — + # on Gitea use external and cache Gradle home with actions/cache below (org IC2/Forestry pattern). - name: Setup Gradle - uses: actions/gradle-actions/setup-gradle@v5 + uses: actions/gradle-actions/setup-gradle@v6 with: cache-cleanup: never cache-provider: ${{ github.server_url == 'https://github.com' && 'basic' || 'external' }} @@ -56,12 +56,27 @@ jobs: restore-keys: | gradle-home-${{ runner.os }}- + # xvfb apt debs — avoids apt-get update+download on every cold container when Actions cache works. + - name: Cache apt packages + uses: actions/cache@v4 + with: + path: ~/apt-cache + key: apt-xvfb-${{ runner.os }}-${{ runner.arch }} + - name: Install Xvfb run: | - # Installing is the slowest setup step, so skip it when the runner already has xvfb, and - # only refresh the package index when a plain install fails. - command -v xvfb-run >/dev/null || sudo apt-get install -y --no-install-recommends xvfb \ + if command -v xvfb-run >/dev/null; then + exit 0 + fi + sudo mkdir -p /var/cache/apt/archives/partial + if [ -d "${HOME}/apt-cache" ] && [ -n "$(ls -A "${HOME}/apt-cache" 2>/dev/null)" ]; then + sudo cp -a "${HOME}/apt-cache/." /var/cache/apt/archives/ + fi + # Prefer offline/cached debs first; only refresh the index when that fails. + sudo apt-get install -y --no-install-recommends xvfb \ || { sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb; } + mkdir -p "${HOME}/apt-cache" + cp -a /var/cache/apt/archives/*.deb "${HOME}/apt-cache/" 2>/dev/null || true # One Gradle run builds, tests and runs the code and translation checks, so the # project is configured and compiled once instead of in two workflows. diff --git a/.github/workflows/publish-tdlm.yml b/.github/workflows/publish-tdlm.yml index e1dbf7c7a0..175beea3b3 100644 --- a/.github/workflows/publish-tdlm.yml +++ b/.github/workflows/publish-tdlm.yml @@ -55,7 +55,7 @@ jobs: cache-jdk: true - name: Setup Gradle - uses: actions/gradle-actions/setup-gradle@v5 + uses: actions/gradle-actions/setup-gradle@v6 with: cache-cleanup: never cache-provider: ${{ github.server_url == 'https://github.com' && 'basic' || 'external' }} @@ -71,10 +71,25 @@ jobs: restore-keys: | gradle-home-${{ runner.os }}- + - name: Cache apt packages + uses: actions/cache@v4 + with: + path: ~/apt-cache + key: apt-xvfb-${{ runner.os }}-${{ runner.arch }} + - name: Install Xvfb run: | - command -v xvfb-run >/dev/null || sudo apt-get install -y --no-install-recommends xvfb \ + if command -v xvfb-run >/dev/null; then + exit 0 + fi + sudo mkdir -p /var/cache/apt/archives/partial + if [ -d "${HOME}/apt-cache" ] && [ -n "$(ls -A "${HOME}/apt-cache" 2>/dev/null)" ]; then + sudo cp -a "${HOME}/apt-cache/." /var/cache/apt/archives/ + fi + sudo apt-get install -y --no-install-recommends xvfb \ || { sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb; } + mkdir -p "${HOME}/apt-cache" + cp -a /var/cache/apt/archives/*.deb "${HOME}/apt-cache/" 2>/dev/null || true - name: Build executables run: xvfb-run --auto-servernum ./gradlew :HMCL:makeExecutables --no-daemon --parallel