Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Deterministic cosign installer for CI deploy jobs.
set -euo pipefail
COSIGN_VERSION="${COSIGN_VERSION:-v3.0.6}"
COSIGN_SHA256="${COSIGN_SHA256:-c956e5dfcac53d52bcf058360d579472f0c1d2d9b69f55209e256fe7783f4c74}"
COSIGN_URL="${COSIGN_URL:-https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/cosign-linux-amd64}"
COSIGN_INSTALL_PATH="${COSIGN_INSTALL_PATH:-/usr/local/bin/cosign}"
if command -v cosign >/dev/null 2>&1; then
cosign version
exit 0
fi
tmp_file="$(mktemp)"
cleanup() {
rm -f "$tmp_file"
}
trap cleanup EXIT
curl --fail --silent --show-error --location "$COSIGN_URL" --output "$tmp_file"
printf '%s %s\n' "$COSIGN_SHA256" "$tmp_file" | sha256sum --check --status
install -m 0755 "$tmp_file" "$COSIGN_INSTALL_PATH"
cosign version
+127
View File
@@ -0,0 +1,127 @@
#!/usr/bin/env bash
# Sentry release helper used by GitHub + Gitea CI to tag releases,
# upload source-maps, correlate commits and mark deploys against our
# self-hosted Sentry (https://sentry.boiler.saas-ctrl.com).
#
# Usage:
# scripts/ci/sentry-release.sh \
# --project <name> \
# --environment <env> \
# --release <git-sha> \
# --sourcemaps <path-or-"none">
#
# Required environment variables:
# SENTRY_AUTH_TOKEN Auth token scoped to project:releases
# SENTRY_ORG Sentry organisation slug (e.g. "sentry")
# SENTRY_URL Base URL of the self-hosted instance
#
# This script intentionally never prints the auth token. Callers in CI
# should mask SENTRY_AUTH_TOKEN via the runner's secret masking.
set -euo pipefail
PROJECT=""
ENVIRONMENT=""
RELEASE=""
SOURCEMAPS="none"
usage() {
cat <<USAGE >&2
sentry-release.sh: arguments
--project <name> Sentry project slug (required)
--environment <env> Deploy environment name (required)
--release <release> Release identifier (usually \$GIT_SHA, required)
--sourcemaps <path|none> Directory to upload source-maps from, or "none"
Required env vars: SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_URL
USAGE
}
while [ $# -gt 0 ]; do
case "$1" in
--project)
PROJECT="${2:-}"
shift 2
;;
--environment)
ENVIRONMENT="${2:-}"
shift 2
;;
--release)
RELEASE="${2:-}"
shift 2
;;
--sourcemaps)
SOURCEMAPS="${2:-none}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "sentry-release.sh: unknown argument: $1" >&2
usage
exit 2
;;
esac
done
missing=()
[ -z "$PROJECT" ] && missing+=("--project")
[ -z "$ENVIRONMENT" ] && missing+=("--environment")
[ -z "$RELEASE" ] && missing+=("--release")
if [ "${#missing[@]}" -gt 0 ]; then
echo "sentry-release.sh: missing required argument(s): ${missing[*]}" >&2
usage
exit 2
fi
missing_env=()
[ -z "${SENTRY_AUTH_TOKEN:-}" ] && missing_env+=("SENTRY_AUTH_TOKEN")
[ -z "${SENTRY_ORG:-}" ] && missing_env+=("SENTRY_ORG")
[ -z "${SENTRY_URL:-}" ] && missing_env+=("SENTRY_URL")
if [ "${#missing_env[@]}" -gt 0 ]; then
echo "sentry-release.sh: missing required environment variable(s): ${missing_env[*]}" >&2
exit 3
fi
# Pinning the CLI version keeps CI deterministic; bump intentionally.
SENTRY_CLI_PACKAGE="${SENTRY_CLI_PACKAGE:-@sentry/cli@2.41.1}"
# Allow tests to inject a fake binary by overriding SENTRY_CLI.
if [ -n "${SENTRY_CLI:-}" ]; then
sentry_cli() {
"$SENTRY_CLI" "$@"
}
else
sentry_cli() {
npx --yes "$SENTRY_CLI_PACKAGE" "$@"
}
fi
export SENTRY_AUTH_TOKEN SENTRY_ORG SENTRY_URL
export SENTRY_PROJECT="$PROJECT"
# Disable shell-trace if a caller enabled it — protects the auth token
# from leaking into log surfaces.
set +x
echo "sentry-release: project=$PROJECT environment=$ENVIRONMENT release=$RELEASE sourcemaps=$SOURCEMAPS"
sentry_cli releases new "$RELEASE"
if [ "$SOURCEMAPS" != "none" ]; then
if [ ! -d "$SOURCEMAPS" ]; then
echo "sentry-release.sh: sourcemaps path does not exist: $SOURCEMAPS" >&2
exit 4
fi
sentry_cli sourcemaps upload --release "$RELEASE" "$SOURCEMAPS"
fi
sentry_cli releases set-commits "$RELEASE" --auto
sentry_cli releases finalize "$RELEASE"
sentry_cli releases deploys "$RELEASE" new -e "$ENVIRONMENT"
echo "sentry-release: done"
+201
View File
@@ -0,0 +1,201 @@
#!/usr/bin/env bash
# Bash test harness for scripts/ci/sentry-release.sh.
#
# Approach: replace sentry-cli with a stub via SENTRY_CLI=... env and
# assert the wrapper passes through the expected arguments to it.
# Each test runs in its own temp dir.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HELPER="$SCRIPT_DIR/sentry-release.sh"
PASS=0
FAIL=0
ok() {
echo " ok: $1"
PASS=$((PASS + 1))
}
fail() {
echo " FAIL: $1" >&2
FAIL=$((FAIL + 1))
}
run_test() {
local name="$1"
shift
echo "test: $name"
"$@"
}
make_stub() {
local logfile="$1"
local exitcode="${2:-0}"
local stubdir
stubdir="$(mktemp -d)"
cat <<STUB > "$stubdir/sentry-cli-stub"
#!/usr/bin/env bash
printf '%s\n' "\$*" >> "$logfile"
exit $exitcode
STUB
chmod +x "$stubdir/sentry-cli-stub"
echo "$stubdir/sentry-cli-stub"
}
assert_contains() {
local logfile="$1"
local needle="$2"
if grep -Fq "$needle" "$logfile"; then
ok "log contains: $needle"
else
fail "log missing: $needle (log: $(cat "$logfile" | tr '\n' '|'))"
fi
}
assert_not_contains() {
local logfile="$1"
local needle="$2"
if grep -Fq "$needle" "$logfile"; then
fail "log unexpectedly contains: $needle"
else
ok "log absent: $needle"
fi
}
# ---------------------------------------------------------------
test_happy_path_with_sourcemaps() {
local tmp
tmp="$(mktemp -d)"
local log="$tmp/calls.log"
local stub
stub="$(make_stub "$log")"
local sourcemaps="$tmp/sm"
mkdir -p "$sourcemaps"
SENTRY_CLI="$stub" \
SENTRY_AUTH_TOKEN="t" SENTRY_ORG="sentry" SENTRY_URL="https://sentry.example" \
bash "$HELPER" \
--project boilerplate-web \
--environment production \
--release abc123 \
--sourcemaps "$sourcemaps" >/dev/null
assert_contains "$log" "releases new abc123"
assert_contains "$log" "sourcemaps upload --release abc123 $sourcemaps"
assert_contains "$log" "releases set-commits abc123 --auto"
assert_contains "$log" "releases finalize abc123"
assert_contains "$log" "releases deploys abc123 new -e production"
}
# ---------------------------------------------------------------
test_happy_path_without_sourcemaps() {
local tmp
tmp="$(mktemp -d)"
local log="$tmp/calls.log"
local stub
stub="$(make_stub "$log")"
SENTRY_CLI="$stub" \
SENTRY_AUTH_TOKEN="t" SENTRY_ORG="sentry" SENTRY_URL="https://sentry.example" \
bash "$HELPER" \
--project boilerplate-api \
--environment staging \
--release deadbeef \
--sourcemaps none >/dev/null
assert_contains "$log" "releases new deadbeef"
assert_not_contains "$log" "sourcemaps upload"
assert_contains "$log" "releases set-commits deadbeef --auto"
assert_contains "$log" "releases deploys deadbeef new -e staging"
}
# ---------------------------------------------------------------
test_missing_env_var_fails() {
local tmp
tmp="$(mktemp -d)"
local log="$tmp/calls.log"
local stub
stub="$(make_stub "$log")"
set +e
SENTRY_CLI="$stub" \
SENTRY_ORG="sentry" SENTRY_URL="https://sentry.example" \
bash "$HELPER" \
--project boilerplate-api \
--environment staging \
--release deadbeef \
--sourcemaps none >/dev/null 2>&1
local rc=$?
set -e
if [ "$rc" -ne 0 ]; then
ok "exits non-zero when SENTRY_AUTH_TOKEN missing (rc=$rc)"
else
fail "expected non-zero exit when SENTRY_AUTH_TOKEN missing"
fi
}
# ---------------------------------------------------------------
test_missing_required_arg_fails() {
local tmp
tmp="$(mktemp -d)"
local log="$tmp/calls.log"
local stub
stub="$(make_stub "$log")"
set +e
SENTRY_CLI="$stub" \
SENTRY_AUTH_TOKEN="t" SENTRY_ORG="sentry" SENTRY_URL="https://sentry.example" \
bash "$HELPER" \
--environment staging \
--release deadbeef \
--sourcemaps none >/dev/null 2>&1
local rc=$?
set -e
if [ "$rc" -ne 0 ]; then
ok "exits non-zero when --project missing (rc=$rc)"
else
fail "expected non-zero exit when --project missing"
fi
}
# ---------------------------------------------------------------
test_missing_sourcemap_dir_fails() {
local tmp
tmp="$(mktemp -d)"
local log="$tmp/calls.log"
local stub
stub="$(make_stub "$log")"
set +e
SENTRY_CLI="$stub" \
SENTRY_AUTH_TOKEN="t" SENTRY_ORG="sentry" SENTRY_URL="https://sentry.example" \
bash "$HELPER" \
--project boilerplate-web \
--environment production \
--release abc \
--sourcemaps "$tmp/does-not-exist" >/dev/null 2>&1
local rc=$?
set -e
if [ "$rc" -ne 0 ]; then
ok "exits non-zero when sourcemaps dir missing (rc=$rc)"
else
fail "expected non-zero exit when sourcemaps dir missing"
fi
}
run_test "happy-path with sourcemaps" test_happy_path_with_sourcemaps
run_test "happy-path without sourcemaps" test_happy_path_without_sourcemaps
run_test "missing env var fails" test_missing_env_var_fails
run_test "missing required arg fails" test_missing_required_arg_fails
run_test "missing sourcemap dir fails" test_missing_sourcemap_dir_fails
echo
echo "Summary: $PASS passed, $FAIL failed"
if [ "$FAIL" -gt 0 ]; then
exit 1
fi