Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839#!/usr/bin/env bash# Whether a deploy of this commit can be rolled back to <rev> by starting# <rev>'s image again, without restoring the snapshot.## Builds <rev>'s didbot-pds in a scratch worktree, then runs the ignored# test `the_previous_release_serves_what_this_one_wrote` in# crates/didbot-serve/tests/deploy_restart.rs: this commit writes a data# directory, and <rev>'s binary has to start on it and serve it. <rev> is# most often the commit the deployment runs now.## Usage: scripts/rollback-check.sh <rev>## <rev>'s build goes to ROLLBACK_TARGET_DIR, by default a directory named for# its commit under the system's temporary directory, and is kept there for# the next run. It carries no debug info, which makes it a fraction of the# size. This commit builds to CARGO_TARGET_DIR, as cargo does.set -euo pipefail
cd "$(dirname "$0")/.."
if [ $# -ne 1 ]; then echo "usage: scripts/rollback-check.sh <rev>" >&2 exit 2fisha="$(git rev-parse --verify "$1^{commit}")"short="$(git rev-parse --short "$sha")"target="${ROLLBACK_TARGET_DIR:-${TMPDIR:-/tmp}/didbot-rollback-target-$short}"tree="$(mktemp -d "${TMPDIR:-/tmp}/didbot-rollback-$short.XXXXXX")"trap 'git worktree remove --force "$tree" >/dev/null 2>&1 || true' EXIT
git worktree add --quiet --detach "$tree" "$sha"echo "==> building didbot-pds at $short into $target"(cd "$tree" && CARGO_TARGET_DIR="$target" CARGO_PROFILE_DEV_DEBUG=0 \ cargo build --quiet -p didbot-serve --bin didbot-pds)
echo "==> starting $short on a data directory $(git rev-parse --short HEAD) wrote"DIDBOT_PREVIOUS_PDS="$target/debug/didbot-pds" cargo test -p didbot-serve \ --test deploy_restart -- --ignored --nocapture the_previous_release_serves_what_this_one_wrote