This is an automated email from the ASF dual-hosted git repository. jdaugherty pushed a commit to branch ci/conserve-actions-minutes in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 9f252b01dff7433a5b0c4536d4584741e3c12782 Author: James Daugherty <[email protected]> AuthorDate: Mon Oct 19 09:58:29 2026 -0400 [run tests] Gate CI through one policy: draft and "no ci" pull requests, and tests by branch and commit marker A draft pull request runs no job of any workflow unless it carries the "run ci" label, and a pull request labelled "no ci" runs none at all. The check skips the policy job that every job of the CI and Groovy joint workflows needs, and the jobs of the workflows without tests (code style, build health, RAT, CodeQL, vulnerability scan) carry it directly. Every pull_request trigger lists ready_for_review, which is not a default type, so marking a draft ready starts CI. Every workflow that runs tests now calls .github/workflows/ci-policy.yml as its first job and gates its test jobs, and the test steps of its build jobs, on the policy's run-tests output. On a release branch below the default branch, and on a pull request whose base is a side branch rather than a release branch, the tests run only when the commit message starts with [run tests]; on the default branch and every release branch above it they run unless it starts with [skip tests]. The policy reads the head commit of a pull request or a dispatched branch through the API, so the markers now work on pull requests too; the github.event.head_commit.message test it replaces is empty on pull_request events, so every pull request ran the tests whatever the message said. The decision and its reason are written to the job summary. Documented as rule 14 and the "CI policy" section of AGENTS.md, and in the "Continuous Integration" section of CONTRIBUTING.md. --- .github/workflows/build-health.yml | 15 ++++ .github/workflows/ci-policy.yml | 104 ++++++++++++++++++++++++++++ .github/workflows/codeql.yml | 7 ++ .github/workflows/codestyle.yml | 15 ++++ .github/workflows/gradle.yml | 46 ++++++++---- .github/workflows/groovy-joint-workflow.yml | 14 +++- .github/workflows/rat.yml | 7 ++ .github/workflows/vulnerability-scan.yml | 6 +- AGENTS.md | 11 +++ CONTRIBUTING.md | 14 ++++ 10 files changed, 225 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-health.yml b/.github/workflows/build-health.yml index 2f54bdc68b..5ad31aac89 100644 --- a/.github/workflows/build-health.yml +++ b/.github/workflows/build-health.yml @@ -19,6 +19,8 @@ on: branches: - '[0-9]+.[0-9]+.x' pull_request: + # ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci". + types: [ opened, synchronize, reopened, ready_for_review ] workflow_dispatch: # queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits concurrency: @@ -27,8 +29,13 @@ concurrency: permissions: contents: read jobs: + # A pull request labelled "no ci", or a draft without the "run ci" label, skips every job of this workflow. check_core_projects: name: "Core Projects" + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-24.04 steps: - name: "🌐 Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it @@ -72,6 +79,10 @@ jobs: done check_gradle_plugin_projects: name: "Gradle Plugin Projects" + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-24.04 steps: - name: "🌐 Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it @@ -113,6 +124,10 @@ jobs: fi check_grails_forge_projects: name: "Forge Projects" + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-24.04 steps: - name: "🌐 Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it diff --git a/.github/workflows/ci-policy.yml b/.github/workflows/ci-policy.yml new file mode 100644 index 0000000000..e5d78ace65 --- /dev/null +++ b/.github/workflows/ci-policy.yml @@ -0,0 +1,104 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Decides, once per run of a calling workflow, whether that workflow's test jobs run. Every workflow that +# runs tests calls this workflow as its first job, `policy`, and gates its test jobs on the run-tests +# output, so the rules live here and nowhere else; see the "CI policy" section of AGENTS.md for the +# reasons behind them. +# +# The tests run when the first line of the commit message starts with [run tests] and do not run when it +# starts with [skip tests]; a marker anywhere else is ignored. Without a marker the target branch +# decides: the default branch and every release branch above it run the tests; a release branch below +# the default (7.0.x while 8.0.x is the default) and a branch that is not a release branch (the base of +# a feature-to-feature pull request) build and publish without them. The commit is the head commit of +# the push, of the pull request, or of the dispatched branch. +# +# The "no ci" label and the draft rule (a draft runs nothing without the "run ci" label) are not handled +# here: the calling job carries them in its `if`, so such a pull request runs no job at all, not even this one. +name: "CI policy" +on: + workflow_call: + outputs: + run-tests: + description: "'true' when the calling workflow runs its test jobs, 'false' when it runs only its build and publish jobs" + value: ${{ jobs.decide.outputs.run-tests }} +permissions: + contents: read +jobs: + decide: + name: "Decide whether the tests run" + runs-on: ubuntu-24.04 + outputs: + run-tests: ${{ steps.decide.outputs.run-tests }} + steps: + - name: "⚖️ Apply the CI policy" + id: decide + # The commit message is untrusted input (a pull request may come from any fork), so it reaches the + # script only through the environment, never through expression interpolation. + env: + GH_TOKEN: ${{ github.token }} + EVENT_NAME: ${{ github.event_name }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} + HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + PUSH_MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail + if [[ "$EVENT_NAME" == push ]]; then + message="$PUSH_MESSAGE" + else + # A pull_request or workflow_dispatch payload carries no commit message, so read the head commit. + message="$(gh api "repos/${GITHUB_REPOSITORY}/commits/${HEAD_SHA}" --jq '.commit.message')" + fi + subject="${message%%$'\n'*}" + subject="${subject#"${subject%%[![:space:]]*}"}" + + run_tests=true + if [[ "$subject" == '[skip tests]'* ]]; then + run_tests=false + reason="the commit message starts with [skip tests]" + elif [[ "$subject" == '[run tests]'* ]]; then + reason="the commit message starts with [run tests]" + elif [[ "$TARGET_BRANCH" =~ ^([0-9]+)\.([0-9]+)\.x$ ]]; then + target_major=${BASH_REMATCH[1]} + target_minor=${BASH_REMATCH[2]} + if [[ "$DEFAULT_BRANCH" =~ ^([0-9]+)\.([0-9]+)\.x$ ]]; then + default_major=${BASH_REMATCH[1]} + default_minor=${BASH_REMATCH[2]} + if (( target_major < default_major || (target_major == default_major && target_minor < default_minor) )); then + run_tests=false + reason="$TARGET_BRANCH is below the default branch $DEFAULT_BRANCH and the commit message does not start with [run tests]" + else + reason="$TARGET_BRANCH is the default branch $DEFAULT_BRANCH or above it and the commit message does not start with [skip tests]" + fi + else + reason="the default branch '$DEFAULT_BRANCH' is not a release branch" + fi + else + run_tests=false + reason="'$TARGET_BRANCH' is not a release branch and the commit message does not start with [run tests]" + fi + + echo "run-tests=$run_tests" >> "$GITHUB_OUTPUT" + decision="Tests run: $run_tests, because $reason." + echo "$decision" + echo "Decided for $EVENT_NAME on $TARGET_BRANCH at $HEAD_SHA: $subject" + { + echo "### ⚖️ CI policy" + echo + echo "$decision" + echo + echo "Event \`$EVENT_NAME\`, branch \`$TARGET_BRANCH\`, commit \`${HEAD_SHA:0:10}\`: $subject" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bc1430f8c7..01a9eca423 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,6 +31,8 @@ on: branches: - '[4-9]+.[0-9]+.x' pull_request: + # ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci". + types: [ opened, synchronize, reopened, ready_for_review ] # The branches below must be a subset of the branches above branches: - '[4-9]+.[0-9]+.x' @@ -39,8 +41,13 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + # A pull request labelled "no ci", or a draft without the "run ci" label, skips every job of this workflow. analyze: name: Analyze + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-latest permissions: actions: read diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index d2db8eb3d5..34ab065679 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -19,14 +19,21 @@ on: branches: - '[0-9]+.[0-9]+.x' pull_request: + # ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci". + types: [ opened, synchronize, reopened, ready_for_review ] workflow_dispatch: # queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + # A pull request labelled "no ci", or a draft without the "run ci" label, skips every job of this workflow. check_core_projects: name: "Core Projects" + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-24.04 steps: - name: "🌐 Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it @@ -69,6 +76,10 @@ jobs: done check_gradle_plugin_projects: name: "Gradle Plugin Projects" + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-24.04 steps: - name: "🌐 Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it @@ -112,6 +123,10 @@ jobs: done check_grails_forge_projects: name: "Forge Projects" + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-24.04 steps: - name: "🌐 Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 43275fef33..63a144f4cc 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -19,14 +19,26 @@ on: branches: - '[0-9]+.[0-9]+.x' pull_request: + # ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci". + types: [ opened, synchronize, reopened, ready_for_review ] workflow_dispatch: # Queue jobs - cancel in-progress PR runs when new commits pushed, but allow branch builds to complete concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + policy: + name: "CI policy" + # A pull request labelled "no ci", or a draft without the "run ci" label, skips this job; every other + # job needs it, so nothing runs for such a pull request. + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) + uses: ./.github/workflows/ci-policy.yml validateDependencies: name: 'Validate Dependency Versions' + needs: [ policy ] runs-on: ubuntu-24.04 steps: - name: "📥 Checkout repository" @@ -58,6 +70,7 @@ jobs: --stacktrace buildGradle: name: 'Build Gradle Plugins' + needs: [ policy ] strategy: fail-fast: false matrix: @@ -85,7 +98,7 @@ jobs: - name: "🔍 Setup TestLens" uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2 - name: "🔨 Build project without tests" - if: ${{ contains(github.event.head_commit.message, '[skip tests]') }} + if: ${{ needs.policy.outputs.run-tests != 'true' }} working-directory: 'grails-gradle' run: > ./gradlew build @@ -94,7 +107,7 @@ jobs: -PskipCodeStyle -PskipTests - name: "🔨 Build project with tests" - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + if: ${{ needs.policy.outputs.run-tests == 'true' }} working-directory: 'grails-gradle' run: > ./gradlew build @@ -103,7 +116,8 @@ jobs: --rerun-tasks -PskipCodeStyle build: - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} name: 'Build Grails-Core' strategy: fail-fast: false @@ -155,7 +169,8 @@ jobs: -PonlyCoreTests -PskipCodeStyle buildRerunTasks: - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} name: 'Build Grails-Core Rerunning all Tasks' strategy: fail-fast: false @@ -195,6 +210,7 @@ jobs: -PskipCodeStyle buildForge: name: "Build Grails Forge" + needs: [ policy ] strategy: fail-fast: false matrix: @@ -222,7 +238,7 @@ jobs: - name: "🔍 Setup TestLens" uses: testlens-app/setup-testlens@d96a555133c275a00949d2cc77b70fe9a4242ebf # v1.9.2 - name: "🔨 Build project without tests" - if: ${{ contains(github.event.head_commit.message, '[skip tests]') }} + if: ${{ needs.policy.outputs.run-tests != 'true' }} working-directory: 'grails-forge' run: > ./gradlew build @@ -231,7 +247,7 @@ jobs: -PskipCodeStyle -PskipTests - name: "🔨 Build project with tests" - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + if: ${{ needs.policy.outputs.run-tests == 'true' }} working-directory: 'grails-forge' run: > ./gradlew build @@ -257,7 +273,8 @@ jobs: if-no-files-found: 'error' functional: name: "Functional Tests" - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} strategy: fail-fast: false matrix: @@ -305,7 +322,8 @@ jobs: if-no-files-found: ignore security: name: "Spring Security Tests" - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} strategy: fail-fast: false matrix: @@ -342,7 +360,8 @@ jobs: -PskipCodeStyle securityConfig: name: "Spring Security Config Functional Tests" - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} strategy: fail-fast: false matrix: @@ -385,7 +404,8 @@ jobs: -PskipCodeStyle redis: name: "Redis Tests" - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -423,7 +443,8 @@ jobs: -PredisContainerVersion=${{ matrix.redis-version }} -PskipCodeStyle mongodbFunctional: - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} name: "Mongodb Functional Tests" runs-on: ubuntu-24.04 strategy: @@ -462,7 +483,8 @@ jobs: -PmongodbContainerVersion=${{ matrix.mongodb-version }} -PskipCodeStyle hibernate5Functional: - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [ policy ] + if: ${{ needs.policy.outputs.run-tests == 'true' }} name: "Hibernate5 Functional Tests" runs-on: ubuntu-24.04 strategy: diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml index 8294c269f0..c3524f10cc 100644 --- a/.github/workflows/groovy-joint-workflow.yml +++ b/.github/workflows/groovy-joint-workflow.yml @@ -19,6 +19,8 @@ on: branches: - '[4-9]+.[0-9]+.x' pull_request: + # ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci". + types: [ opened, synchronize, reopened, ready_for_review ] branches: - '[4-9]+.[0-9]+.x' workflow_dispatch: @@ -29,8 +31,18 @@ concurrency: permissions: contents: read jobs: + policy: + name: "CI policy" + # A pull request labelled "no ci", or a draft without the "run ci" label, skips this job; every other + # job needs it, so nothing runs for such a pull request. + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) + uses: ./.github/workflows/ci-policy.yml build_groovy: - if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }} + needs: [policy] + if: ${{ needs.policy.outputs.run-tests == 'true' }} runs-on: ubuntu-latest outputs: groovyVersion: ${{ steps.groovy-version.outputs.value }} diff --git a/.github/workflows/rat.yml b/.github/workflows/rat.yml index 83f2f4f375..37ef2bff79 100644 --- a/.github/workflows/rat.yml +++ b/.github/workflows/rat.yml @@ -21,6 +21,8 @@ on: - '[3-9]+.[3-9]+.x' - license-audit pull_request: + # ready_for_review is not a default type: a draft runs nothing until it is ready or labelled "run ci". + types: [ opened, synchronize, reopened, ready_for_review ] branches: - '[4-9]+.[0-9]+.x' - '[3-9]+.[3-9]+.x' @@ -31,7 +33,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: + # A pull request labelled "no ci", or a draft without the "run ci" label, skips every job of this workflow. rat-audit: + if: >- + github.event_name != 'pull_request' + || (!contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))) runs-on: ubuntu-latest steps: - name: "📥 Checkout repository" diff --git a/.github/workflows/vulnerability-scan.yml b/.github/workflows/vulnerability-scan.yml index 43dfa035cb..8c48b7baf2 100644 --- a/.github/workflows/vulnerability-scan.yml +++ b/.github/workflows/vulnerability-scan.yml @@ -22,7 +22,8 @@ on: # Opt in per pull request by applying the "vulnerability scan" label. Applying a label # requires write access, so only a committer can start a scan. pull_request: - types: [labeled, synchronize, reopened] + # ready_for_review is not a default type: a labelled draft is scanned once it is ready or labelled "run ci". + types: [labeled, synchronize, reopened, ready_for_review] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} @@ -67,9 +68,12 @@ jobs: scan-pull-request: name: "Vulnerability Scan - pull request" # `synchronize` and `reopened` re-scan a pull request that already carries the label. + # A pull request labelled "no ci", or a draft without the "run ci" label, is never scanned. if: >- github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'vulnerability scan') + && !contains(github.event.pull_request.labels.*.name, 'no ci') + && (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci')) runs-on: ubuntu-24.04 permissions: contents: read diff --git a/AGENTS.md b/AGENTS.md index 606d38120d..28830b981d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -57,6 +57,7 @@ export GRADLE_OPTS="-Xms2G -Xmx5G" 11. **The BOM must manage the latest version** - `validateDependencyVersions` enforces that the BOM (`dependencies.gradle`) manages a version `>=` every transitively-resolved version. When it fails, **bump the version in `dependencies.gradle`** so the BOM wins — never silence it with `allowedBomOverrides` or an exclusion unless there is an explicit, documented conflict or an agreed-upon workaround. See [Dependency Management](#dependency-management). 12. **GitHub Actions must use ASF-approved references** - Every third-party action SHA must appear in the ASF allowlist; `actions/*` use the full tag of their latest release and `apache/*` use version or branch references, never SHAs. See [GitHub Actions](#github-actions). 13. **Workflows cache Gradle through one policy** - Every `setup-gradle` step takes `cache-read-only` from `.github/actions/gradle-cache-policy`; never write `true` or `false` there, never cache `~/.gradle` with `actions/cache`, and never pass `cache-writer` outside the core build. See [Gradle caching](#gradle-caching). +14. **Workflows run tests through one policy** - Every workflow that runs tests calls `.github/workflows/ci-policy.yml` as its first job, `policy`, and gates its test jobs on `needs.policy.outputs.run-tests`; never test `github.event.head_commit.message` in a workflow. Every job of every workflow that reacts to a pull request is skipped by the `no ci` label, and on a draft pull request unless it carries the `run ci` label. See [CI policy](#ci-policy). ## Available Skills @@ -246,6 +247,16 @@ Rules: - Do not use a newer third-party SHA, tag, or major version until it is on the allowlist. If you need a new pin, open a PR against `apache/infrastructure-actions` (`actions.yml`, not the generated `approved_patterns.yml`). - Before adding or bumping a third-party `uses:` line, search `approved_patterns.yml` for that action and copy an approved SHA. +### CI policy + +GitHub-hosted runner time is shared with every other Apache project, so the workflows run tests only where the result is worth the runner time: + +- A draft pull request runs nothing unless it carries the `run ci` label, and a pull request labelled `no ci` runs nothing at all: every workflow that reacts to a pull request skips all of its jobs. Marking a draft ready for review starts CI (the workflows list the `ready_for_review` trigger type, which is not a default). Labels and the draft flag are read when a run starts, so set them before pushing; adding `run ci` or removing `no ci` takes effect on the next push, or when the draft i [...] +- Every workflow that runs tests calls `.github/workflows/ci-policy.yml` as its first job, `policy`, and gates its test jobs (and the test steps of its build jobs) on `needs.policy.outputs.run-tests`. Never test `github.event.head_commit.message` in a workflow: a `pull_request` payload has no such field, so that test silently ran the tests on every pull request. The policy reads the head commit of the push, of the pull request, or of the dispatched branch, and matches the marker against [...] +- The tests run by default only on the default branch and the release branches above it, and there a commit message starting with `[skip tests]` skips them. Everywhere else, that is on a release branch below the default (7.0.x and 7.2.x while 8.0.x is the default) and on a pull request whose base is a side branch rather than a release branch, the tests run only when the commit message starts with `[run tests]`; otherwise the run builds, and on a push publishes snapshots, without tests, e [...] +- The jobs that run no tests (dependency validation, the build-without-tests steps, code style, build health, RAT, CodeQL, and the snapshot publish) still run on every push and on every non-draft pull request. Only the `no ci` label, or a draft without `run ci`, stops them. +- A workflow that gains a test job gets `needs: [ policy ]` and `if: ${{ needs.policy.outputs.run-tests == 'true' }}` on that job; a workflow that gains a non-test job copies the label-and-draft `if` from its sibling jobs. + ### Gradle caching GitHub keeps about 10 GB of Actions cache per repository and evicts the least recently used entries. A run can restore entries only from its own branch and the default branch, and a pull request also from its base branch. The workflows are arranged around those two limits: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9bc19a8c21..86fa9c64fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -272,6 +272,20 @@ Grails makes use of [Release Drafter](https://github.com/release-drafter/release commit messages are important. They should follow the project's rules. While a change can be incrementally made under many commits, pull requests should be squashed into a single, meaningful commit message. +### Continuous Integration + +Every push and pull request runs the GitHub Actions workflows, and runner time is shared with every other Apache +project, so two controls limit what runs: + +* A draft pull request runs no workflow unless it carries the `run ci` label; marking it ready for review starts CI. + A pull request labelled `no ci` runs no workflow at all, draft or not. Labels are read when a push arrives, so add + `run ci` (or remove `no ci`) and then push, or mark the draft ready, to get a run. +* The tests run by default only on the default branch and the release branches above it. Elsewhere, that is on an + older release branch such as `7.0.x` while `8.0.x` is the default, and on a pull request whose base is a side + branch rather than a release branch, a push or pull request builds without running the tests unless the commit + message starts with `[run tests]`. On the default branch and above, a commit message starting with `[skip tests]` + skips them. The marker is read from the first line of the head commit's message. + ### Change Review Process The Apache Grails project uses different review processes based on the change being made. We use both a
