feat(crm): add PMX due_time deploy verification script (BIT-1049)
Add scripts/crm/verify_pmx_bet_due_time_deploy.sh with gitea (ancestor check vs CRM_Project main) and runtime (SSH to crm-repo) modes. Point the due_time runbook at the script for operators without VPN on runners. Paperclip-Issue: BIT-1049
This commit is contained in:
1 parent
d9bd75a67e
commit
c610cb3bab
2 files changed
+55
No files matched your search
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
# Gitea + runtime checks for CRM `due_time` normalization on crm.pmx.bet.
|
||||
# See docs/RUNBOOK_REPORTER_CRM_TASKS_DUE_TIME.md §6 (BIT-1048 / BIT-1049 / BIT-887).
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/crm/verify_pmx_bet_due_time_deploy.sh gitea
|
||||
# [email protected] ./scripts/crm/verify_pmx_bet_due_time_deploy.sh runtime
|
||||
set -euo pipefail
|
||||
|
||||
readonly CRM_REPO_URL="${CRM_REPO_URL:-https://git.bitreport.pt/BitReport.pt/CRM_Project.git}"
|
||||
readonly SHA_E0="${DUE_TIME_FIX_SHA_E0:-e0f2b62bcc59a509a8b0543e7282d58bca023b54}"
|
||||
readonly SHA_30="${DUE_TIME_FIX_SHA_30:-30b74b19d3e27a53e5fcaf9a89e0989651f1222e}"
|
||||
readonly RUNTIME_GIT_DIR="${CRM_PMX_RUNTIME_GIT_DIR:-/data/wwwroot/crm-repo}"
|
||||
readonly FETCH_DEPTH="${CRM_GIT_FETCH_DEPTH:-500}"
|
||||
|
||||
cmd_gitea() {
|
||||
local tip tmp_repo
|
||||
tip="$(git ls-remote "$CRM_REPO_URL" refs/heads/main | awk '{print $1}')"
|
||||
echo "verify_pmx_bet_due_time_deploy: gitea refs/heads/main -> ${tip}"
|
||||
|
||||
tmp_repo="$(mktemp -d)"
|
||||
# Capture path at trap install time (RETURN runs before the function frame is discarded).
|
||||
trap "rm -rf \"${tmp_repo}\"" RETURN
|
||||
|
||||
git clone --quiet --depth 1 --branch main "$CRM_REPO_URL" "$tmp_repo/repo"
|
||||
git -C "$tmp_repo/repo" fetch --quiet --depth="$FETCH_DEPTH" origin main
|
||||
|
||||
git -C "$tmp_repo/repo" merge-base --is-ancestor "$SHA_E0" HEAD
|
||||
git -C "$tmp_repo/repo" merge-base --is-ancestor "$SHA_30" HEAD
|
||||
|
||||
local head_local
|
||||
head_local="$(git -C "$tmp_repo/repo" rev-parse HEAD)"
|
||||
echo "verify_pmx_bet_due_time_deploy: gitea ancestor OK (${SHA_E0}, ${SHA_30} ⊆ HEAD ${head_local})"
|
||||
if [[ "$head_local" != "$tip" ]]; then
|
||||
echo "verify_pmx_bet_due_time_deploy: note: shallow HEAD ${head_local} may differ from ls-remote tip ${tip}; widen CRM_GIT_FETCH_DEPTH if ancestor check fails after a large fast-forward." >&2
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_runtime() {
|
||||
: "${CRM_PMX_SSH:?set CRM_PMX_SSH, e.g. [email protected] (VPN required from most lab runners)}"
|
||||
|
||||
ssh -o BatchMode=yes "$CRM_PMX_SSH" \
|
||||
"set -euo pipefail; cd '${RUNTIME_GIT_DIR}' && git fetch -q origin && git rev-parse HEAD && git merge-base --is-ancestor ${SHA_E0} HEAD && git merge-base --is-ancestor ${SHA_30} HEAD && echo ancestors_ok"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
gitea) cmd_gitea ;;
|
||||
runtime) cmd_runtime ;;
|
||||
*)
|
||||
echo "usage: $0 gitea|runtime" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user