scripts/run.sh
scripts/run.shBrowse 4 files
581 tokens
1,899 bytes
Token encoding: o200k_base
Snapshot 1d17ca4
← Back to SKILL.md
1#!/usr/bin/env bash2set -euo pipefail3# Job control gives each background make invocation its own process group.4set -m5 6SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"7if command -v git >/dev/null 2>&1; then8 REPO_ROOT="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel 2>/dev/null || true)"9fi10REPO_ROOT="${REPO_ROOT:-$(cd "${SCRIPT_DIR}/../../../.." && pwd)}"11cd "${REPO_ROOT}"12 13STEP_PID=""14EXIT_STATUS=015 16stop_step() {17 if [ -z "${STEP_PID}" ]; then18 return19 fi20 # Descendants can outlive make, so always address its process group.21 if kill -TERM -- "-${STEP_PID}" 2>/dev/null; then22 sleep 123 kill -KILL -- "-${STEP_PID}" 2>/dev/null || true24 fi25 wait "${STEP_PID}" 2>/dev/null || true26 STEP_PID=""27}28 29cleanup() {30 local status=$?31 if [ "${EXIT_STATUS}" -ne 0 ]; then32 status=${EXIT_STATUS}33 fi34 trap - EXIT35 trap '' INT TERM36 stop_step37 exit "${status}"38}39 40cancel() {41 if [ "${EXIT_STATUS}" -eq 0 ]; then42 EXIT_STATUS=$143 fi44 # Defer only until a just-launched PID has been registered.45 if [ -n "${STEP_PID}" ]; then46 exit "${EXIT_STATUS}"47 fi48}49 50trap cleanup EXIT51trap 'cancel 130' INT52trap 'cancel 143' TERM53 54for step in format lint typecheck tests; do55 if [ "${EXIT_STATUS}" -ne 0 ]; then56 exit "${EXIT_STATUS}"57 fi58 echo "Running make ${step}..."59 started=${SECONDS}60 make "${step}" &61 STEP_PID=$!62 if [ "${EXIT_STATUS}" -eq 0 ]; then63 wait "${STEP_PID}" || {64 status=$?65 if [ "${EXIT_STATUS}" -eq 0 ]; then66 EXIT_STATUS=${status}67 fi68 }69 fi70 if [ "${EXIT_STATUS}" -ne 0 ]; then71 echo "code-change-verification: make ${step} failed with exit code ${EXIT_STATUS}." >&272 exit "${EXIT_STATUS}"73 fi74 stop_step75 if [ "${EXIT_STATUS}" -ne 0 ]; then76 exit "${EXIT_STATUS}"77 fi78 echo "make ${step} passed in $((SECONDS - started))s."79done80 81echo "code-change-verification: all commands passed."82