]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
PR checks: Send status updates if manually triggered 2613/head
authorDavid Galloway <david.galloway@ibm.com>
Mon, 15 Jun 2026 20:57:34 +0000 (16:57 -0400)
committerDavid Galloway <david.galloway@ibm.com>
Tue, 16 Jun 2026 14:18:57 +0000 (10:18 -0400)
Signed-off-by: David Galloway <david.galloway@ibm.com>
ceph-pr-api/build/build
ceph-pr-api/config/definitions/ceph-pr-api.yml
ceph-pull-requests-arm64/build/build
ceph-pull-requests-arm64/config/definitions/ceph-pull-requests-arm64.yml
ceph-pull-requests/build/build
ceph-pull-requests/config/definitions/ceph-pull-requests.yml
ceph-windows-pull-requests/build/check_docs_pr_only
ceph-windows-pull-requests/config/definitions/ceph-windows-pull-requests.yml
scripts/build_utils.sh
scripts/ceph-windows/run_tests

index 44b81dcd767294efe1959fc1ecc5e8cff392417c..f20872743046350b666becffc7697c6e899d8991 100644 (file)
@@ -4,6 +4,16 @@ if [[ "${ROOT_BUILD_CAUSE}" == "MANUALTRIGGER" ]]; then
     ghprbGhRepository="ceph/ceph"
 fi
 
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so it fires no matter which stage (make check, dep
+# install, or API tests) the job exits on, including the docs-only early exit
+# below (which reports success).
+trap 'report_github_pr_status $? "ceph API tests"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running API tests" "ceph API tests"
+
 docs_pr_only
 container_pr_only
 gha_pr_only
index dfca61988bf3917f09922e8b61e5e1eb0abea2c3..45b9781627e2aaf19a9a8e0a0476fbacdbeee96a 100644 (file)
               credential-id: github-readonly-token
               username: GITHUB_USER
               password: GITHUB_PASS
+          - username-password-separated:
+              credential-id: github-status-check-token
+              username: GITHUB_STATUS_USER
+              password: GITHUB_STATUS_TOKEN
 
 - project:
     name: ceph-api-project
index e586750922d91d5e35f6bde3e008e8ef46c6b40c..1c69f2f613a4ea74d367a58c4a2289c05a14eec6 100644 (file)
@@ -1,5 +1,14 @@
 #!/bin/bash -ex
 
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so it fires no matter where the job exits, including
+# the docs-only early exit below (which reports success).
+trap 'report_github_pr_status $? "make check (arm64)" "make check"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running make check" "make check (arm64)"
+
 docs_pr_only
 container_pr_only
 gha_pr_only
@@ -26,3 +35,14 @@ bwc 4 -e tests
 npm_cache_info
 sleep 5
 ps -ef | grep -v jnlp | grep ceph || true
+
+# `bwc -e tests` exits 0 even when individual tests fail so that the CTest
+# results are always published; the xUnit publisher is what fails the build (its
+# threshold fails on any failed test).  A non-test failure (e.g. compile) would
+# have aborted above under `set -e`.  Mirror xUnit here so the EXIT trap reports
+# the matching GitHub status for manual triggers.
+test_xml="$(find build/Testing -name Test.xml 2>/dev/null)"
+if [ -n "$test_xml" ] && grep -q 'Status="failed"' $test_xml; then
+    echo "CTest reported one or more failed tests; marking the build as failed."
+    exit 1
+fi
index 73d00ca96c15b2e395b7c9b82b4685bf6fe03efe..34871a060ff469e93b85126b853a2264840b63b5 100644 (file)
               credential-id: github-readonly-token
               username: GITHUB_USER
               password: GITHUB_PASS
+          - username-password-separated:
+              credential-id: github-status-check-token
+              username: GITHUB_STATUS_USER
+              password: GITHUB_STATUS_TOKEN
           - username-password-separated:
               credential-id: dgalloway-docker-hub
               username: DOCKER_HUB_USERNAME
index ec8cc8071fe017cd2a0475553497f0aeb2aa6427..02bb2b0360d0389a2bb60c9dfe5de5689c9aced0 100644 (file)
@@ -1,5 +1,14 @@
 #!/bin/bash -ex
 
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so it fires no matter where the job exits, including
+# the docs-only early exit below (which reports success).
+trap 'report_github_pr_status $? "make check"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running make check" "make check"
+
 docs_pr_only
 container_pr_only
 gha_pr_only
@@ -25,3 +34,14 @@ bwc 4 -e tests
 npm_cache_info
 sleep 5
 ps -ef | grep -v jnlp | grep ceph || true
+
+# `bwc -e tests` exits 0 even when individual tests fail so that the CTest
+# results are always published; the xUnit publisher is what fails the build (its
+# threshold fails on any failed test).  A non-test failure (e.g. compile) would
+# have aborted above under `set -e`.  Mirror xUnit here so the EXIT trap reports
+# the matching GitHub status for manual triggers.
+test_xml="$(find build/Testing -name Test.xml 2>/dev/null)"
+if [ -n "$test_xml" ] && grep -q 'Status="failed"' $test_xml; then
+    echo "CTest reported one or more failed tests; marking the build as failed."
+    exit 1
+fi
index 9fc86f970ef0035592837a0f02685ed504cf7084..bd1904ec6e0c370248388cfa6d4906c0480a2272 100644 (file)
               credential-id: github-readonly-token
               username: GITHUB_USER
               password: GITHUB_PASS
+          - username-password-separated:
+              credential-id: github-status-check-token
+              username: GITHUB_STATUS_USER
+              password: GITHUB_STATUS_TOKEN
           - username-password-separated:
               credential-id: dgalloway-docker-hub
               username: DOCKER_HUB_USERNAME
index 82854b8b326c39e71d2df0f91e5296717b4f88e0..76166abea34d60fa783a7ff0c5f85b32a16f0f22 100644 (file)
@@ -2,6 +2,16 @@
 set -o errexit
 set -o pipefail
 
+# For manually-triggered jobs, report the final result back to GitHub as a
+# commit status (webhook-triggered jobs get this from the PR Builder plugin).
+# Installed as an EXIT trap so a failure anywhere in the setup stages (or the
+# docs-only early exit below) is reported.  Note: run_tests installs its own
+# EXIT trap later in the chain which supersedes this one and also reports.
+trap 'report_github_pr_status $? "ceph windows tests"' EXIT
+
+# Report that the job has started (manual triggers only).
+update_github_pr_status "pending" "running ceph windows tests" "ceph windows tests"
+
 docs_pr_only
 container_pr_only
 gha_pr_only
index 1848522917e09b871d0b08cfb64b2df33a827004..233625475b3c5d017c31b06c4099fcabb1c0c2d4 100644 (file)
               credential-id: github-readonly-token
               username: GITHUB_USER
               password: GITHUB_PASS
+          - username-password-separated:
+              credential-id: github-status-check-token
+              username: GITHUB_STATUS_USER
+              password: GITHUB_STATUS_TOKEN
index 907dc6ab840d7bbeaa64f28b99676ec5e41243c5..b8d173698f9606b35e89b7f228f7621605cef2e7 100755 (executable)
@@ -1250,6 +1250,76 @@ github_status_setup() {
 
 }
 
+# Report a Pull Request job's result back to GitHub as a commit status (check).
+# The GitHub Pull Request Builder plugin does this automatically when a webhook
+# triggers the job, but manually-triggered jobs don't get that, so post the
+# status directly via the GitHub API.
+#   $1 - state: one of pending, success, failure, error
+#   $2 - description shown alongside the check (optional)
+#   $3 - status context/name (optional, defaults to "make check")
+#   $4 - target URL the check links to in the GitHub UI (optional, defaults to
+#        this Jenkins build's URL)
+update_github_pr_status() {
+  local state=$1
+  local description=$2
+  local context=${3:-"make check"}
+  # Link the check back to this Jenkins build so clicking the context in the
+  # GitHub UI opens the job.
+  local target_url=${4:-$BUILD_URL}
+
+  # Only post a status for manually-triggered jobs.  Webhook-triggered jobs
+  # already have their status managed by the GitHub Pull Request Builder plugin,
+  # so posting here would just be a duplicate.  Check ROOT_BUILD_CAUSE too so a
+  # job kicked off down an upstream chain from a manual trigger is still covered.
+  if [ "$BUILD_CAUSE" != "MANUALTRIGGER" ] && [ "$ROOT_BUILD_CAUSE" != "MANUALTRIGGER" ]; then
+    return 0
+  fi
+
+  # Manually-triggered jobs don't have the ghprb* variables set by the plugin.
+  # Assume ceph/ceph and look up the PR's head commit from the GitHub API.
+  ghprbGhRepository="ceph/ceph"
+  ghprbActualCommit="$(curl -s -u ${GITHUB_USER}:${GITHUB_PASS} https://api.github.com/repos/${ghprbGhRepository}/pulls/${ghprbPullId} | jq -r '.head.sha')"
+
+  if [ -z "$ghprbActualCommit" ] || [ -z "$ghprbGhRepository" ]; then
+    echo "Could not determine commit or repository; skipping GitHub status update"
+    return 0
+  fi
+
+  echo "Setting GitHub status '$context' to '$state' for ${ghprbGhRepository}@${ghprbActualCommit}"
+  # Posting a status needs a token with write access, unlike the read-only token
+  # in GITHUB_USER/GITHUB_PASS used for the lookup above.
+  curl -s -u ${GITHUB_STATUS_USER}:${GITHUB_STATUS_TOKEN} \
+    -X POST \
+    -H "Accept: application/vnd.github+json" \
+    "https://api.github.com/repos/${ghprbGhRepository}/statuses/${ghprbActualCommit}" \
+    -d "$(jq -n \
+      --arg state "$state" \
+      --arg target_url "$target_url" \
+      --arg description "$description" \
+      --arg context "$context" \
+      '{state: $state, target_url: $target_url, description: $description, context: $context}')"
+}
+
+# Convenience wrapper meant to be installed as a bash EXIT trap so a Pull Request
+# job reports its overall pass/fail to GitHub regardless of which stage failed.
+# Like update_github_pr_status, it's a no-op unless the job was triggered
+# manually.  Pass $? explicitly from the trap so the exit code is captured before
+# anything in this function clobbers it, e.g.:
+#   trap 'report_github_pr_status $? "make check"' EXIT
+#   $1 - exit code (0 == success)
+#   $2 - status context/name (e.g. "make check (arm64)")
+#   $3 - label used in the description (optional, defaults to $2)
+report_github_pr_status() {
+  local rc=$1
+  local context=$2
+  local label=${3:-$context}
+  if [ "$rc" -eq 0 ]; then
+    update_github_pr_status "success" "$label succeeded" "$context"
+  else
+    update_github_pr_status "failure" "$label failed" "$context"
+  fi
+}
+
 write_collect_logs_playbook() {
     cat > $WORKSPACE/collect-logs.yml << EOF
 - hosts: all
index 6e2da2d79a455a0e7844e91590d95cd856c0c0c6..f6e40f22eb883d4aa1a2c5f92580a31c04fadbd3 100644 (file)
@@ -85,7 +85,17 @@ function collect_artifacts() {
     scp_download /workspace/eventlogs $WORKSPACE/artifacts/client/eventlogs
     echo "Successfully retrieved artifacts."
 }
-trap collect_artifacts EXIT
+#
+# On exit, report the result to GitHub (manual triggers only) and then collect
+# artifacts.  $? is captured first so the job's real exit code is reported
+# before anything in the trap clobbers it.
+#
+function on_exit() {
+    local rc=$?
+    report_github_pr_status $rc "ceph windows tests"
+    collect_artifacts
+}
+trap on_exit EXIT
 
 # View cluster status before test run
 SSH_USER=$UBUNTU_SSH_USER SSH_ADDRESS=$UBUNTU_VM_IP ssh_exec ./ceph/build/bin/ceph status