From d6b4af2d96f4bd4fc5ef9dfe19e485c07f759df0 Mon Sep 17 00:00:00 2001 From: Layue13 Date: Sun, 8 Nov 2026 16:19:50 +0800 Subject: [PATCH 1/2] ci: one workflow run per change, cancel superseded runs, cache the Gradle distribution Pushes to feature branches built twice (push and pull request) and Check Codes repeated the compile in a second workflow. Build now runs only on main, tags and pull requests, cancels older runs of the same ref, folds checkstyle and checkTranslations into the single Gradle invocation, caches the wrapper download and skips apt when xvfb is installed. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/check-codes-comment.yml | 21 -------------- .github/workflows/check-codes.yml | 35 ----------------------- .github/workflows/gradle.yml | 31 +++++++++++++++++--- 3 files changed, 27 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/check-codes-comment.yml delete mode 100644 .github/workflows/check-codes.yml diff --git a/.github/workflows/check-codes-comment.yml b/.github/workflows/check-codes-comment.yml deleted file mode 100644 index b323e1b45f..0000000000 --- a/.github/workflows/check-codes-comment.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Check Codes Comment - -# Disabled on this Gitea fork: the upstream flow depends on reviewdog -# (missing from git.nest.potatolab.uk) and a checkstyle-artifact produced by -# check-codes.yml. Re-enable only after those actions are mirrored or the -# comment path is rewritten without reviewdog. -on: - workflow_dispatch: - -permissions: - actions: read - contents: read - pull-requests: write - -jobs: - comment: - runs-on: ubuntu-latest - if: false - steps: - - name: Disabled - run: echo "check-codes-comment is disabled on this fork" diff --git a/.github/workflows/check-codes.yml b/.github/workflows/check-codes.yml deleted file mode 100644 index 52971f9345..0000000000 --- a/.github/workflows/check-codes.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Check Codes - -on: - workflow_dispatch: - push: - paths: - - '**.java' - - '**.properties' - - '.github/workflows/check-codes.yml' - pull_request: - paths: - - '**.java' - - '**.properties' - - '.github/workflows/check-codes.yml' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - name: Setup JDK 17 - uses: actions/setup-java@v5 - with: - distribution: 'zulu' - java-version: '17' - java-package: 'jdk+fx' - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v5 - with: - cache-cleanup: never - # Keep only Gradle checks. reviewdog/action-setup is not mirrored on - # git.nest.potatolab.uk (404), so PR-comment artifact steps are omitted - # for Gitea Actions / act runners. - - name: Check Codes - run: ./gradlew checkstyle checkTranslations --no-daemon --parallel --stacktrace diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 5a7bacbb54..d31eda06ac 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,11 +1,22 @@ name: Java CI +# Pushes to main and pull requests only. A branch with an open pull request used to build twice +# (once for the push, once for the pull request), which kept the runners queued. on: push: + branches: + - main + tags: + - '*' pull_request: paths-ignore: - '**.md' +# A newer run for the same pull request or branch replaces the older one. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build: @@ -23,12 +34,24 @@ jobs: uses: 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 + uses: actions/cache@v4 + with: + path: | + ~/.gradle/wrapper + .gradle/wrapper-neo + key: gradle-dist-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java') }} - name: Install Xvfb run: | - sudo apt-get update - sudo apt-get install -y xvfb - - name: Build with Gradle - run: xvfb-run --auto-servernum ./gradlew build --no-daemon --parallel + # Skip the slow apt update when the runner image already has it. + command -v xvfb-run >/dev/null || { sudo apt-get update && sudo apt-get install -y 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 + run: xvfb-run --auto-servernum ./gradlew build checkstyle checkTranslations --no-daemon --parallel env: JAVA_TOOL_OPTIONS: -Djava.awt.headless=true MICROSOFT_AUTH_ID: ${{ secrets.MICROSOFT_AUTH_ID }} -- 2.47.3 From e792bfc554c938e86927a317fef1c824d640b3bf Mon Sep 17 00:00:00 2001 From: Layue13 Date: Sun, 8 Nov 2026 16:21:40 +0800 Subject: [PATCH 2/2] ci: try installing xvfb before refreshing the package index Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/gradle.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d31eda06ac..76c24e7d5c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -46,8 +46,10 @@ jobs: key: gradle-dist-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java') }} - name: Install Xvfb run: | - # Skip the slow apt update when the runner image already has it. - command -v xvfb-run >/dev/null || { sudo apt-get update && sudo apt-get install -y xvfb; } + # 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 -- 2.47.3