Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112#!/bin/bashset -euo pipefailcd "$(dirname "$0")/.."source Scripts/remote-sync.shif [[ $# -lt 1 || $# -gt 3 ]]; then printf 'Usage: %s <host> [bench|bench-record|bench-ab|smoothness|idle|soak] [BASE=ref]\n' "$0" >&2 exit 2fihost=$1task=${2:-bench}remote_validate_host "$host"case "$task" in bench|bench-record|bench-ab|smoothness|idle|soak) ;; *) printf 'Unknown bench task: %s\n' "$task" >&2; exit 2 ;; esacif [[ $# -eq 3 && ( $task != bench-ab || $3 != BASE=* ) ]]; then printf 'BASE=ref is only accepted for bench-ab.\n' >&2 exit 2fiwait_value=${BENCH_WAIT:-15m}if [[ ! $wait_value =~ ^([0-9]+)(s|m)?$ ]]; then printf 'BENCH_WAIT must be an integer number of seconds or minutes (for example 15m).\n' >&2 exit 2fiwait_seconds=$((10#${BASH_REMATCH[1]}))[[ ${BASH_REMATCH[2]:-} != m ]] || wait_seconds=$((wait_seconds * 60))base_revision=if [[ $task == bench-ab ]]; then base=${3:-BASE=${BASE:-main}} base_revision=$(git merge-base HEAD "${base#BASE=}")firemote_dir=$(remote_sync "$host")if [[ $task == bench-ab ]]; then bundle=$(mktemp "${TMPDIR:-/tmp}/parcel-bench-history.XXXXXX") trap 'rm -f "$bundle"' EXIT git bundle create "$bundle" HEAD rsync -az "$bundle" "$host:parcel-ci/$remote_dir/measurement-history.bundle"fistamp=$(date -u +%Y%m%dT%H%M%SZ)destination="$PWD/build/remote/$host/$stamp"mkdir -p "$destination"# All inserted values are validated tokens; the script is sent verbatim, not shell-expanded.status=0# shellcheck disable=SC2029ssh "$host" "bash -s -- $remote_dir $task $wait_seconds ${base_revision:-none}" <<'REMOTE' || status=$?set -euo pipefailcd "$HOME/parcel-ci/$1"task=$2wait_seconds=$3base_revision=$4mkdir -p buildstarted=$SECONDSwhile true; do quiet_status=0 Scripts/quiet-check.sh --output build/bench-quiet.json || quiet_status=$? case "$quiet_status" in 0) break ;; 3) if (( SECONDS - started >= wait_seconds )); then printf 'Host did not become quiet before BENCH_WAIT expired.\n' >&2 exit 3 fi remaining=$((wait_seconds - (SECONDS - started))) delay=60 (( remaining >= delay )) || delay=$remaining sleep "$delay" ;; *) printf 'Quiet preflight failed with status %s; refusing measurement.\n' "$quiet_status" >&2; exit "$quiet_status" ;; esacdoneif [[ $task == bench-ab ]]; then git init --quiet git fetch --quiet measurement-history.bundle HEAD:refs/heads/measurement-head git symbolic-ref HEAD refs/heads/measurement-head git reset --mixed --quiet HEAD command=(Scripts/bench-ab.sh "$base_revision")else command=(make "$task")fiPARCEL_BENCH_QUIET="$PWD/build/bench-quiet.json" BENCH_STRICT_QUIET=1 \ caffeinate -i -s nice -n -5 "${command[@]}"REMOTE# Readings and failure artifacts are retrieved even if the task terminates unsuccessfully.# shellcheck disable=SC2029artifacts=$(ssh "$host" "cd ~/parcel-ci/$remote_dir && for path in build/bench-results.json build/bench-quiet.json build/bench-ab build/smoothness build/idle build/soak build/traces; do if [ -e \"\$path\" ]; then printf '%s\\n' \"\$path\"; fi; done")while IFS= read -r artifact; do [[ -n $artifact ]] || continue case "$artifact" in build/bench-results.json|build/bench-quiet.json|build/bench-ab|build/smoothness|build/idle|build/soak|build/traces) ;; *) printf 'Unexpected artifact: %s\n' "$artifact" >&2; exit 2 ;; esac rsync -az "$host:parcel-ci/$remote_dir/$artifact" "$destination/"done <<< "$artifacts"if (( status != 0 )); then printf 'Remote task failed with status %s; artifacts: %s\n' "$status" "$destination" >&2 exit "$status"ficase "$task" in bench|bench-record) required=bench-results.json ;; bench-ab) required=bench-ab/summary.json ;; smoothness) required=smoothness ;; idle) required=idle ;; soak) required=soak ;;esac[[ -e $destination/$required ]] || { printf 'Required remote artifact missing: %s\n' "$required" >&2; exit 2; }if [[ $task == bench-record ]]; then # A fresh remote checkout can only produce this host's deliberate new baseline. # shellcheck disable=SC2029 baselines=$(ssh "$host" "cd ~/parcel-ci/$remote_dir && find Benchmarks/baselines -type f -name '*.json' -newer build/bench-quiet.json -print") [[ -n $baselines ]] || { printf 'No newly recorded remote baseline found.\n' >&2; exit 2; } while IFS= read -r baseline; do [[ $baseline =~ ^Benchmarks/baselines/[A-Za-z0-9,._-]+\.json$ ]] || { printf 'Unexpected baseline path.\n' >&2; exit 2; } rsync -az "$host:parcel-ci/$remote_dir/$baseline" "$baseline" printf 'Retrieved baseline for review (not staged): %s\n' "$baseline" done <<< "$baselines"fiprintf 'Remote artifacts: %s\n' "$destination"