Astra: regression catalogue, runner robustness, idempotent Agent Studio contract, key-screen design (2182ef729b22)
152e0c1 verified Download deploy/runner/sync.sh from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/deploy/runner/sync.sh
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/deploy/runner/sync.sh
-
curl -L -o sync.sh https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/deploy/runner/sync.sh
2.82 kB
| # Puts this repo's committed automation/ and tests/ on a browser runner, so the runner runs the same scenarios and | |
| # step code as the Astra server. Run it after every Astra deploy, from the repo, on the commit that was deployed: | |
| # deploy/runner/sync.sh ubuntu@runner-host ~/.ssh/runner_key [https://runner.example.com] | |
| # It refuses while the runner is busy (a test run would lose its browsers), keeps the previous copy as astra.prev, | |
| # reuses node_modules when package-lock.json is unchanged, and restarts the runner service only at the end. | |
| set -euo pipefail | |
| HOST=${1:?ssh target, e.g. ubuntu@runner-host} | |
| KEY=${2:?ssh private key file} | |
| URL=${3:-} | |
| SERVICE=${RUNNER_SERVICE:-astra-runner} | |
| REV=$(git rev-parse --short=12 HEAD) | |
| git diff --quiet HEAD -- automation tests || { echo "automation/ or tests/ has uncommitted changes: commit first" >&2; exit 1; } | |
| SSH=(ssh -i "$KEY" -o BatchMode=yes "$HOST") | |
| if "${SSH[@]}" "curl -s --max-time 10 http://127.0.0.1:\${RUNNER_PORT:-8899}/healthz" | grep -q '"busy": true'; then | |
| echo "the runner is busy with a test run: try again when it ends" >&2 | |
| exit 2 | |
| fi | |
| PKG=$(mktemp -t astra-runner.XXXXXX.tgz) | |
| trap 'rm -f "$PKG"' EXIT | |
| git archive --format=tar.gz -o "$PKG" HEAD automation tests | |
| scp -q -i "$KEY" -o BatchMode=yes "$PKG" "$HOST:astra-sync.tgz" | |
| "${SSH[@]}" bash -s -- "$REV" "$SERVICE" <<'REMOTE' | |
| set -euo pipefail | |
| REV=$1 SERVICE=$2 | |
| rm -rf ~/astra.new && mkdir ~/astra.new | |
| tar -xzf ~/astra-sync.tgz -C ~/astra.new && rm -f ~/astra-sync.tgz | |
| echo "$REV" > ~/astra.new/VERSION | |
| cd ~/astra.new/automation | |
| if [ -d ~/astra/automation/node_modules ] && cmp -s package-lock.json ~/astra/automation/package-lock.json; then | |
| cp -a ~/astra/automation/node_modules . | |
| else | |
| npm ci --no-audit --no-fund --loglevel=error | |
| fi | |
| npx playwright install chromium >/dev/null | |
| # the install took minutes: a test run may have started meanwhile, and the restart would kill its browsers | |
| if curl -s --max-time 10 http://127.0.0.1:${RUNNER_PORT:-8899}/healthz | grep -q '"busy": true'; then | |
| echo "a test run started on the runner during the install: nothing switched; run this again when it ends" >&2 | |
| rm -rf ~/astra.new | |
| exit 2 | |
| fi | |
| rm -rf ~/astra.prev | |
| [ -d ~/astra ] && mv ~/astra ~/astra.prev | |
| mv ~/astra.new ~/astra | |
| sudo systemctl restart "$SERVICE" | |
| sleep 3 | |
| H=$(curl -s http://127.0.0.1:${RUNNER_PORT:-8899}/healthz); echo "$H" | |
| # the service must run the copy just installed (its AUTOMATION_DIR is ~/astra/automation) and have its scenario files | |
| echo "$H" | grep -q "\"version\": \"$REV\"" && echo "$H" | grep -q '"cases": true' || { echo "the runner does not report $REV with its scenario files: check the service's AUTOMATION_DIR" >&2; exit 3; } | |
| REMOTE | |
| if [ -n "$URL" ]; then | |
| echo "from outside: $(curl -s --max-time 20 "$URL/healthz")" | |
| fi | |
| echo "runner now on $REV" | |