cosmosmesh-privacy-preservi.../test.sh

36 lines
1020 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
echo "[test.sh] Running tests..."
# 1) Prefer pytest if tests exist
if command -v pytest >/dev/null 2>&1 && [ -d "tests" ]; then
echo "[test.sh] Found tests/; running pytest..."
pytest -q
echo "[test.sh] pytest succeeded."
echo "[test.sh] Now building package to validate packaging..."
# Attempt packaging build as part of the CI gate
python3 -m build
echo "[test.sh] Build succeeded."
exit 0
fi
# 2) If pyproject.toml exists, attempt Python build (packaging check)
if [ -f "pyproject.toml" ]; then
echo "[test.sh] Found pyproject.toml; attempting python3 -m build..."
python3 -m build
echo "[test.sh] Build succeeded."
exit 0
fi
# 3) Fallback: try npm-based test if present
if command -v npm >/dev/null 2>&1 && [ -f package.json ]; then
echo "[test.sh] Found package.json; running npm test..."
npm ci && npm test --silent
echo "[test.sh] npm test succeeded."
exit 0
fi
echo "[test.sh] No tests or build found. Exiting with failure." >&2
exit 1