diff --git a/buildkite/bootstrap.sh b/buildkite/bootstrap.sh index f0e9119a..79dd3419 100644 --- a/buildkite/bootstrap.sh +++ b/buildkite/bootstrap.sh @@ -19,6 +19,10 @@ if [[ -z "${AMD_MIRROR_HW:-}" ]]; then AMD_MIRROR_HW="amdproduction" fi +if [[ -z "${DOCS_ONLY_DISABLE:-}" ]]; then + DOCS_ONLY_DISABLE=0 +fi + fail_fast() { DISABLE_LABEL="ci-no-fail-fast" # If BUILDKITE_PULL_REQUEST != "false", then we check the PR labels using curl and jq @@ -105,6 +109,40 @@ if [[ $BUILDKITE_BRANCH == "main" ]]; then file_diff=$(get_diff_main) fi +# ---------------------------------------------------------------------- +# Early exit start: skip pipeline if conditions are met +# ---------------------------------------------------------------------- + +# skip pipeline if all changed files are under docs/ +if [[ "${DOCS_ONLY_DISABLE}" != "1" ]]; then + if [[ -n "${file_diff:-}" ]]; then + docs_only=1 + # Robust iteration over newline-separated file_diff + while IFS= read -r f; do + [[ -z "$f" ]] && continue + # **Policy:** only skip if *every* path starts with docs/ + if [[ "$f" != docs/* ]]; then + docs_only=0 + break + fi + done <<< "$file_diff" + + 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 + +# ---------------------------------------------------------------------- +# Early exit end +# ---------------------------------------------------------------------- + patterns=( "docker/Dockerfile" "CMakeLists.txt"