Cotton code
34 lines · 1.4 KB · ShellRaw
#!/usr/bin/env bash# Has main moved since this Swift job last went green? (swift-main.yml)##   bash scripts/ci/swift-moved.sh check <job> <event>   writes run=true|false to $GITHUB_OUTPUT#   bash scripts/ci/swift-moved.sh record <job>          after a green pass: this commit is proved## A scheduled run skips a commit its job already proved, as rust-slow does with# its marker; a dispatch always runs. The marker lives on the Mac that ran it# (~/.cache/cottondb/swift-main/<job>), so a second Mac re-proves once.set -euo pipefailverb="${1:?usage: swift-moved.sh check <job> <event> | record <job>}"job="${2:?name the job}"marker="${SWIFT_MOVED_DIR:-$HOME/.cache/cottondb/swift-main}/$job"head="$(git rev-parse HEAD)"case "$verb" in  check)    event="${3:?name the event}"    proved=""    [ -f "$marker" ] && proved="$(cat "$marker" 2>/dev/null || true)"    if [ "$event" = schedule ] && [ "$proved" = "$head" ]; then      echo "run=false" >> "$GITHUB_OUTPUT"      echo "$job: main is still at $head, which its last green pass proved — nothing to re-prove."    else      echo "run=true" >> "$GITHUB_OUTPUT"      echo "$job: $event at $head; the last green pass proved '${proved:-nothing}' — running."    fi    ;;  record)    mkdir -p "$(dirname "$marker")"    echo "$head" > "$marker"    echo "$job: proved $head"    ;;  *) echo "swift-moved: unknown verb $verb (check | record)" >&2; exit 2 ;;esac