[ROCm] [CI] Add the same skip ci logic as CUDA CI (#3482)
Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
This commit is contained in:
1 parent
2c73cf3522
commit
67e0e10c85
2 files changed
+88
-23
No files matched your search
@@ -56,6 +56,88 @@ check_run_all_label() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_docs_only_change() {
|
||||||
|
local file_path
|
||||||
|
local has_any=0
|
||||||
|
|
||||||
|
while IFS= read -r file_path; do
|
||||||
|
[[ -z "${file_path}" ]] && continue
|
||||||
|
has_any=1
|
||||||
|
|
||||||
|
if [[ "${file_path}" == docs/* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ "${file_path}" == *.md ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ "${file_path}" == "mkdocs.yml" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ "${has_any}" -eq 1 ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_skip_ci() {
|
||||||
|
local is_pr_build=0
|
||||||
|
local files
|
||||||
|
local base_branch base_ref
|
||||||
|
|
||||||
|
if [[ "${BUILDKITE_PULL_REQUEST:-false}" != "false" && -n "${BUILDKITE_PULL_REQUEST:-}" ]]; then
|
||||||
|
is_pr_build=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${is_pr_build}" -eq 1 ]]; then
|
||||||
|
base_branch="${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-main}"
|
||||||
|
if ! git rev-parse --verify "origin/${base_branch}" >/dev/null 2>&1; then
|
||||||
|
echo "resolve_skip_ci: origin/${base_branch} not found locally; trying fetch" >&2
|
||||||
|
git fetch --depth=200 origin "${base_branch}" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
base_ref=""
|
||||||
|
if git rev-parse --verify "origin/${base_branch}" >/dev/null 2>&1; then
|
||||||
|
base_ref="origin/${base_branch}"
|
||||||
|
elif git rev-parse --verify "${base_branch}" >/dev/null 2>&1; then
|
||||||
|
base_ref="${base_branch}"
|
||||||
|
else
|
||||||
|
echo "resolve_skip_ci: cannot resolve PR base ${base_branch}; skip-ci=0" >&2
|
||||||
|
echo -n 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! files="$(git diff --name-only "${base_ref}...${BUILDKITE_COMMIT}" 2>/dev/null)"; then
|
||||||
|
echo "resolve_skip_ci: failed to compute PR changed files; skip-ci=0" >&2
|
||||||
|
echo -n 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
elif [[ "${BUILDKITE_BRANCH:-}" == "main" ]]; then
|
||||||
|
if ! git rev-parse --verify "${BUILDKITE_COMMIT}^" >/dev/null 2>&1; then
|
||||||
|
echo "resolve_skip_ci: commit has no parent on main; skip-ci=0" >&2
|
||||||
|
echo -n 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if ! files="$(git diff --name-only "${BUILDKITE_COMMIT}^..${BUILDKITE_COMMIT}" 2>/dev/null)"; then
|
||||||
|
echo "resolve_skip_ci: failed to compute main changed files; skip-ci=0" >&2
|
||||||
|
echo -n 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "resolve_skip_ci: not PR/main build; skip-ci=0" >&2
|
||||||
|
echo -n 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_docs_only_change <<< "${files}"; then
|
||||||
|
echo "resolve_skip_ci: docs-only change detected; skip-ci=1" >&2
|
||||||
|
echo -n 1
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "resolve_skip_ci: non-doc changes detected; skip-ci=0" >&2
|
||||||
|
echo -n 0
|
||||||
|
}
|
||||||
|
|
||||||
if [[ -z "${COV_ENABLED:-}" ]]; then
|
if [[ -z "${COV_ENABLED:-}" ]]; then
|
||||||
COV_ENABLED=0
|
COV_ENABLED=0
|
||||||
fi
|
fi
|
||||||
@@ -140,30 +222,13 @@ fi
|
|||||||
# Early exit start: skip pipeline if conditions are met
|
# Early exit start: skip pipeline if conditions are met
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
# skip pipeline if all changed files are under docs/
|
# Match CUDA Buildkite skip-ci behavior for docs/markdown-only changes.
|
||||||
if [[ "${DOCS_ONLY_DISABLE}" != "1" ]]; then
|
if [[ "${DOCS_ONLY_DISABLE}" != "1" ]]; then
|
||||||
if [[ -n "${file_diff:-}" ]]; then
|
SKIP_CI="$(resolve_skip_ci)"
|
||||||
docs_only=1
|
if [[ "${SKIP_CI}" == "1" ]]; then
|
||||||
# Robust iteration over newline-separated file_diff
|
echo "[docs-only] Docs/markdown-only changes detected. Exiting before pipeline upload."
|
||||||
while IFS= read -r f; do
|
exit 0
|
||||||
[[ -z "$f" ]] && continue
|
|
||||||
# **Policy:** only skip if *every* path starts with docs/
|
|
||||||
if [[ "$f" != docs/* ]]; then
|
|
||||||
docs_only=0
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done < <(printf '%s\n' "$file_diff" | tr ' ' '\n' | tr -d '\r')
|
|
||||||
|
|
||||||
if [[ "$docs_only" -eq 1 ]]; then
|
|
||||||
buildkite-agent annotate ":memo: CI skipped — docs/** only changes detected
|
|
||||||
|
|
||||||
\`\`\`
|
|
||||||
${file_diff}
|
|
||||||
\`\`\`" --style "info" || true
|
|
||||||
echo "[docs-only] All changes are under docs/. Exiting before pipeline upload."
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ is_docs_only_change() {
|
|||||||
if [[ "${file_path}" == *.md ]]; then
|
if [[ "${file_path}" == *.md ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [[ "${file_path}" == "mkdocs.yaml" ]]; then
|
if [[ "${file_path}" == "mkdocs.yml" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in new issue
Block a user