forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·45 lines (40 loc) · 1.66 KB
/
Copy pathrun-tests.sh
File metadata and controls
executable file
·45 lines (40 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Deterministic dev-harness unit-test lane (checks-manifest: dev-harness-unit-tests).
#
# Prefers an interpreter that ALREADY has pytest + python-dotenv + Google ADC + PostHog (the
# repo's backend venv (POSIX or Windows layout), then the ambient python3) so the check needs no
# uv cache, network, or ~/.cache write — keeping `make preflight` green in restricted
# local/agent environments. Only a truly bare environment falls back to uv,
# and even then the cache is redirected to a writable temp dir. Real pytest
# failures still fail the lane in every path.
set -euo pipefail
cd "$(dirname "$0")/../.."
run_pytest() {
exec "$@" -m pytest scripts/dev-harness/tests -q
}
for py in \
backend/.venv/bin/python \
backend/.venv/Scripts/python.exe \
backend/venv/bin/python \
backend/venv/Scripts/python.exe \
python3; do
if [ -x "$py" ] || command -v "$py" >/dev/null 2>&1; then
if "$py" -c 'import pytest, dotenv, google.auth, posthog, requests' >/dev/null 2>&1; then
run_pytest "$py"
fi
fi
done
if command -v uv >/dev/null 2>&1; then
# Redirect the cache off the default ~/.cache/uv, which is not always writable
# in sandboxed preflight environments; a temp dir always is.
export UV_CACHE_DIR="${UV_CACHE_DIR:-${TMPDIR:-/tmp}/omi-dev-harness-uv-cache}"
exec uv run --no-project \
--with 'pytest==8.4.1' \
--with 'python-dotenv==1.1.0' \
--with 'google-auth==2.32.0' \
--with 'posthog==3.5.2' \
--with 'requests~=2.33.0' \
python -m pytest scripts/dev-harness/tests -q
fi
echo "dev-harness tests require pytest + python-dotenv + Google ADC + PostHog via a backend venv, python3, or uv; none available" >&2
exit 1