.PHONY: test precommit slow_tests test_experimental claude clean-ai

# Transient infrastructure errors that are worth retrying, matched against "<ExceptionType>: <message>":
#  - OSError, Timeout, HTTPError 502/504: Hub flakiness
#  - OutOfMemoryError, STATUS_ALLOC_FAILED: GPU memory pressure from the parallel workers
rerun_errors := (OSError|Timeout|HTTPError.*502|HTTPError.*504|OutOfMemoryError|STATUS_ALLOC_FAILED)

test:
	pytest -n auto -m "not slow and not low_priority" -s -v --reruns 5 --reruns-delay 1 --only-rerun '$(rerun_errors)' tests

precommit:
	python scripts/add_copyrights.py
	pre-commit run --all-files

slow_tests:
	pytest -m "slow" tests/ $(PYTEST_ARGS)

test_experimental:
	pytest -n auto -s -v tests/experimental

claude:
	mkdir -p .claude
	rm -rf .claude/skills
	ln -snf ../.agents/skills .claude/skills

# The `.agents/skills` line removes a leftover symlink from the old `make codex` setup; the tracked
# directory is left alone.
clean-ai:
	[ -L .agents/skills ] && rm .agents/skills || true
	rm -rf .claude/skills
