Files
AstrBot/scripts/run_pytests_ci.sh
Sha1rholder ab4ddd662d perf(ci): simplify CI and speed it up (#11226)
* CI: Simplify smoke test

* follow-up for standardizing uv setup and skip redundant syncs

* CI: Use uv for project sync workflows

Reference actions by version tag and reduce the sync timeout from 120 to
10 minutes. Drop references to the deleted delivery test and remove
workflow security assertions.
2026-11-18 22:09:02 +08:00

33 lines
898 B
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
mkdir -p ./data/plugins ./data/config ./data/temp
export TESTING="${TESTING:-true}"
# Keep backward compatibility with existing test code that reads ZHIPU_API_KEY.
if [[ -n "${OPENAI_API_KEY:-}" && -z "${ZHIPU_API_KEY:-}" ]]; then
export ZHIPU_API_KEY="$OPENAI_API_KEY"
fi
PYTEST_TARGETS=("${@:-./tests}")
echo "[ci] running tests: ${PYTEST_TARGETS[*]}"
# Some tests may leave non-daemon worker threads alive (e.g. aiosqlite warning path),
# which can block pytest process exit in CI. Run pytest via python and force process exit
# with pytest's return code to avoid hanging workflow jobs.
uv run python - "${PYTEST_TARGETS[@]}" <<'PY'
import os
import sys
import pytest
exit_code = int(pytest.main(sys.argv[1:]))
sys.stdout.flush()
sys.stderr.flush()
os._exit(exit_code)
PY