This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 20978d38bf84 chore: ci - count the Scalpel-detected modules in the
dependents threshold (#31021)
20978d38bf84 is described below
commit 20978d38bf842a7a7b4bcf2c78cb52fc8cae783b
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 27 20:31:51 2026 +0100
chore: ci - count the Scalpel-detected modules in the dependents threshold
(#31021)
The threshold check counted only the -amd reactor of the changed modules,
while the grep and Scalpel detected modules are added to -pl next to it.
A change to camel-catalog, camel-endpointdsl or camel-componentdsl, which
every component description change regenerates, has few -amd dependents
(38) but about 700 downstream modules in Scalpel's graph. Such a PR passed
the threshold of 50 and then tested about 700 modules, so a one-line
documentation PR ran a near-full test suite and often failed on unrelated
flaky tests.
The new countTestableModules function counts the union of both lists, so
these PRs exceed the threshold and test only the changed modules.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
.../actions/incremental-build/incremental-build.sh | 15 +++-
.../incremental_build_count_test.sh | 87 ++++++++++++++++++++++
2 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/.github/actions/incremental-build/incremental-build.sh
b/.github/actions/incremental-build/incremental-build.sh
index d53b5ea4c3c9..eac46b8eaa8a 100755
--- a/.github/actions/incremental-build/incremental-build.sh
+++ b/.github/actions/incremental-build/incremental-build.sh
@@ -108,6 +108,19 @@ filterExclusions() {
echo "$result"
}
+# Count the modules a build would test: the -amd reactor of the changed modules
+# plus the dependency-detected modules (grep + Scalpel), without duplicates.
+# The dependency-detected modules are added to -pl next to the -amd reactor,
so the
+# threshold must count them too. Otherwise a change to a module with many
+# downstream modules in Scalpel's graph (camel-catalog, camel-endpointdsl, ...)
+# passes the threshold with its few -amd dependents and then tests ~700
modules.
+# Args: $1=reactor artifact IDs (newline-separated), $2=dep_module_ids
(":id,:id,...")
+countTestableModules() {
+ local reactor="$1"
+ local deps="$2"
+ { echo "$reactor"; echo "$deps" | tr ',' '\n' | sed 's/^://'; } | grep . |
sort -u | grep -c . || true
+}
+
# Check whether a PR label exists
hasLabel() {
local issueNumber=${1}
@@ -939,7 +952,7 @@ main() {
local totalTestableProjects
reactor_ids=$(./mvnw -B -q -amd exec:exec -Dexec.executable="echo" \
-Dexec.args='${project.artifactId}' -pl "$threshold_pl" 2>/dev/null ||
true)
- totalTestableProjects=$(echo "$reactor_ids" | grep -c . || true)
+ totalTestableProjects=$(countTestableModules "$reactor_ids"
"$dep_module_ids")
if [[ ${totalTestableProjects} -gt ${maxNumberOfTestableProjects} ]];
then
echo "Too many dependent modules (${totalTestableProjects} >
${maxNumberOfTestableProjects}), testing only the affected modules"
diff --git a/.github/actions/incremental-build/incremental_build_count_test.sh
b/.github/actions/incremental-build/incremental_build_count_test.sh
new file mode 100755
index 000000000000..4bb5c8c47b89
--- /dev/null
+++ b/.github/actions/incremental-build/incremental_build_count_test.sh
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+#
+# 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
+#
+# http://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.
+#
+
+# Unit tests for the countTestableModules function in incremental-build.sh.
+# The threshold check must count the dependency-detected modules (grep +
Scalpel)
+# that are added to -pl next to the -amd reactor of the changed modules.
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Extract and load only countTestableModules from incremental-build.sh without
+# running main() (same approach as incremental_build_filter_test.sh).
+_fn_body=$(awk '
+ /^countTestableModules\(\)/ { in_fn=1; depth=0 }
+ in_fn {
+ for (i=1; i<=length($0); i++) {
+ c = substr($0, i, 1)
+ if (c == "{") depth++
+ if (c == "}") depth--
+ }
+ print
+ if (in_fn && depth == 0) { in_fn=0 }
+ }
+' "${SCRIPT_DIR}/incremental-build.sh")
+eval "$_fn_body"
+
+pass=0
+fail=0
+
+assert_eq() {
+ local expected="$1"
+ local actual="$2"
+ local message="$3"
+ if [[ "$expected" == "$actual" ]]; then
+ pass=$((pass + 1))
+ else
+ echo "FAIL: $message"
+ echo " expected: [$expected]"
+ echo " actual: [$actual]"
+ fail=$((fail + 1))
+ fi
+}
+
+REACTOR=$'camel-catalog\ncamel-endpointdsl\ncamel-ai-prompt'
+
+# 1. No dependency-detected modules: the count is the -amd reactor
+assert_eq "3" "$(countTestableModules "$REACTOR" "")" \
+ "reactor only: counts the -amd reactor"
+
+# 2. Dependency-detected modules are added to the count
+assert_eq "5" "$(countTestableModules "$REACTOR"
":camel-kafka,:camel-zipfile")" \
+ "reactor + deps: dependency-detected modules are counted"
+
+# 3. A module in both lists is counted once
+assert_eq "4" "$(countTestableModules "$REACTOR"
":camel-catalog,:camel-zipfile")" \
+ "overlap: a module in both lists is counted once"
+
+# 4. Nothing at all
+assert_eq "0" "$(countTestableModules "" "")" \
+ "empty: counts zero"
+
+# 5. Many Scalpel downstream modules push the count over the threshold of 50
+DEPS=$(for i in $(seq 1 60); do printf ':camel-m%s,' "$i"; done)
+assert_eq "63" "$(countTestableModules "$REACTOR" "${DEPS%,}")" \
+ "many downstream modules: all are counted"
+
+echo ""
+echo "incremental-build-count-test.sh: ${pass} passed, ${fail} failed"
+if [[ "$fail" -ne 0 ]]; then
+ exit 1
+fi