check-resources.sh 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env bash
  2. # Offline resource checks — runs in PR CI, may block.
  3. #
  4. # Exercises the skill verifier/scanner scripts in their OFFLINE/structural mode
  5. # (no network) and asserts basic protocol compliance (SKILL-RESOURCE-PROTOCOL.md):
  6. # every shipped verifier responds to --help with exit 0 and passes its own
  7. # offline self-check against the skill's current content.
  8. #
  9. # The network-dependent --live drift checks run in the scheduled freshness
  10. # workflow, never here — a rate-limit must never block an unrelated PR (§7).
  11. #
  12. # Exit: 0 all checks pass, 1 a check failed.
  13. set -uo pipefail
  14. ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  15. cd "$ROOT" || exit 1
  16. # Pick a working python (Windows Store python3 stub exits 49 on --version).
  17. PY="python3"
  18. if ! "$PY" --version >/dev/null 2>&1; then PY="python"; fi
  19. fail=0
  20. pass() { echo " ok $*"; }
  21. bad() { echo " FAIL $*"; fail=1; }
  22. run() { # description, expected-exit, command...
  23. local desc="$1" want="$2"; shift 2
  24. "$@" >/dev/null 2>&1; local got=$?
  25. if [ "$got" -eq "$want" ]; then pass "$desc (exit $got)"; else bad "$desc (want $want, got $got)"; fi
  26. }
  27. echo "== claude-api-ops: model-table verifier"
  28. run "model-table --offline consistent" 0 "$PY" skills/claude-api-ops/scripts/check-model-table.py --offline
  29. run "model-table --help" 0 "$PY" skills/claude-api-ops/scripts/check-model-table.py --help
  30. echo "== terraform-ops: action-ref verifier"
  31. run "action-refs --offline well-formed" 0 bash skills/terraform-ops/scripts/check-action-refs.sh --offline
  32. run "action-refs --help" 0 bash skills/terraform-ops/scripts/check-action-refs.sh --help
  33. echo "== claude-code-ops: hooks.json validator"
  34. run "hooks-lint clean on repo hooks.json" 0 "$PY" skills/claude-code-ops/scripts/validate-hooks-json.py hooks/hooks.json
  35. run "hooks-lint --help" 0 "$PY" skills/claude-code-ops/scripts/validate-hooks-json.py --help
  36. echo "== playwright-ops: flake-triage"
  37. run "flake-triage --help" 0 "$PY" skills/playwright-ops/scripts/triage-flakes.py --help
  38. echo "== ffmpeg-ops: command/resource verifier"
  39. run "ffmpeg-ops --offline consistent" 0 bash skills/ffmpeg-ops/scripts/verify-commands.sh --offline
  40. run "ffmpeg-ops --help" 0 bash skills/ffmpeg-ops/scripts/verify-commands.sh --help
  41. echo "== ytdlp-ops: version/staleness verifier"
  42. run "ytdlp-ops --offline consistent" 0 bash skills/ytdlp-ops/scripts/check-ytdlp-version.sh --offline
  43. run "ytdlp-ops --help" 0 bash skills/ytdlp-ops/scripts/check-ytdlp-version.sh --help
  44. echo "== protocol: every new verifier is executable + compiles"
  45. for s in skills/claude-api-ops/scripts/check-model-table.py \
  46. skills/claude-code-ops/scripts/validate-hooks-json.py \
  47. skills/playwright-ops/scripts/triage-flakes.py; do
  48. "$PY" -m py_compile "$s" 2>/dev/null && pass "py_compile $(basename "$s")" || bad "py_compile $(basename "$s")"
  49. done
  50. bash -n skills/terraform-ops/scripts/check-action-refs.sh 2>/dev/null \
  51. && pass "bash -n check-action-refs.sh" || bad "bash -n check-action-refs.sh"
  52. bash -n skills/ffmpeg-ops/scripts/verify-commands.sh 2>/dev/null \
  53. && pass "bash -n verify-commands.sh" || bad "bash -n verify-commands.sh"
  54. bash -n skills/ytdlp-ops/scripts/check-ytdlp-version.sh 2>/dev/null \
  55. && pass "bash -n check-ytdlp-version.sh" || bad "bash -n check-ytdlp-version.sh"
  56. echo
  57. if [ "$fail" -eq 0 ]; then echo "resource checks: clean"; exit 0; fi
  58. echo "resource checks: failures above"; exit 1