diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8f81a54d2e..d034c4bc9f 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -21,37 +21,48 @@ jobs: build: runs-on: ubuntu-latest + timeout-minutes: 90 steps: - uses: actions/checkout@v6 + + # Same pattern as TDLM ForestryMC/IndustrialCraft2 setup-build: cache the JDK toolchain. - name: Set up JDK 17 uses: actions/setup-java@v6 with: distribution: 'liberica' java-version: '17' 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. - name: Setup Gradle - # Nest hosts this under actions/gradle-actions (mirror of github.com/gradle/actions). - # uses: gradle/actions/... makes act clone git.nest…/gradle/actions which is not seeded. uses: actions/gradle-actions/setup-gradle@v5 with: cache-cleanup: never - # Only main writes the dependency cache; pull requests read it. - cache-read-only: ${{ github.ref != 'refs/heads/main' }} - # The repository's wrapper downloads Gradle itself, so cache that download too. - - name: Cache Gradle distribution + cache-provider: ${{ github.server_url == 'https://github.com' && 'basic' || 'external' }} + + # Cache wrapper + dependency/build caches (covers what setup-gradle skips under external). + - name: Cache Gradle home uses: actions/cache@v4 with: path: | + ~/.gradle/caches ~/.gradle/wrapper .gradle/wrapper-neo - key: gradle-dist-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java') }} + key: gradle-home-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java', '**/libs.versions.toml', '**/*.gradle.kts', '**/*.gradle') }} + restore-keys: | + gradle-home-${{ runner.os }}- + - 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 \ || { sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb; } + # 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. - name: Build and check with Gradle @@ -60,26 +71,31 @@ jobs: JAVA_TOOL_OPTIONS: -Djava.awt.headless=true MICROSOFT_AUTH_ID: ${{ secrets.MICROSOFT_AUTH_ID }} CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} + - name: Get short SHA run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV + - name: Upload JAR uses: actions/upload-artifact@v7 with: name: HMCL-${{ env.SHORT_SHA }}-jar path: HMCL/build/libs/HMCL-*.jar archive: false + - name: Upload EXE uses: actions/upload-artifact@v7 with: name: HMCL-${{ env.SHORT_SHA }}-exe path: HMCL/build/libs/HMCL-*.exe archive: false + - name: Upload SH uses: actions/upload-artifact@v7 with: name: HMCL-${{ env.SHORT_SHA }}-sh path: HMCL/build/libs/HMCL-*.sh archive: false + - name: Upload DEB uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/publish-tdlm.yml b/.github/workflows/publish-tdlm.yml index 61c241bb2a..e1dbf7c7a0 100644 --- a/.github/workflows/publish-tdlm.yml +++ b/.github/workflows/publish-tdlm.yml @@ -45,25 +45,31 @@ jobs: steps: - uses: actions/checkout@v6 + # Same caching pattern as gradle.yml / TDLM ForestryMC+IC2 setup-build. - name: Set up JDK 17 + JavaFX uses: actions/setup-java@v6 with: distribution: 'liberica' java-version: '17' java-package: 'jdk+fx' + cache-jdk: true - name: Setup Gradle uses: actions/gradle-actions/setup-gradle@v5 with: cache-cleanup: never + cache-provider: ${{ github.server_url == 'https://github.com' && 'basic' || 'external' }} - - name: Cache Gradle distribution + - name: Cache Gradle home uses: actions/cache@v4 with: path: | + ~/.gradle/caches ~/.gradle/wrapper .gradle/wrapper-neo - key: gradle-dist-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java') }} + key: gradle-home-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java', '**/libs.versions.toml', '**/*.gradle.kts', '**/*.gradle') }} + restore-keys: | + gradle-home-${{ runner.os }}- - name: Install Xvfb run: |