Skip to content

Commit fe2e29f

Browse files
yrapartiassistant-librarian[bot]
authored andcommitted
[rocm-libraries] ROCm/rocm-libraries#7289 (commit e3fb4ee)
[CK] Fix smart build false positives from merged commits (#7289) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Motivation Current smart-build infrastructure triggers full build for almost every PR which is draining our CI infrastructure. Need to update the test selection logic based on diffs from the current workspace instead of entire repo. ## Technical Details Use three-dot syntax and scope BUILD_INFRA_PATTERN to composablekernel. Changes: - Switch from two-dot (..) to three-dot (...) in git diff - Three-dot shows only PR-specific changes - Excludes commits merged from develop (prevents false positives) - Scope BUILD_INFRA_PATTERN to projects/composablekernel/ paths only - Avoids triggering on other projects (hipblas, hipdnn, etc.) - Only composablekernel build infra changes trigger full build - Update both ci_safety_check.sh and validate_pr.sh ## Test Plan Test with PR 7112 and 7223 ## Test Result Impact: - PR 7112: Was 620 files (false positive) → Now 6 files (correct) - PR 7223: Was full build (false positive) → Now selective build (correct) ## Submission Checklist - [ x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
1 parent 6cd0638 commit fe2e29f

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

script/dependency-parser/ci_safety_check.sh

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# CHANGE_TARGET - Base branch for PR builds (set by Jenkins Multibranch Pipeline)
1919
#
2020
# Note: CHANGE_ID may not be set even for PR builds if Jenkins job is not
21-
# configured as Multibranch Pipeline. Script uses two-dot git diff syntax
22-
# to detect PR changes regardless of CHANGE_ID availability.
21+
# configured as Multibranch Pipeline. Script uses three-dot git diff syntax
22+
# to detect only PR-specific changes (excluding merged commits from base branch).
2323
#
2424
# Manual override (set by developer/admin if needed):
2525
# DISABLE_SMART_BUILD - Set to "true" to force full build
@@ -48,25 +48,21 @@ fi
4848

4949
# 3. Force full build if CMakeLists.txt or cmake/ configuration changed
5050
# Always compare against base branch (not consecutive commits) to avoid false positives from merge commits
51-
# Two-dot syntax (..) compares current state against base branch
52-
# Note: This includes merged changes from develop, which is conservative but safe (catches all potentially affected files)
53-
CHANGED_FILES=$(git diff --name-only origin/${BASE_BRANCH}..HEAD 2>/dev/null || echo "")
51+
# Three-dot syntax (...) shows only changes unique to the current branch (excludes merged commits from base)
52+
# This prevents false positives when the PR branch has merged in commits from develop
53+
CHANGED_FILES=$(git diff --name-only origin/${BASE_BRANCH}...HEAD 2>/dev/null || echo "")
5454

5555
# Comprehensive pattern for build/infrastructure files that require full build:
56-
# - CMake: CMakeLists.txt, *.cmake, *.cmake.in, CMakePresets.json
57-
# - Docker: Dockerfile*, docker-compose*
58-
# - CI/CD: Jenkinsfile, .github/, .gitlab-ci.yml, .pre-commit-config.yaml, .readthedocs.yaml
59-
# - Scripts: script/ directory (cmake, dependency-parser, build utilities)
60-
# - Compiler: .clang-format, .clang-tidy
61-
# - Python: setup.py, pyproject.toml, requirements*.txt
62-
BUILD_INFRA_PATTERN="(CMakeLists\.txt"
63-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|\.cmake$|\.cmake\.in$|CMakePresets\.json"
64-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|Dockerfile|docker-compose"
65-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|Jenkinsfile|\.github/|\.gitlab-ci\.yml"
66-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|\.pre-commit-config\.yaml|\.readthedocs\.yaml"
67-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|script/"
68-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|\.clang-format|\.clang-tidy"
69-
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|setup\.py|pyproject\.toml|requirements.*\.txt)"
56+
# Scoped to composablekernel-specific paths only to avoid false positives from other projects
57+
# - CMake: CMakeLists.txt, *.cmake, *.cmake.in within projects/composablekernel/
58+
# - Scripts: Only build-critical scripts (dependency-parser, cmake utilities)
59+
# - Compiler: .clang-format, .clang-tidy within projects/composablekernel/
60+
# - Python: setup.py, pyproject.toml within projects/composablekernel/
61+
BUILD_INFRA_PATTERN="(projects/composablekernel/.*CMakeLists\.txt"
62+
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|projects/composablekernel/.*\.cmake$|projects/composablekernel/.*\.cmake\.in$"
63+
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|projects/composablekernel/script/dependency-parser/"
64+
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|projects/composablekernel/script/cmake/"
65+
BUILD_INFRA_PATTERN="${BUILD_INFRA_PATTERN}|projects/composablekernel/setup\.py|projects/composablekernel/pyproject\.toml)"
7066

7167
if echo "$CHANGED_FILES" | grep -qE "${BUILD_INFRA_PATTERN}"; then
7268
FORCE_FULL_BUILD=true

script/dependency-parser/validate_pr.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
2+
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
3+
# SPDX-License-Identifier: MIT
4+
#
25
# Validate Smart Build vs Legacy Method for a PR
3-
#
6+
#
47
# This script compares smart build and legacy dependency analysis
58
# to ensure both methods produce the same test selection results.
69

@@ -189,7 +192,7 @@ git log --oneline -5
189192

190193
log_section "Step 3: Analyze Changed Files"
191194
log_info "Files changed vs $BASE_BRANCH:"
192-
CHANGED_FILES=$(git diff --name-only ${BASE_BRANCH}..HEAD -- projects/composablekernel)
195+
CHANGED_FILES=$(git diff --name-only ${BASE_BRANCH}...HEAD -- projects/composablekernel)
193196
NUM_FILES=$(echo "$CHANGED_FILES" | wc -l)
194197
echo "$CHANGED_FILES" | head -20
195198
if [ "$NUM_FILES" -gt 20 ]; then

0 commit comments

Comments
 (0)