| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | repo_root="$(git rev-parse --show-toplevel)" |
| 5 | root="$(mktemp -d "${TMPDIR:-/tmp}/reasonix-stable-dispatch-test.XXXXXX")" |
| 6 | cleanup() { |
| 7 | case "$root" in */reasonix-stable-dispatch-test.*) rm -rf -- "$root" ;; *) exit 1 ;; esac |
| 8 | } |
| 9 | trap cleanup EXIT |
| 10 | |
| 11 | mkdir -p "$root/bin" |
| 12 | cat >"$root/bin/gh" <<'EOF' |
| 13 | #!/usr/bin/env bash |
| 14 | set -euo pipefail |
| 15 | body="$(cat)" |
| 16 | test "$1" = api |
| 17 | test "$2" = -X |
| 18 | test "$3" = POST |
| 19 | test "$4" = "repos/esengine/DeepSeek-Reasonix/actions/workflows/release-promote.yml/dispatches" |
| 20 | jq -e '.ref == "main-v2" and .inputs.candidate_id == "v1.2.3-aaaaaaaaaaaa-bbbbbbbbbbbb" and (.inputs.operation == "publish" or .inputs.operation == "recover")' <<<"$body" >/dev/null |
| 21 | EOF |
| 22 | chmod +x "$root/bin/gh" |
| 23 | |
| 24 | candidate=v1.2.3-aaaaaaaaaaaa-bbbbbbbbbbbb |
| 25 | PATH="$root/bin:$PATH" "$repo_root/scripts/release-stable.sh" "$candidate" |
| 26 | PATH="$root/bin:$PATH" "$repo_root/scripts/release-stable.sh" "$candidate" recover |
| 27 | |
| 28 | for invalid in 1.2.3 v1.2.3-short v1.2.3-aaaaaaaaaaaa-bbbbbbbbbbbz; do |
| 29 | if PATH="$root/bin:$PATH" "$repo_root/scripts/release-stable.sh" "$invalid" >/dev/null 2>&1; then |
| 30 | echo "invalid candidate unexpectedly dispatched: $invalid" >&2 |
| 31 | exit 1 |
| 32 | fi |
| 33 | done |
| 34 | if PATH="$root/bin:$PATH" "$repo_root/scripts/release-stable.sh" "$candidate" retry >/dev/null 2>&1; then |
| 35 | echo "invalid operation unexpectedly dispatched" >&2 |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | echo "stable candidate dispatch tests: PASS" |
| 40 |