From: David Galloway Date: Wed, 3 Feb 2021 17:49:51 +0000 (-0500) Subject: ceph-pull-requests: Skip make check on a docs-only PR X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6d7321a124309244466509e40bce188da06c7114;p=ceph-build.git ceph-pull-requests: Skip make check on a docs-only PR Signed-off-by: David Galloway --- diff --git a/ceph-pull-requests/build/build b/ceph-pull-requests/build/build index 93778560..0c3ccf1d 100644 --- a/ceph-pull-requests/build/build +++ b/ceph-pull-requests/build/build @@ -1,4 +1,11 @@ #!/bin/bash -ex + +docs_pr_only +if [ "$DOCS_ONLY" = true ]; then + echo "Only the doc/ dir changed. No need to run make check." + exit 0 +fi + export NPROC=$(nproc) export WITH_SEASTAR=true if which apt-get > /dev/null ; then diff --git a/ceph-pull-requests/config/definitions/ceph-pull-requests.yml b/ceph-pull-requests/config/definitions/ceph-pull-requests.yml index 1ef21979..14791cd0 100644 --- a/ceph-pull-requests/config/definitions/ceph-pull-requests.yml +++ b/ceph-pull-requests/config/definitions/ceph-pull-requests.yml @@ -85,3 +85,8 @@ wrappers: - ansicolor + - credentials-binding: + - username-password-separated: + credential-id: github-readonly-token + username: GITHUB_USER + password: GITHUB_PASS diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 8e19686e..20bc7a07 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1478,7 +1478,12 @@ docs_pr_only() { if ! [[ "$(git config --get remote.origin.url)" =~ "ceph/ceph.git" ]]; then cd "$WORKSPACE/ceph" fi - files="$(git diff --name-only origin/${ghprbTargetBranch}...origin/pr/${ghprbPullId}/head)" + 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 echo -e "changed files:\n$files" if [ $(echo "$files" | grep -v '^doc/' | wc -l) -gt 0 ]; then DOCS_ONLY=false