Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: tests

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
shell-tests:
name: shell tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Ensure jq is available
run: |
if command -v jq >/dev/null 2>&1; then
exit 0
fi
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install -y jq
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install jq
else
echo "Unsupported runner OS for jq install: $RUNNER_OS" >&2
exit 1
fi

- name: Show tool versions
run: |
bash --version
jq --version
python3 --version

- name: Run eval-harness shell tests
run: |
set -euo pipefail
for t in scripts/eval/tests/*.sh; do
echo "== $(basename "$t")"
bash "$t"
done
5 changes: 4 additions & 1 deletion scripts/eval/hooks/opencode-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ main() {
if ! require_opencode_version; then exit 0; fi

local changed_skills=()
mapfile -t changed_skills < <(discover_changed_skills)
local changed_skill
while IFS= read -r changed_skill; do
[[ -n "$changed_skill" ]] && changed_skills+=("$changed_skill")
done < <(discover_changed_skills)
if [[ ${#changed_skills[@]} -eq 0 ]]; then
echo "[opencode-stop] no skill files changed; nothing to evaluate" >&2
exit 0
Expand Down
50 changes: 47 additions & 3 deletions scripts/eval/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,47 @@

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ -f "$SCRIPT_DIR/../lib/portable.sh" ]]; then
# shellcheck source=../lib/portable.sh
source "$SCRIPT_DIR/../lib/portable.sh"
else
run_with_timeout() {
local max_seconds="$1"
shift
if command -v timeout >/dev/null 2>&1; then
timeout "$max_seconds" "$@"
return $?
fi
if command -v gtimeout >/dev/null 2>&1; then
gtimeout "$max_seconds" "$@"
return $?
fi
if command -v python3 >/dev/null 2>&1; then
python3 - "$max_seconds" "$@" <<'PY'
import subprocess
import sys

timeout = float(sys.argv[1])
cmd = sys.argv[2:]
if not cmd:
sys.exit(2)
try:
completed = subprocess.run(cmd, timeout=timeout)
sys.exit(completed.returncode)
except subprocess.TimeoutExpired:
sys.exit(124)
except FileNotFoundError:
print(f"[eval-harness] command not found: {cmd[0]}", file=sys.stderr)
sys.exit(127)
PY
return $?
fi
echo "[eval-harness] missing timeout tool: install timeout, gtimeout, or python3" >&2
return 127
}
fi

REMOTE="${1:-origin}"
URL="${2:-}"

Expand All @@ -23,7 +64,8 @@ while read -r local_ref local_sha remote_ref remote_sha; do
while IFS= read -r f; do
case "$f" in
.opencode/skills/*/*|*/.opencode/skills/*/*)
skill="$(echo "$f" | grep -oP '\.opencode/skills/\K[^/]+' | head -1 || true)"
skill_path="${f#*.opencode/skills/}"
skill="${skill_path%%/*}"
[[ -n "$skill" ]] && affected_skills+=("$skill")
;;
esac
Expand All @@ -41,8 +83,10 @@ echo "$unique_skills" | sed 's/^/ - /' >&2
EVAL_HARNESS_BIN="${EVAL_HARNESS_BIN:-eval-harness}"
exit_code=0
for skill in $unique_skills; do
if ! timeout 60 "$EVAL_HARNESS_BIN" --skill="$skill" --trigger=pre-push; then
exit_code=$?
rc=0
run_with_timeout 60 "$EVAL_HARNESS_BIN" --skill="$skill" --trigger=pre-push || rc=$?
if [[ "$rc" -ne 0 ]]; then
exit_code="$rc"
fi
done

Expand Down
Loading