mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-20 06:49:15 +00:00
[rocm-libraries] ROCm/rocm-libraries#4943 (commit ea40212)
[CK] Updating CI skip logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Motivation The CI skip logic has two issues that prevented it from working correctly: 1. **Incorrect file patterns**: After migrating from standalone repo to `rocm-libraries`, file paths now include the `projects/composablekernel/` prefix (e.g., `projects/composablekernel/docs/README.md`). The skip patterns were still checking for paths starting with `docs/`, which never matched. 2. **Incomplete build type support**: Jenkins multibranch pipelines provide different environment variables for PR builds (`$CHANGE_TARGET`, `$CHANGE_ID`) vs branch builds (`$BRANCH_NAME`). The previous logic only compared `HEAD~1..HEAD` for branch builds, which missed changes from multi-commit pushes and didn't properly handle feature branch builds. When CI skipped or ran, there was no visibility into which files triggered the decision, making it difficult to diagnose issues. You can now see which files triggered the CI run. ## Technical Details PR builds: Compares all commits against origin/$CHANGE_TARGET. Feature branch builds: Uses git merge-base to find divergence point from develop and checks all touched files since then. Scheduled develop builds are unaffected. These builds are forced to run from the pipeline parameters. Example log output for PR Builds: <img width="647" height="260" alt="image" src="https://github.com/user-attachments/assets/c8673a81-acb2-4fb2-acbb-1c07b5ab3b69" /> Example log output for Branch Builds: <img width="488" height="287" alt="image" src="https://github.com/user-attachments/assets/fbb17ba7-eb2c-42a4-b820-b2a8b9e479c4" /> ## Test Plan Pre-PR validation (branch builds): Push commits with only documentation changes → CI should skip. I will have to verify this after this PR is merged! Push commits with code changes → CI should run Push commits that modify then revert code → CI should run (catching reverts) Verify debug output clearly shows skip/run decision Post-PR validation (PR builds): Create PR with only doc changes → CI should skip. I will have to verify this after this PR is merged! Create PR with mixed doc + code changes → CI should run and log which files triggered it Verify debug output clearly shows skip/run decision ## Test Result All branch build checks succeeded. All PR build checks succeeded. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
This commit is contained in:
committed by
assistant-librarian[bot]
parent
f00ec5afd9
commit
0d595e04ba
66
Jenkinsfile
vendored
66
Jenkinsfile
vendored
@@ -259,26 +259,40 @@ def runShell(String command){
|
||||
}
|
||||
|
||||
def shouldRunCICheck() {
|
||||
// Define patterns for files that should not trigger CI
|
||||
// File patterns that should not trigger CI
|
||||
def skipFilePatterns = [
|
||||
/^\.github\/.*/, // GitHub workflow files
|
||||
/^docs\/.*/, // Documentation files
|
||||
/^LICENSE$/, // License file
|
||||
/^.*\.gitignore$/, // Git ignore files
|
||||
/.*\.md$/ // Markdown files
|
||||
/^projects\/composablekernel\/\.github\/.*/, // GitHub workflow files
|
||||
/^projects\/composablekernel\/docs\/.*/, // Documentation files
|
||||
/^projects\/composablekernel\/LICENSE$/, // License file
|
||||
/^projects\/composablekernel\/.*\.gitignore$/, // Git ignore files
|
||||
/^projects\/composablekernel\/.*\.md$/ // Markdown files
|
||||
]
|
||||
|
||||
try {
|
||||
// Get the list of changed files
|
||||
// Always run if this is a base branch build
|
||||
def baseBranch = "develop"
|
||||
def isBaseBranchBuild = (env.CHANGE_ID == null && env.BRANCH_NAME == baseBranch)
|
||||
|
||||
if (isBaseBranchBuild) {
|
||||
echo "Base branch (${baseBranch}) build detected - always running CI for safety"
|
||||
return true
|
||||
}
|
||||
|
||||
// Get the list of changed files (all files touched in any commit, even if reverted)
|
||||
def changedFiles = sh(
|
||||
returnStdout: true,
|
||||
script: '''
|
||||
BASE_BRANCH="develop"
|
||||
|
||||
if [ "$CHANGE_ID" != "" ]; then
|
||||
# For PR builds, compare against target branch
|
||||
git diff --name-only origin/$CHANGE_TARGET...HEAD -- projects/composablekernel/
|
||||
# For PR builds, get all files touched in any commit
|
||||
echo "PR build detected, checking all touched files against origin/$CHANGE_TARGET" >&2
|
||||
git log --name-only --pretty=format: origin/$CHANGE_TARGET..HEAD -- projects/composablekernel/ | sort -u | grep -v '^$'
|
||||
else
|
||||
# For regular builds, compare against previous commit
|
||||
git diff --name-only HEAD~1..HEAD -- projects/composablekernel/
|
||||
# For feature branch builds, compare against merge-base with base branch
|
||||
MERGE_BASE=$(git merge-base HEAD origin/$BASE_BRANCH 2>/dev/null || echo "HEAD~1")
|
||||
echo "Branch build detected, checking all touched files since merge-base: $MERGE_BASE" >&2
|
||||
git log --name-only --pretty=format: $MERGE_BASE..HEAD -- projects/composablekernel/ | sort -u | grep -v '^$'
|
||||
fi
|
||||
'''
|
||||
).trim().split('\n')
|
||||
@@ -290,20 +304,36 @@ def shouldRunCICheck() {
|
||||
|
||||
echo "Changed files: ${changedFiles.join(', ')}"
|
||||
|
||||
// Check if any changed files are not in the skip patterns
|
||||
def hasFilesRequiringCI = changedFiles.any { file ->
|
||||
!skipFilePatterns.any { pattern ->
|
||||
// Separate files into those requiring CI and those that can be skipped
|
||||
def filesRequiringCI = []
|
||||
def skippedFiles = []
|
||||
|
||||
changedFiles.each { file ->
|
||||
def shouldSkip = skipFilePatterns.any { pattern ->
|
||||
file ==~ pattern
|
||||
}
|
||||
|
||||
if (shouldSkip) {
|
||||
skippedFiles.add(file)
|
||||
} else {
|
||||
filesRequiringCI.add(file)
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFilesRequiringCI) {
|
||||
echo "Found files that require CI"
|
||||
|
||||
// Debug output
|
||||
if (skippedFiles.size() > 0) {
|
||||
echo "Files that don't require CI (${skippedFiles.size()}):"
|
||||
skippedFiles.each { echo " - ${it}" }
|
||||
}
|
||||
|
||||
if (filesRequiringCI.size() > 0) {
|
||||
echo "Files that require CI (${filesRequiringCI.size()}):"
|
||||
filesRequiringCI.each { echo " - ${it}" }
|
||||
return true
|
||||
} else {
|
||||
echo "Only non-relevant files changed, skipping CI"
|
||||
return false
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
echo "Error checking changed files: ${e.getMessage()}, running CI by default"
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user