This is an automated email from the ASF dual-hosted git repository.

jacopoc pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 3734acdb57e9a2ade75006eac0206de9ecd1a762
Author: Jacopo Cappellato <[email protected]>
AuthorDate: Tue Oct 20 19:33:59 2026 +0200

    Run the Java CI workflow only when it is useful
    
    The ubuntu-latest runners are a limited resource shared by all the ASF
    projects, so avoid using them when the build cannot be affected:
    
    - trigger the workflow only for changes that can affect
      "gradlew check javadoc": changes to documentation (*.md, *.adoc,
      docs/), Windows scripts, legal/info files, Docker/IDE/devcontainer
      setup and other workflows no longer start a build
    - cancel the build of a pull request that is still running or queued
      when a new commit is pushed to it; builds of pushes to trunk and
      release* branches are never cancelled
    - drop the "prep" job, which used a runner only to compute the JDK
      matrix: the matrix is now computed directly with an expression
      (JDK 17 for release* branches, JDK 17 and 21 otherwise)
    
    Co-Authored-By: Claude Opus 5.5
---
 .github/workflows/gradle.yml | 69 ++++++++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index ff75270d20..5e113283e6 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -22,48 +22,61 @@ name: Java CI with Gradle
 on:
   push:
     branches: [ trunk, release* ]
+    # Changes that cannot affect `./gradlew check javadoc` (documentation, 
Docker/IDE/devcontainer
+    # setup, Windows-only scripts, other workflows...) don't trigger the 
build: the ubuntu-latest
+    # runners are a limited resource shared by all the ASF projects.
+    # GitHub evaluates these patterns in order, so a later pattern can 
re-include a path that an
+    # earlier "!" pattern excluded.
+    paths: &build-paths
+      - '**'
+      - '!**.md'
+      - '!**.adoc'
+      - '!**/src/docs/**'
+      - '!docs/**'
+      - '!**.bat'
+      - '!APACHE2_HEADER'
+      - '!INSTALL'
+      - '!LICENSE'
+      - '!NOTICE'
+      - '!OPTIONAL_LIBRARIES'
+      - '!VERSION'
+      - '!.asf.yaml'
+      - '!.devcontainer/**'
+      - '!.dockerignore'
+      - '!.gitattributes'
+      - '!.gitignore'
+      - '!.hgignore'
+      - '!.idea/**'
+      - '!.pre-commit-config.yaml'
+      - '!Dockerfile'
+      - '!docker/**'
+      - '!.github/**'
+      - '.github/workflows/gradle.yml'
   pull_request:
     branches: [ trunk, release* ]
+    paths: *build-paths
+
+# A new push to a pull request makes its previous, still running or queued 
build useless.
+# Pushes to trunk and release* are never cancelled so that every commit gets 
its own result.
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || 
github.ref }}
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
 
 permissions:
   contents: read
 
 jobs:
-  # Computes which JDK versions the build job's matrix should cover. This 
lives in its
-  # own job because the `matrix` context is not available in a job-level 
`if:`, so the
-  # release*-branches-skip-21 rule can't be expressed as a condition on the 
build job
-  # itself - see https://github.com/orgs/community/discussions/37883. Instead 
we shrink
-  # the matrix itself before it reaches the build job.
-  prep:
-    runs-on: ubuntu-latest
-    outputs:
-      java: ${{ steps.set-matrix.outputs.java }}
-    steps:
-    - name: Determine JDK matrix
-      id: set-matrix
-      env:
-        EVENT_NAME: ${{ github.event_name }}
-        REF_NAME: ${{ github.ref_name }}
-        BASE_REF: ${{ github.base_ref }}
-      run: |
-        # release* branches stay JDK 17 only until they adopt JDK 21 too,
-        # since trunk fixes must stay backportable to them.
-        if { [ "$EVENT_NAME" = "push" ] && [[ "$REF_NAME" == release* ]]; } || 
\
-           { [ "$EVENT_NAME" = "pull_request" ] && [[ "$BASE_REF" == release* 
]]; }; then
-          echo 'java=[17]' >> "$GITHUB_OUTPUT"
-        else
-          echo 'java=[17,21]' >> "$GITHUB_OUTPUT"
-        fi
-
   build:
     # trunk builds sourceCompatibility/targetCompatibility 17 bytecode (see 
build.gradle),
     # but is matrix-tested on both the JDK 17 runtime it targets and the JDK 
21 runtime
     # it may adopt later.
-    needs: prep
+    # release* branches stay JDK 17 only until they adopt JDK 21 too, since 
trunk fixes must
+    # stay backportable to them. github.base_ref is the target branch of a 
pull request and is
+    # empty for a push, where github.ref_name is the pushed branch.
     strategy:
       fail-fast: false
       matrix:
-        java: ${{ fromJson(needs.prep.outputs.java) }}
+        java: ${{ startsWith(github.base_ref || github.ref_name, 'release') && 
fromJson('[17]') || fromJson('[17, 21]') }}
 
     runs-on: ubuntu-latest
 

Reply via email to