This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch ci-merge-incremental-build-detect-dependencies in repository https://gitbox.apache.org/repos/asf/camel.git
commit 647af6ba5890072325405999518b1546f4fc3e9e Author: Guillaume Nodet <[email protected]> AuthorDate: Tue Mar 24 23:10:03 2026 +0100 chore(ci): merge detect-dependencies into incremental-build Merge the separate detect-dependencies action into the incremental-build action to provide a single unified CI test mechanism. Previously, two independent mechanisms determined which modules to test: 1. incremental-build: file-path based module detection 2. detect-dependencies: POM property change analysis using Maveniverse Toolbox For dependency version bumps in parent/pom.xml, the file-path approach would identify "parent" as the changed module, find that everything depends on it, and give up. The detect-dependencies action would then run separately and find the actually affected modules via Toolbox dependency analysis. This resulted in two separate PR comments, wasted CI time testing "parent" (which has no tests), and general confusion. The merged script now: - Uses file-path analysis for source code changes (unchanged) - Uses Toolbox dependency analysis for any changed pom.xml (generalized from parent-only to all pom.xml files) - Merges and deduplicates both sets of affected modules - Filters out pom-only parent modules when Toolbox found the real targets - Runs tests once and posts a single unified PR comment - Raises the testable modules threshold to 1000 (effectively disabled) - Removes the unused "build" mode (builds are handled by regen.sh) - Supports push builds (git diff HEAD~1) when no PR ID is provided Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .github/actions/detect-dependencies/action.yaml | 92 --- .github/actions/detect-dependencies/detect-test.sh | 395 ------------ .github/actions/incremental-build/action.yaml | 21 +- .../actions/incremental-build/incremental-build.sh | 668 +++++++++++++++------ .github/workflows/main-build.yml | 1 - .github/workflows/pr-build-main.yml | 9 - 6 files changed, 501 insertions(+), 685 deletions(-) diff --git a/.github/actions/detect-dependencies/action.yaml b/.github/actions/detect-dependencies/action.yaml deleted file mode 100644 index 285f90c8e6d7..000000000000 --- a/.github/actions/detect-dependencies/action.yaml +++ /dev/null @@ -1,92 +0,0 @@ -# -# 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. -# - -name: "Parent pom dependencies detector" -description: "Test only projects which have a dependency changed in the parent pom (typically dependabot)" -inputs: - github-token: - description: 'The github token to access to the API' - required: false - pr-id: - description: 'Id of the pull request' - required: true - github-repo: - description: 'The GitHub repository name (example, apache/camel)' - required: false - default: 'apache/camel' - skip-mvnd-install: - description: 'Skip mvnd installation (use if already installed)' - required: false - default: 'false' -runs: - using: "composite" - steps: - - id: install-mvnd - uses: apache/camel/.github/actions/install-mvnd@main - with: - dry-run: ${{ inputs.skip-mvnd-install }} - - name: maven test - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - shell: bash - run: ${{ github.action_path }}/detect-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd ${{ inputs.pr-id }} ${{ inputs.github-repo }} - - name: Post dependency change comment - if: always() - uses: actions/github-script@v8 - with: - github-token: ${{ inputs.github-token }} - script: | - const fs = require('fs'); - const commentFile = 'detect-dependencies-comment.md'; - if (!fs.existsSync(commentFile)) return; - const body = fs.readFileSync(commentFile, 'utf8').trim(); - if (!body) return; - - const prNumber = ${{ inputs.pr-id || 0 }}; - if (!prNumber) { - core.warning('Could not determine PR number, skipping dependency comment'); - return; - } - - const marker = '<!-- ci-parent-pom-deps -->'; - - try { - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - }); - const existing = comments.find(c => c.body && c.body.includes(marker)); - - if (existing) { - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: existing.id, - body: body, - }); - } else { - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: body, - }); - } - } catch (error) { - core.warning(`Failed to post dependency change comment: ${error.message}`); - } diff --git a/.github/actions/detect-dependencies/detect-test.sh b/.github/actions/detect-dependencies/detect-test.sh deleted file mode 100755 index 2f55e1c2f918..000000000000 --- a/.github/actions/detect-dependencies/detect-test.sh +++ /dev/null @@ -1,395 +0,0 @@ -# -# 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. -# - -# Detects property changes in parent/pom.xml, maps them to the managed -# artifacts that use those properties, then uses Maveniverse Toolbox to -# find which modules depend on those artifacts (including transitive -# dependencies) and runs their tests. -# -# Uses the GitHub API to fetch the PR diff (works with shallow clones). -# -# Approach: -# 1. Fetch PR diff via GitHub API, extract parent/pom.xml changes -# 2. Find changed property names from the diff -# 3. Parse parent/pom.xml to map property -> groupId:artifactId -# (detecting BOM imports vs regular dependencies) -# 4. Use toolbox:tree-find to find all modules depending on those -# artifacts (direct + transitive) -# 5. Run tests for affected modules - -set -euo pipefail - -MAX_MODULES=50 -TOOLBOX_PLUGIN="eu.maveniverse.maven.plugins:toolbox" - -# Fetch the PR diff from the GitHub API and extract only the parent/pom.xml -# portion. Returns the unified diff for parent/pom.xml, or empty if not changed. -fetch_parent_pom_diff() { - local pr_id="$1" - local repository="$2" - - local diff_output - diff_output=$(curl -s -w "\n%{http_code}" \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - -H "Accept: application/vnd.github.v3.diff" \ - "https://api.github.com/repos/${repository}/pulls/${pr_id}") - - local http_code - http_code=$(echo "$diff_output" | tail -n 1) - local diff_body - diff_body=$(echo "$diff_output" | sed '$d') - - if [[ "$http_code" -lt 200 || "$http_code" -ge 300 || -z "$diff_body" ]]; then - echo "WARNING: Failed to fetch PR diff (HTTP $http_code)" >&2 - return - fi - - # Extract only the parent/pom.xml diff section - echo "$diff_body" | awk ' - /^diff --git/ && found { exit } - /^diff --git a\/parent\/pom.xml/ { found=1 } - found { print } - ' -} - -# Detect which properties changed in the parent/pom.xml diff. -# Returns one property name per line. -detect_changed_properties() { - local diff_content="$1" - - echo "$diff_content" | \ - grep -E '^[+-][[:space:]]*<[^>]+>[^<]*</[^>]+>' | \ - grep -vE '^\+\+\+|^---' | \ - sed -E 's/^[+-][[:space:]]*<([^>]+)>.*/\1/' | \ - sort -u || true -} - -# Given a property name, find which groupId:artifactId pairs in -# parent/pom.xml use it as their <version>. -# Also detects if the artifact is a BOM import (<type>pom</type> + -# <scope>import</scope>), in which case it outputs "bom:groupId" -# so the caller can search by groupId wildcard. -# Returns one entry per line: either "groupId:artifactId" or "bom:groupId". -find_gav_for_property() { - local property="$1" - local parent_pom="parent/pom.xml" - - local matches - matches=$(grep -n "<version>\${${property}}</version>" "$parent_pom" 2>/dev/null || true) - - if [ -z "$matches" ]; then - return - fi - - echo "$matches" | while IFS=: read -r line_num _; do - local block - block=$(sed -n "1,${line_num}p" "$parent_pom") - local artifactId - artifactId=$(echo "$block" | grep '<artifactId>' | tail -1 | sed 's/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/') - local groupId - groupId=$(echo "$block" | grep '<groupId>' | tail -1 | sed 's/.*<groupId>\([^<]*\)<\/groupId>.*/\1/') - - # Check if this is a BOM import by looking at lines after the version - local after_version - after_version=$(sed -n "$((line_num+1)),$((line_num+3))p" "$parent_pom") - if echo "$after_version" | grep -q '<type>pom</type>' && echo "$after_version" | grep -q '<scope>import</scope>'; then - echo "bom:${groupId}" - else - echo "${groupId}:${artifactId}" - fi - done | sort -u -} - -# Use Maveniverse Toolbox tree-find to discover all modules that depend -# on a given artifact (including transitive dependencies). -# Returns one module artifactId per line. -find_modules_with_toolbox() { - local mavenBinary="$1" - local matcher_spec="$2" - local search_pattern="$3" - - local output - output=$($mavenBinary -B ${TOOLBOX_PLUGIN}:tree-find \ - -DartifactMatcherSpec="${matcher_spec}" 2>&1 || true) - - if echo "$output" | grep -q 'BUILD FAILURE'; then - echo " WARNING: toolbox tree-find failed, skipping" >&2 - return - fi - - # Parse output: track current module from "Paths found in project" lines, - # then when a dependency match is found, output that module's artifactId. - # Note: mvnd strips [module] prefixes when output is captured to a - # variable, so we track the current module from "Paths found" headers. - echo "$output" | awk -v pattern="$search_pattern" ' - /Paths found in project/ { - split($0, a, "project ") - split(a[2], b, ":") - current = b[2] - } - index($0, pattern) && /->/ { - print current - } - ' | sort -u -} - -main() { - echo "Using MVND_OPTS=$MVND_OPTS" - local mavenBinary=${1} - local prId=${2} - local repository=${3} - local log="detect-dependencies.log" - local exclusionList="!:camel-allcomponents,!:dummy-component,!:camel-catalog,!:camel-catalog-console,!:camel-catalog-lucene,!:camel-catalog-maven,!:camel-catalog-suggest,!:camel-route-parser,!:camel-csimple-maven-plugin,!:camel-report-maven-plugin,!:camel-endpointdsl,!:camel-componentdsl,!:camel-endpointdsl-support,!:camel-yaml-dsl,!:camel-kamelet-main,!:camel-yaml-dsl-deserializers,!:camel-yaml-dsl-maven-plugin,!:camel-jbang-core,!:camel-jbang-main,!:camel-jbang-plugin-generate,!:came [...] - - # Fetch diff via GitHub API (works with shallow clones) - echo "Fetching PR #${prId} diff from GitHub API..." - local parent_diff - parent_diff=$(fetch_parent_pom_diff "$prId" "$repository") - - if [ -z "$parent_diff" ]; then - echo "parent/pom.xml not changed, nothing to do" - exit 0 - fi - - local changed_props - changed_props=$(detect_changed_properties "$parent_diff") - - if [ -z "$changed_props" ]; then - echo "No property changes detected in parent/pom.xml" - exit 0 - fi - - echo "Changed properties in parent/pom.xml:" - echo "$changed_props" - echo "" - - # Map properties -> GAV coordinates for toolbox lookup - # For properties not used in parent's dependencyManagement, fall back - # to grepping for ${property} in module pom.xml files directly - local all_gavs="" - local fallback_props="" - while read -r prop; do - [ -z "$prop" ] && continue - - local gavs - gavs=$(find_gav_for_property "$prop") - if [ -z "$gavs" ]; then - echo " Property '$prop': not in dependencyManagement, will search modules directly" - fallback_props="${fallback_props:+${fallback_props} -}${prop}" - continue - fi - - echo " Property '$prop' manages:" - while read -r gav; do - [ -z "$gav" ] && continue - echo " - $gav" - all_gavs="${all_gavs:+${all_gavs} -}${gav}" - done <<< "$gavs" - done <<< "$changed_props" - - if [ -z "$all_gavs" ] && [ -z "$fallback_props" ]; then - echo "" - echo "No managed artifacts found for changed properties" - exit 0 - fi - - local all_module_ids="" - local seen_modules="" - - # Step 1: Use Toolbox tree-find for properties with managed artifacts - if [ -n "$all_gavs" ]; then - echo "" - echo "Searching for affected modules using Maveniverse Toolbox..." - - local unique_gavs - unique_gavs=$(echo "$all_gavs" | sort -u) - - while read -r gav; do - [ -z "$gav" ] && continue - - local matcher_spec search_pattern - if [[ "$gav" == bom:* ]]; then - # BOM import: search by groupId wildcard - local groupId="${gav#bom:}" - matcher_spec="artifact(${groupId}:*)" - search_pattern="${groupId}:" - echo " Searching for modules using ${groupId}:* (BOM)..." - else - matcher_spec="artifact(${gav})" - search_pattern="${gav}" - echo " Searching for modules using ${gav}..." - fi - - local modules - modules=$(find_modules_with_toolbox "$mavenBinary" "$matcher_spec" "$search_pattern") - if [ -n "$modules" ]; then - while read -r mod; do - [ -z "$mod" ] && continue - if ! echo "$seen_modules" | grep -qx "$mod"; then - seen_modules="${seen_modules:+${seen_modules} -}${mod}" - all_module_ids="${all_module_ids:+${all_module_ids},}:${mod}" - fi - done <<< "$modules" - fi - done <<< "$unique_gavs" - fi - - # Step 2: Fallback for properties used directly in module pom.xml files - # (not through parent's dependencyManagement) - if [ -n "$fallback_props" ]; then - echo "" - echo "Searching for modules referencing properties directly..." - - while read -r prop; do - [ -z "$prop" ] && continue - - local matches - matches=$(grep -rl "\${${prop}}" --include="pom.xml" . 2>/dev/null | \ - grep -v "^\./parent/pom.xml" | \ - grep -v "/target/" | \ - grep -v "\.claude/worktrees" || true) - - if [ -n "$matches" ]; then - echo " Property '\${${prop}}' referenced by:" - while read -r pom_file; do - [ -z "$pom_file" ] && continue - # Extract artifactId from the module's pom.xml - local mod_artifact - mod_artifact=$(sed -n '/<parent>/,/<\/parent>/!{ s/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/p }' "$pom_file" | head -1) - if [ -n "$mod_artifact" ] && ! echo "$seen_modules" | grep -qx "$mod_artifact"; then - echo " - $mod_artifact" - seen_modules="${seen_modules:+${seen_modules} -}${mod_artifact}" - all_module_ids="${all_module_ids:+${all_module_ids},}:${mod_artifact}" - fi - done <<< "$matches" - fi - done <<< "$fallback_props" - fi - - if [ -z "$all_module_ids" ]; then - echo "" - echo "No modules depend on the changed artifacts" - exit 0 - fi - - # Count modules - local module_count - module_count=$(echo "$all_module_ids" | tr ',' '\n' | wc -l | tr -d ' ') - - echo "" - echo "Found ${module_count} modules affected by parent/pom.xml property changes:" - echo "$all_module_ids" | tr ',' '\n' | while read -r m; do - echo " - $m" - done - echo "" - - if [ "${module_count}" -gt "${MAX_MODULES}" ]; then - echo "Too many affected modules (${module_count} > ${MAX_MODULES}), skipping targeted tests" - - write_comment "$changed_props" "$all_module_ids" "$module_count" "skip" - exit 0 - fi - - # Filter out modules that are in the exclusion list - local filtered_ids="" - local IFS_backup="$IFS" - IFS=',' - for mod_id in $all_module_ids; do - if ! echo ",$exclusionList," | grep -q ",!${mod_id},"; then - filtered_ids="${filtered_ids:+${filtered_ids},}${mod_id}" - else - echo " Skipping excluded module: $mod_id" - fi - done - IFS="$IFS_backup" - - if [ -z "$filtered_ids" ]; then - echo "All affected modules are in the exclusion list, skipping targeted tests" - write_comment "$changed_props" "$all_module_ids" "$module_count" "skip" - exit 0 - fi - - echo "Running targeted tests for affected modules..." - # Use install instead of test, otherwise test-infra modules fail due to jandex maven plugin - $mavenBinary -l $log $MVND_OPTS install -pl "${filtered_ids},${exclusionList}" -amd - local ret=$? - - if [ ${ret} -eq 0 ]; then - write_comment "$changed_props" "$all_module_ids" "$module_count" "pass" - else - write_comment "$changed_props" "$all_module_ids" "$module_count" "fail" - fi - - # Write step summary - if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then - echo "### Parent POM dependency change tests" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "Changed properties: $(echo "$changed_props" | tr '\n' ', ' | sed 's/,$//')" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "$all_module_ids" | tr ',' '\n' | while read -r m; do - echo "- \`$m\`" >> "$GITHUB_STEP_SUMMARY" - done - - if [ ${ret} -ne 0 ]; then - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "Processing surefire and failsafe reports to create the summary" >> "$GITHUB_STEP_SUMMARY" - echo -e "| Failed Test | Duration | Failure Type |\n| --- | --- | --- |" >> "$GITHUB_STEP_SUMMARY" - find . -path '*target/*-reports*' -iname '*.txt' -exec .github/actions/incremental-build/parse_errors.sh {} \; - fi - fi - - exit $ret -} - -write_comment() { - local changed_props="$1" - local modules="$2" - local module_count="$3" - local status="$4" - local comment_file="detect-dependencies-comment.md" - - echo "<!-- ci-parent-pom-deps -->" > "$comment_file" - - case "$status" in - pass) - echo ":white_check_mark: **Parent POM dependency changes: targeted tests passed**" >> "$comment_file" - ;; - fail) - echo ":x: **Parent POM dependency changes: targeted tests failed**" >> "$comment_file" - ;; - skip) - echo ":information_source: **Parent POM dependency changes detected** but too many modules affected (${module_count}) to run targeted tests." >> "$comment_file" - ;; - esac - - echo "" >> "$comment_file" - echo "Changed properties: $(echo "$changed_props" | tr '\n' ', ' | sed 's/,$//')" >> "$comment_file" - echo "" >> "$comment_file" - echo "<details><summary>Affected modules (${module_count})</summary>" >> "$comment_file" - echo "" >> "$comment_file" - echo "$modules" | tr ',' '\n' | while read -r m; do - echo "- \`$m\`" >> "$comment_file" - done - echo "" >> "$comment_file" - echo "</details>" >> "$comment_file" -} - -main "$@" diff --git a/.github/actions/incremental-build/action.yaml b/.github/actions/incremental-build/action.yaml index 0166f9d3aad1..7ee310bf3c6d 100644 --- a/.github/actions/incremental-build/action.yaml +++ b/.github/actions/incremental-build/action.yaml @@ -15,15 +15,13 @@ # limitations under the License. # -name: "Incremental Build Runner" -description: "Build only affected projects" +name: "Incremental Test Runner" +description: "Test only affected projects, using file-path analysis and POM dependency detection" inputs: - mode: - description: 'The mode to launch, it can be build or test' - required: true pr-id: - description: 'Id of the pull request' - required: true + description: 'Id of the pull request (optional for push builds)' + required: false + default: '' github-token: description: 'The github token to access to the API' required: false @@ -46,17 +44,16 @@ runs: uses: apache/camel/.github/actions/install-mvnd@main with: dry-run: ${{ inputs.skip-mvnd-install }} - - name: maven build + - name: maven test env: GITHUB_TOKEN: ${{ inputs.github-token }} - MODE: ${{ inputs.mode }} PR_ID: ${{ inputs.pr-id }} GITHUB_REPO: ${{ inputs.github-repo }} shell: bash - run: ${{ github.action_path }}/incremental-build.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd $MODE $PR_ID $GITHUB_REPO + run: ${{ github.action_path }}/incremental-build.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd "$PR_ID" "$GITHUB_REPO" - name: archive logs uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 if: always() with: - name: incremental-${{ inputs.mode }}-${{ inputs.artifact-upload-suffix }}.log - path: incremental-${{ inputs.mode }}.log + name: incremental-test-${{ inputs.artifact-upload-suffix }}.log + path: incremental-test.log diff --git a/.github/actions/incremental-build/incremental-build.sh b/.github/actions/incremental-build/incremental-build.sh index 37eb34395c90..abf6d01bc6bd 100755 --- a/.github/actions/incremental-build/incremental-build.sh +++ b/.github/actions/incremental-build/incremental-build.sh @@ -15,18 +15,37 @@ # limitations under the License. # +# Incremental test runner for Apache Camel PRs. +# +# Determines which modules to test by: +# 1. File-path analysis: maps changed files to their Maven modules +# 2. POM dependency analysis: for changed pom.xml files, detects property +# changes and uses Maveniverse Toolbox to find modules that depend on +# the affected artifacts (including transitive dependencies) +# +# Both sets of affected modules are merged and deduplicated before testing. + +set -euo pipefail + echo "Using MVND_OPTS=$MVND_OPTS" -maxNumberOfBuildableProjects=100 -maxNumberOfTestableProjects=50 +maxNumberOfTestableProjects=1000 + +TOOLBOX_PLUGIN="eu.maveniverse.maven.plugins:toolbox" -function findProjectRoot () { +# Modules excluded from targeted testing (generated code, meta-modules, etc.) +EXCLUSION_LIST="!:camel-allcomponents,!:dummy-component,!:camel-catalog,!:camel-catalog-console,!:camel-catalog-lucene,!:camel-catalog-maven,!:camel-catalog-suggest,!:camel-route-parser,!:camel-csimple-maven-plugin,!:camel-report-maven-plugin,!:camel-endpointdsl,!:camel-componentdsl,!:camel-endpointdsl-support,!:camel-yaml-dsl,!:camel-kamelet-main,!:camel-yaml-dsl-deserializers,!:camel-yaml-dsl-maven-plugin,!:camel-jbang-core,!:camel-jbang-main,!:camel-jbang-plugin-generate,!:camel-jbang [...] + +# ── Utility functions ────────────────────────────────────────────────── + +# Walk up from a file path to find the nearest directory containing a pom.xml +findProjectRoot() { local path=${1} while [[ "$path" != "." ]]; do - if [[ ! -e "$path/pom.xml" ]] ; then - path=$(dirname $path) - elif [[ $(dirname $path) == */src/it ]] ; then - path=$(dirname $(dirname $path)) + if [[ ! -e "$path/pom.xml" ]]; then + path=$(dirname "$path") + elif [[ $(dirname "$path") == */src/it ]]; then + path=$(dirname "$(dirname "$path")") else break fi @@ -34,210 +53,507 @@ function findProjectRoot () { echo "$path" } -function hasLabel() { - local issueNumber=${1} - local label="incremental-${2}" - local repository=${3} - curl -s \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GITHUB_TOKEN}"\ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "https://api.github.com/repos/${repository}/issues/${issueNumber}/labels" | jq -r '.[].name' | grep -c "$label" +# Check whether a PR label exists +hasLabel() { + local issueNumber=${1} + local label="incremental-${2}" + local repository=${3} + curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/${repository}/issues/${issueNumber}/labels" | jq -r '.[].name' | grep -c "$label" } -function main() { - local mavenBinary=${1} - local mode=${2} - local log="incremental-${mode}.log" - local prId=${3} - local ret=0 - local repository=${4} - local testedDependents="" +# Fetch the PR diff from the GitHub API. Returns the full unified diff. +fetchDiff() { + local prId="$1" + local repository="$2" - echo "Searching for affected projects" - local projects local diff_output - diff_output=$(curl -s -w "\n%{http_code}" -H "Authorization: Bearer ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3.diff" "https://api.github.com/repos/${repository}/pulls/${prId}") + diff_output=$(curl -s -w "\n%{http_code}" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "Accept: application/vnd.github.v3.diff" \ + "https://api.github.com/repos/${repository}/pulls/${prId}") + local http_code http_code=$(echo "$diff_output" | tail -n 1) local diff_body diff_body=$(echo "$diff_output" | sed '$d') - if [[ "$http_code" -lt 200 || "$http_code" -ge 300 || -z "$diff_body" ]] ; then - echo "WARNING: Failed to fetch PR diff (HTTP $http_code). Falling back to full build." - diff_body="" + + if [[ "$http_code" -lt 200 || "$http_code" -ge 300 || -z "$diff_body" ]]; then + echo "WARNING: Failed to fetch PR diff (HTTP $http_code). Falling back to full build." >&2 + return + fi + echo "$diff_body" +} + +# ── POM dependency analysis (previously detect-dependencies) ─────────── + +# Extract the diff section for a specific pom.xml file from the full diff +extractPomDiff() { + local diff_body="$1" + local pom_path="$2" + + echo "$diff_body" | awk -v target="a/${pom_path}" ' + /^diff --git/ && found { exit } + /^diff --git/ && index($0, target) { found=1 } + found { print } + ' +} + +# Detect which properties changed in a pom.xml diff. +# Returns one property name per line. +detectChangedProperties() { + local diff_content="$1" + + echo "$diff_content" | \ + grep -E '^[+-][[:space:]]*<[^>]+>[^<]*</[^>]+>' | \ + grep -vE '^\+\+\+|^---' | \ + sed -E 's/^[+-][[:space:]]*<([^>]+)>.*/\1/' | \ + sort -u || true +} + +# Given a property name and a pom.xml path, find which groupId:artifactId +# pairs use it as their <version>. +# Outputs "bom:groupId" for BOM imports, "groupId:artifactId" otherwise. +findGavForProperty() { + local property="$1" + local pom_file="$2" + + local matches + matches=$(grep -n "<version>\${${property}}</version>" "$pom_file" 2>/dev/null || true) + + if [ -z "$matches" ]; then + return + fi + + echo "$matches" | while IFS=: read -r line_num _; do + local block + block=$(sed -n "1,${line_num}p" "$pom_file") + local artifactId + artifactId=$(echo "$block" | grep '<artifactId>' | tail -1 | sed 's/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/') + local groupId + groupId=$(echo "$block" | grep '<groupId>' | tail -1 | sed 's/.*<groupId>\([^<]*\)<\/groupId>.*/\1/') + + # Check if this is a BOM import + local after_version + after_version=$(sed -n "$((line_num+1)),$((line_num+3))p" "$pom_file") + if echo "$after_version" | grep -q '<type>pom</type>' && echo "$after_version" | grep -q '<scope>import</scope>'; then + echo "bom:${groupId}" + else + echo "${groupId}:${artifactId}" + fi + done | sort -u +} + +# Use Maveniverse Toolbox tree-find to discover all modules that depend +# on a given artifact (including transitive dependencies). +# Returns one module artifactId per line. +findModulesWithToolbox() { + local mavenBinary="$1" + local matcher_spec="$2" + local search_pattern="$3" + + local output + output=$($mavenBinary -B ${TOOLBOX_PLUGIN}:tree-find \ + -DartifactMatcherSpec="${matcher_spec}" 2>&1 || true) + + if echo "$output" | grep -q 'BUILD FAILURE'; then + echo " WARNING: toolbox tree-find failed, skipping" >&2 + return + fi + + echo "$output" | awk -v pattern="$search_pattern" ' + /Paths found in project/ { + split($0, a, "project ") + split(a[2], b, ":") + current = b[2] + } + index($0, pattern) && /->/ { + print current + } + ' | sort -u +} + +# Analyze pom.xml changes to find affected modules via dependency analysis. +# Adds discovered module artifactIds to the seen_modules and toolbox_module_ids +# variables (which must be declared in the caller). +analyzePomDependencies() { + local mavenBinary="$1" + local diff_body="$2" + local pom_path="$3" # e.g. "parent/pom.xml" or "components/camel-foo/pom.xml" + + local pom_diff + pom_diff=$(extractPomDiff "$diff_body" "$pom_path") + if [ -z "$pom_diff" ]; then + return + fi + + local changed_props + changed_props=$(detectChangedProperties "$pom_diff") + if [ -z "$changed_props" ]; then + return + fi + + echo " Property changes detected in ${pom_path}:" + echo "$changed_props" | while read -r p; do echo " - $p"; done + + # Map properties -> GAV coordinates + local all_gavs="" + local fallback_props="" + while read -r prop; do + [ -z "$prop" ] && continue + + local gavs + gavs=$(findGavForProperty "$prop" "$pom_path") + if [ -z "$gavs" ]; then + # Property not used as a version in this pom — search modules directly + fallback_props="${fallback_props:+${fallback_props} +}${prop}" + continue + fi + + while read -r gav; do + [ -z "$gav" ] && continue + echo " Property '$prop' -> $gav" + all_gavs="${all_gavs:+${all_gavs} +}${gav}" + done <<< "$gavs" + done <<< "$changed_props" + + # Use Toolbox to find modules depending on the managed artifacts + if [ -n "$all_gavs" ]; then + local unique_gavs + unique_gavs=$(echo "$all_gavs" | sort -u) + + while read -r gav; do + [ -z "$gav" ] && continue + + local matcher_spec search_pattern + if [[ "$gav" == bom:* ]]; then + local groupId="${gav#bom:}" + matcher_spec="artifact(${groupId}:*)" + search_pattern="${groupId}:" + else + matcher_spec="artifact(${gav})" + search_pattern="${gav}" + fi + + echo " Searching for modules using ${search_pattern} via Toolbox..." + local modules + modules=$(findModulesWithToolbox "$mavenBinary" "$matcher_spec" "$search_pattern") + if [ -n "$modules" ]; then + while read -r mod; do + [ -z "$mod" ] && continue + if ! echo "$seen_modules" | grep -qx "$mod"; then + seen_modules="${seen_modules:+${seen_modules} +}${mod}" + toolbox_module_ids="${toolbox_module_ids:+${toolbox_module_ids},}:${mod}" + fi + done <<< "$modules" + fi + done <<< "$unique_gavs" + fi + + # Fallback: search for properties referenced directly in module pom.xml files + if [ -n "$fallback_props" ]; then + while read -r prop; do + [ -z "$prop" ] && continue + + local matches + matches=$(grep -rl "\${${prop}}" --include="pom.xml" . 2>/dev/null | \ + grep -v "^\./parent/pom.xml" | \ + grep -v "/target/" | \ + grep -v "\.claude/worktrees" || true) + + if [ -n "$matches" ]; then + while read -r pom_file; do + [ -z "$pom_file" ] && continue + local mod_artifact + mod_artifact=$(sed -n '/<parent>/,/<\/parent>/!{ s/.*<artifactId>\([^<]*\)<\/artifactId>.*/\1/p }' "$pom_file" | head -1) + if [ -n "$mod_artifact" ] && ! echo "$seen_modules" | grep -qx "$mod_artifact"; then + echo " Property '\${${prop}}' referenced by: $mod_artifact" + seen_modules="${seen_modules:+${seen_modules} +}${mod_artifact}" + toolbox_module_ids="${toolbox_module_ids:+${toolbox_module_ids},}:${mod_artifact}" + fi + done <<< "$matches" + fi + done <<< "$fallback_props" + fi +} + +# ── Comment generation ───────────────────────────────────────────────── + +writeComment() { + local comment_file="$1" + local pl="$2" + local toolbox_ids="$3" + local changed_props_summary="$4" + local testedDependents="$5" + + echo "<!-- ci-tested-modules -->" > "$comment_file" + + # Section 1: file-path-based modules + if [ -n "$pl" ]; then + echo ":test_tube: **CI tested the following changed modules:**" >> "$comment_file" + echo "" >> "$comment_file" + for w in $(echo "$pl" | tr ',' '\n'); do + echo "- \`$w\`" >> "$comment_file" + done + + if [[ "${testedDependents}" = "false" ]]; then + echo "" >> "$comment_file" + echo "> :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (${maxNumberOfTestableProjects}). Use the \`test-dependents\` label to force testing all dependents." >> "$comment_file" + fi + fi + + # Section 2: pom dependency-detected modules + if [ -n "$toolbox_ids" ]; then + echo "" >> "$comment_file" + if [ -n "$changed_props_summary" ]; then + echo ":white_check_mark: **POM dependency changes: targeted tests included**" >> "$comment_file" + echo "" >> "$comment_file" + echo "Changed properties: ${changed_props_summary}" >> "$comment_file" + echo "" >> "$comment_file" + local dep_count + dep_count=$(echo "$toolbox_ids" | tr ',' '\n' | wc -l | tr -d ' ') + echo "<details><summary>Modules affected by dependency changes (${dep_count})</summary>" >> "$comment_file" + echo "" >> "$comment_file" + echo "$toolbox_ids" | tr ',' '\n' | while read -r m; do + echo "- \`$m\`" >> "$comment_file" + done + echo "" >> "$comment_file" + echo "</details>" >> "$comment_file" + fi + fi + + if [ -z "$pl" ] && [ -z "$toolbox_ids" ]; then + echo ":information_source: CI did not run targeted module tests." >> "$comment_file" + fi +} + +# ── Main ─────────────────────────────────────────────────────────────── + +main() { + local mavenBinary=${1} + local prId=${2} + local repository=${3} + local log="incremental-test.log" + local ret=0 + local testedDependents="" + + # Check for skip-tests label (only for PR builds) + if [ -n "$prId" ]; then + local mustSkipTests + mustSkipTests=$(hasLabel "${prId}" "skip-tests" "${repository}") + if [[ ${mustSkipTests} = "1" ]]; then + echo "The skip-tests label has been detected, no tests will be launched" + echo "<!-- ci-tested-modules -->" > "incremental-test-comment.md" + echo ":information_source: CI did not run targeted module tests (skip-tests label detected)." >> "incremental-test-comment.md" + exit 0 + fi + fi + + # Fetch the diff (PR diff via API, or git diff for push builds) + local diff_body + if [ -n "$prId" ]; then + echo "Fetching PR #${prId} diff..." + diff_body=$(fetchDiff "$prId" "$repository") + else + echo "No PR ID, using git diff HEAD~1..." + diff_body=$(git diff HEAD~1 2>/dev/null || true) fi + + if [ -z "$diff_body" ]; then + echo "Could not fetch diff, skipping tests" + exit 0 + fi + + # ── Step 1: File-path analysis ── + echo "Searching for affected projects by file path..." + local projects projects=$(echo "$diff_body" | sed -n -e '/^diff --git a/p' | awk '{print $3}' | cut -b 3- | sed 's|\(.*\)/.*|\1|' | uniq | sort) + local pl="" local lastProjectRoot="" - local buildAll=false local totalAffected=0 - for project in ${projects} - do - if [[ ${project} == */archetype-resources ]] ; then + local pom_files="" + + for project in ${projects}; do + if [[ ${project} == */archetype-resources ]]; then continue - elif [[ ${project} != .* ]] ; then + elif [[ ${project} != .* ]]; then local projectRoot - projectRoot=$(findProjectRoot ${project}) - if [[ ${projectRoot} = "." ]] ; then - echo "The root project is affected, so a complete build is triggered" - buildAll=true - totalAffected=1 - break - elif [[ ${projectRoot} != "${lastProjectRoot}" ]] ; then - (( totalAffected ++ )) + projectRoot=$(findProjectRoot "${project}") + if [[ ${projectRoot} = "." ]]; then + # Root project change — don't add to pl, will rely on dependency analysis + # for pom.xml changes, or skip if it's just config files + continue + elif [[ ${projectRoot} != "${lastProjectRoot}" ]]; then + (( totalAffected++ )) pl="$pl,${projectRoot}" lastProjectRoot=${projectRoot} fi fi done + pl="${pl:1}" # strip leading comma - if [[ ${totalAffected} = 0 ]] ; then - echo "There is nothing to build" - exit 0 - elif [[ ${totalAffected} -gt ${maxNumberOfBuildableProjects} ]] ; then - echo "There are too many affected projects, so a complete build is triggered" - buildAll=true - fi - pl="${pl:1}" - - if [[ ${mode} = "build" ]] ; then - local mustBuildAll - mustBuildAll=$(hasLabel ${prId} "build-all" ${repository}) - if [[ ${mustBuildAll} = "1" ]] ; then - echo "The build-all label has been detected thus all projects must be built" - buildAll=true - fi - if [[ ${buildAll} = "true" ]] ; then - echo "Building all projects" - $mavenBinary -l $log $MVND_OPTS -DskipTests install - ret=$? - else - local buildDependents - buildDependents=$(hasLabel ${prId} "build-dependents" ${repository}) - local totalTestableProjects - if [[ ${buildDependents} = "1" ]] ; then - echo "The build-dependents label has been detected thus the projects that depend on the affected projects will be built" - totalTestableProjects=0 - else - for w in $pl; do - echo "$w" - done - totalTestableProjects=$(./mvnw -B -q -amd exec:exec -Dexec.executable="pwd" -pl "$pl" | wc -l) + # Collect all changed pom.xml files for dependency analysis + pom_files=$(echo "$diff_body" | sed -n -e '/^diff --git a/p' | awk '{print $3}' | cut -b 3- | grep '/pom\.xml$' | sort -u || true) + + # ── Step 2: POM dependency analysis ── + # Variables shared with analyzePomDependencies (modified by subshell-free calls) + local seen_modules="" + local toolbox_module_ids="" + local all_changed_props="" + + if [ -n "$pom_files" ]; then + echo "" + echo "Analyzing POM dependency changes..." + while read -r pom_file; do + [ -z "$pom_file" ] && continue + + # Capture changed props for this pom before calling analyze + local pom_diff + pom_diff=$(extractPomDiff "$diff_body" "$pom_file") + if [ -n "$pom_diff" ]; then + local props + props=$(detectChangedProperties "$pom_diff") + if [ -n "$props" ]; then + all_changed_props="${all_changed_props:+${all_changed_props}, }$(echo "$props" | tr '\n' ',' | sed 's/,$//')" + fi fi - if [[ ${totalTestableProjects} -gt ${maxNumberOfTestableProjects} ]] ; then - echo "Launching fast build command against the projects ${pl}, their dependencies and the projects that depend on them" - for w in $pl; do - echo "$w" - done - $mavenBinary -l $log $MVND_OPTS -DskipTests install -pl "$pl" -amd -am - ret=$? + + analyzePomDependencies "$mavenBinary" "$diff_body" "$pom_file" + done <<< "$pom_files" + fi + + # ── Step 3: Merge and deduplicate ── + # When Toolbox found the real affected modules, remove pom-only parents + # from pl (e.g. "parent") since they have no tests of their own + local final_pl="" + if [ -n "$toolbox_module_ids" ]; then + # Filter pl: keep only modules that have src/test (actual testable code) + for w in $(echo "$pl" | tr ',' '\n'); do + if [ -d "$w/src/test" ]; then + final_pl="${final_pl:+${final_pl},}${w}" else - echo "Launching fast build command against the projects ${pl} and their dependencies" - for w in $pl; do - echo "$w" - done - $mavenBinary -l $log $MVND_OPTS -DskipTests install -pl "$pl" -am - ret=$? + echo " Skipping pom-only module from file-path analysis: $w (no src/test)" fi + done + # Append Toolbox-discovered modules + if [ -n "$final_pl" ]; then + final_pl="${final_pl},${toolbox_module_ids}" + else + final_pl="$toolbox_module_ids" fi - [[ -z $(git status --porcelain | grep -v antora.yml) ]] || { echo 'There are uncommitted changes'; git status; echo; echo; git diff; exit 1; } else - local mustSkipTests - mustSkipTests=$(hasLabel ${prId} "skip-tests" ${repository}) - if [[ ${mustSkipTests} = "1" ]] ; then - echo "The skip-tests label has been detected thus no test will be launched" - buildAll=true - elif [[ ${buildAll} = "true" ]] ; then - echo "Cannot launch the tests of all projects, so no test will be launched" - else - local testDependents - testDependents=$(hasLabel ${prId} "test-dependents" ${repository}) - local totalTestableProjects - if [[ ${testDependents} = "1" ]] ; then - echo "The test-dependents label has been detected thus the projects that depend on affected projects will be tested" - testedDependents=true - totalTestableProjects=0 - else - totalTestableProjects=$(./mvnw -B -q -amd exec:exec -Dexec.executable="pwd" -pl "$pl" | wc -l) - fi - if [[ ${totalTestableProjects} -gt ${maxNumberOfTestableProjects} ]] ; then - echo "There are too many projects to test (${totalTestableProjects} > ${maxNumberOfTestableProjects}) so only the affected projects are tested:" - testedDependents=false - for w in $pl; do - echo "$w" - done - # This need to install, other commands like test are not enough, otherwise test-infra will fail due to jandex maven plugin - $mavenBinary -l $log $MVND_OPTS install -pl "$pl" - ret=$? + final_pl="$pl" + fi + + if [ -z "$final_pl" ]; then + echo "" + echo "No modules to test" + writeComment "incremental-test-comment.md" "" "" "" "" + exit 0 + fi + + echo "" + echo "Modules to test:" + for w in $(echo "$final_pl" | tr ',' '\n'); do + echo " - $w" + done + echo "" + + # ── Step 4: Run tests ── + local testDependents="0" + if [ -n "$prId" ]; then + testDependents=$(hasLabel "${prId}" "test-dependents" "${repository}") + fi + local totalTestableProjects + if [[ ${testDependents} = "1" ]]; then + echo "The test-dependents label has been detected, testing dependents too" + testedDependents=true + totalTestableProjects=0 + else + totalTestableProjects=$(./mvnw -B -q -amd exec:exec -Dexec.executable="pwd" -pl "$final_pl" 2>/dev/null | wc -l || echo "0") + fi + + # Build the -pl argument, appending exclusions for Toolbox-discovered modules + # (to skip generated/meta modules that shouldn't be tested directly) + local pl_with_exclusions="$final_pl" + if [ -n "$toolbox_module_ids" ]; then + pl_with_exclusions="${pl_with_exclusions},${EXCLUSION_LIST}" + fi + + if [[ ${totalTestableProjects} -gt ${maxNumberOfTestableProjects} ]]; then + echo "Too many dependent modules (${totalTestableProjects} > ${maxNumberOfTestableProjects}), testing only the affected modules" + testedDependents=false + # This needs to install, not just test, otherwise test-infra will fail due to jandex maven plugin + $mavenBinary -l "$log" $MVND_OPTS install -pl "$pl_with_exclusions" + ret=$? + else + echo "Testing affected modules and their dependents (${totalTestableProjects} modules)" + testedDependents=true + $mavenBinary -l "$log" $MVND_OPTS install -pl "$pl_with_exclusions" -amd + ret=$? + fi + + # ── Step 5: Write comment and summary ── + local comment_file="incremental-test-comment.md" + writeComment "$comment_file" "$pl" "$toolbox_module_ids" "$all_changed_props" "$testedDependents" + + # Append reactor module list from build log + if [[ -f "$log" ]]; then + local reactor_modules + reactor_modules=$(grep '^\[INFO\] Camel ::' "$log" | sed 's/\[INFO\] //' | sed 's/ \..*$//' | sort -u) + if [[ -n "$reactor_modules" ]]; then + local count + count=$(echo "$reactor_modules" | wc -l | tr -d ' ') + local reactor_label + if [[ "${testedDependents}" = "false" ]]; then + reactor_label="Build reactor — dependencies compiled but only changed modules were tested" else - echo "Testing the affected projects and the projects that depend on them (${totalTestableProjects} modules):" - testedDependents=true - for w in $pl; do - echo "$w" - done - # This need to install, other commands like test are not enough, otherwise test-infra will fail due to jandex maven plugin - $mavenBinary -l $log $MVND_OPTS install -pl "$pl" -amd - ret=$? + reactor_label="All tested modules" fi - fi - fi - # Write the list of tested modules to the step summary and PR comment file - local comment_file="incremental-${mode}-comment.md" - if [[ -n "$pl" && ${buildAll} != "true" ]] ; then - echo "### Changed modules" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "<!-- ci-tested-modules -->" > "$comment_file" - echo ":test_tube: **CI tested the following changed modules:**" >> "$comment_file" - echo "" >> "$comment_file" - for w in $(echo "$pl" | tr ',' '\n'); do - echo "- \`$w\`" >> "$GITHUB_STEP_SUMMARY" - echo "- \`$w\`" >> "$comment_file" - done - echo "" >> "$GITHUB_STEP_SUMMARY" - # Add note about dependent modules testing scope - if [[ ${mode} = "test" && "${testedDependents:-}" = "false" ]] ; then + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "<details><summary><b>${reactor_label} ($count)</b></summary>" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$comment_file" - echo "> :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (${maxNumberOfTestableProjects}). Use the \`test-dependents\` label to force testing all dependents." >> "$comment_file" + echo "<details><summary>${reactor_label} ($count modules)</summary>" >> "$comment_file" echo "" >> "$comment_file" + + echo "$reactor_modules" | while read -r m; do + echo "- $m" >> "$GITHUB_STEP_SUMMARY" + echo "- $m" >> "$comment_file" + done + + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "</details>" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$comment_file" + echo "</details>" >> "$comment_file" fi - # Extract full reactor module list from the build log - if [[ -f "$log" ]] ; then - local reactor_modules - reactor_modules=$(grep '^\[INFO\] Camel ::' "$log" | sed 's/\[INFO\] //' | sed 's/ \..*$//' | sort -u) - if [[ -n "$reactor_modules" ]] ; then - local count - count=$(echo "$reactor_modules" | wc -l | tr -d ' ') - local reactor_label - if [[ ${mode} = "test" && "${testedDependents:-}" = "false" ]] ; then - reactor_label="Build reactor — dependencies compiled but only changed modules were tested" - else - reactor_label="All tested modules" - fi - echo "<details><summary><b>${reactor_label} ($count)</b></summary>" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$comment_file" - echo "<details><summary>${reactor_label} ($count modules)</summary>" >> "$comment_file" - echo "" >> "$comment_file" - echo "$reactor_modules" | while read -r m; do - echo "- $m" >> "$GITHUB_STEP_SUMMARY" - echo "- $m" >> "$comment_file" - done - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "</details>" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$comment_file" - echo "</details>" >> "$comment_file" - fi - fi - elif [[ ${buildAll} = "true" ]] ; then - echo "<!-- ci-tested-modules -->" > "$comment_file" - echo ":information_source: CI did not run targeted module tests (all projects built or tests skipped)." >> "$comment_file" fi - if [[ ${ret} -ne 0 ]] ; then + # Write step summary header + if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + { + echo "### Tested modules" + echo "" + for w in $(echo "$final_pl" | tr ',' '\n'); do + echo "- \`$w\`" + done + echo "" + } >> "$GITHUB_STEP_SUMMARY" + fi + + if [[ ${ret} -ne 0 ]]; then echo "Processing surefire and failsafe reports to create the summary" - echo -e "| Failed Test | Duration | Failure Type |\n| --- | --- | --- |" >> "$GITHUB_STEP_SUMMARY" + echo -e "| Failed Test | Duration | Failure Type |\n| --- | --- | --- |" >> "$GITHUB_STEP_SUMMARY" find . -path '*target/*-reports*' -iname '*.txt' -exec .github/actions/incremental-build/parse_errors.sh {} \; fi diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 95419d8c7d2e..dcfc80711e73 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -68,7 +68,6 @@ jobs: - name: mvn test uses: ./.github/actions/incremental-build with: - mode: test github-token: ${{ secrets.GITHUB_TOKEN }} skip-mvnd-install: 'true' artifact-upload-suffix: main-java-${{ matrix.java }} diff --git a/.github/workflows/pr-build-main.yml b/.github/workflows/pr-build-main.yml index fe32bbacbf7a..bcdf13e12e6a 100644 --- a/.github/workflows/pr-build-main.yml +++ b/.github/workflows/pr-build-main.yml @@ -92,7 +92,6 @@ jobs: - name: mvn test uses: ./.github/actions/incremental-build with: - mode: test pr-id: ${{ github.event.number || inputs.pr_number }} github-token: ${{ secrets.GITHUB_TOKEN }} skip-mvnd-install: 'true' @@ -142,11 +141,3 @@ jobs: } catch (error) { core.warning(`Failed to post CI test summary comment: ${error.message}`); } - - name: mvn test parent pom dependencies changed - if: always() && !matrix.experimental - uses: ./.github/actions/detect-dependencies - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - pr-id: ${{ github.event.number || inputs.pr_number }} - github-repo: ${{ github.repository }} - skip-mvnd-install: 'true'
