From: Dan Mick Date: Tue, 29 Jul 2025 18:24:40 +0000 (-0700) Subject: Revert "removed build_utils dependency from ceph pull request job" X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b2d65c59a4be6609aca0d3edbe38ba732e9be984;p=ceph-build.git Revert "removed build_utils dependency from ceph pull request job" Jobs are using more than just the 'docs check' functions in build_utils.sh (ssh_exec, get_nr_build_jobs are two that showed up after merge). Revert this until it can be more-carefully evaluated. This reverts commit 28871177b6102eb3b17e260341eaa05a861628c1. --- diff --git a/ceph-pr-api/config/definitions/ceph-pr-api.yml b/ceph-pr-api/config/definitions/ceph-pr-api.yml index 9c251b34..b2afd6a9 100644 --- a/ceph-pr-api/config/definitions/ceph-pr-api.yml +++ b/ceph-pr-api/config/definitions/ceph-pr-api.yml @@ -66,7 +66,7 @@ builders: - shell: !include-raw-verbatim: - - ../../../scripts/pr_checks.sh + - ../../../scripts/build_utils.sh - ../../build/build - ../../../scripts/dashboard/install-backend-api-test-deps.sh - ../../build/api diff --git a/ceph-pr-commits/config/definitions/ceph-pr-commits.yml b/ceph-pr-commits/config/definitions/ceph-pr-commits.yml index fd81601c..38fa5446 100644 --- a/ceph-pr-commits/config/definitions/ceph-pr-commits.yml +++ b/ceph-pr-commits/config/definitions/ceph-pr-commits.yml @@ -73,7 +73,6 @@ - shell: !include-raw-verbatim: - ../../../scripts/build_utils.sh - - ../../../scripts/pr_checks.sh - ../../build/build publishers: diff --git a/ceph-pull-requests-arm64/config/definitions/ceph-pull-requests-arm64.yml b/ceph-pull-requests-arm64/config/definitions/ceph-pull-requests-arm64.yml index 30140a9c..624fa8c2 100644 --- a/ceph-pull-requests-arm64/config/definitions/ceph-pull-requests-arm64.yml +++ b/ceph-pull-requests-arm64/config/definitions/ceph-pull-requests-arm64.yml @@ -4,7 +4,7 @@ builders: - shell: !include-raw-verbatim: - - ../../../scripts/pr_checks.sh + - ../../../scripts/build_utils.sh - ../../build/build concurrent: true disabled: false diff --git a/ceph-pull-requests/config/definitions/ceph-pull-requests.yml b/ceph-pull-requests/config/definitions/ceph-pull-requests.yml index f8d6a47d..8cef990c 100644 --- a/ceph-pull-requests/config/definitions/ceph-pull-requests.yml +++ b/ceph-pull-requests/config/definitions/ceph-pull-requests.yml @@ -62,7 +62,7 @@ builders: - shell: !include-raw-verbatim: - - ../../../scripts/pr_checks.sh + - ../../../scripts/build_utils.sh - ../../build/build publishers: diff --git a/ceph-windows-pull-requests/config/definitions/ceph-windows-pull-requests.yml b/ceph-windows-pull-requests/config/definitions/ceph-windows-pull-requests.yml index 23e82283..abd1d797 100644 --- a/ceph-windows-pull-requests/config/definitions/ceph-windows-pull-requests.yml +++ b/ceph-windows-pull-requests/config/definitions/ceph-windows-pull-requests.yml @@ -67,7 +67,7 @@ builders: - shell: !include-raw-verbatim: - - ../../../scripts/pr_checks.sh + - ../../../scripts/build_utils.sh - ../../build/check_docs_pr_only - ../../../scripts/ceph-windows/setup_libvirt - ../../../scripts/ceph-windows/setup_libvirt_ubuntu_vm diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 334d6aab..598b1bf3 100755 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1694,6 +1694,70 @@ maybe_reset_ci_container() { fi } +# NOTE: These functions will only work on a Pull Request job! +pr_only_for() { + # $1 is passed by reference to avoid having to call with ${array[@]} and + # receive by creating another local array ("$@") + local -n local_patterns=$1 + local files + pushd . + # cd to ceph repo if we need to. + # The ceph-pr-commits job checks out ceph.git and ceph-build.git but most + # other jobs do not. + if ! [[ "$(git config --get remote.origin.url)" =~ "ceph/ceph.git" ]]; then + cd "$WORKSPACE/ceph" + fi + if [ -f $(git rev-parse --git-dir)/shallow ]; then + # We can't do a regular `git diff` in a shallow clone. There is no other way to check files changed. + files="$(curl -s -u ${GITHUB_USER}:${GITHUB_PASS} https://api.github.com/repos/${ghprbGhRepository}/pulls/${ghprbPullId}/files | jq '.[].filename' | tr -d '"')" + else + files="$(git diff --name-only origin/${ghprbTargetBranch}...origin/pr/${ghprbPullId}/head)" + fi + popd + echo -e "changed files:\n$files" + # 0 is true, 1 is false + local all_match=0 + for f in $files; do + local match=1 + for p in "${local_patterns[@]}"; do + # pattern loop: if one pattern matches, skip the others + if [[ $f == $p ]]; then match=0; break; fi + done + # file loop: if this file matched no patterns, the group fails + # (one mismatch spoils the whole bushel) + if [[ $match -eq 1 ]] ; then all_match=1; break; fi + done + return $all_match +} + +docs_pr_only() { + DOCS_ONLY=false + local patterns=( + 'doc/*' + 'admin/*' + 'src/sample.ceph.conf' + 'CodingStyle' + '*.rst' + '*.md' + 'COPYING*' + 'README.*' + 'SubmittingPatches' + '.readthedocs.yml' + 'PendingReleaseNotes' + ) + if pr_only_for patterns; then DOCS_ONLY=true; fi +} + +container_pr_only() { + CONTAINER_ONLY=false + local patterns=( + 'container/*' + 'Dockerfile.build' + 'src/script/buildcontainer-setup.sh' + 'src/script/build-with-container.py' + ) + if pr_only_for patterns; then CONTAINER_ONLY=true; fi +} function ssh_exec() { if [[ -z $SSH_ADDRESS ]]; then diff --git a/scripts/pr_checks.sh b/scripts/pr_checks.sh deleted file mode 100644 index bf422c64..00000000 --- a/scripts/pr_checks.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -ex -# vim: ts=4 sw=4 expandtab - -# NOTE: These functions will only work on a Pull Request job! -pr_only_for() { - # $1 is passed by reference to avoid having to call with ${array[@]} and - # receive by creating another local array ("$@") - local -n local_patterns=$1 - local files - pushd . - # cd to ceph repo if we need to. - # The ceph-pr-commits job checks out ceph.git and ceph-build.git but most - # other jobs do not. - if ! [[ "$(git config --get remote.origin.url)" =~ "ceph/ceph.git" ]]; then - cd "$WORKSPACE/ceph" - fi - if [ -f $(git rev-parse --git-dir)/shallow ]; then - # We can't do a regular `git diff` in a shallow clone. There is no other way to check files changed. - files="$(curl -s -u ${GITHUB_USER}:${GITHUB_PASS} https://api.github.com/repos/${ghprbGhRepository}/pulls/${ghprbPullId}/files | jq '.[].filename' | tr -d '"')" - else - files="$(git diff --name-only origin/${ghprbTargetBranch}...origin/pr/${ghprbPullId}/head)" - fi - popd - echo -e "changed files:\n$files" - # 0 is true, 1 is false - local all_match=0 - for f in $files; do - local match=1 - for p in "${local_patterns[@]}"; do - # pattern loop: if one pattern matches, skip the others - if [[ $f == $p ]]; then match=0; break; fi - done - # file loop: if this file matched no patterns, the group fails - # (one mismatch spoils the whole bushel) - if [[ $match -eq 1 ]] ; then all_match=1; break; fi - done - return $all_match -} - -docs_pr_only() { - DOCS_ONLY=false - local patterns=( - 'doc/*' - 'admin/*' - 'src/sample.ceph.conf' - 'CodingStyle' - '*.rst' - '*.md' - 'COPYING*' - 'README.*' - 'SubmittingPatches' - '.readthedocs.yml' - 'PendingReleaseNotes' - ) - if pr_only_for patterns; then DOCS_ONLY=true; fi -} - -container_pr_only() { - CONTAINER_ONLY=false - local patterns=( - 'container/*' - 'Dockerfile.build' - 'src/script/buildcontainer-setup.sh' - 'src/script/build-with-container.py' - ) - if pr_only_for patterns; then CONTAINER_ONLY=true; fi -} \ No newline at end of file