ci: add pytest --maxfail=1 and simple pip/venv cache at /cache if available
Some checks failed
CI / Lint, test, and build (push) Failing after 33s
Some checks failed
CI / Lint, test, and build (push) Failing after 33s
This commit is contained in:
parent
979fbb0e64
commit
136b4196ea
1 changed files with 26 additions and 4 deletions
|
@ -65,11 +65,33 @@ jobs:
|
|||
- name: Set up venv and install deps
|
||||
run: |
|
||||
set -euo pipefail
|
||||
python3 -m venv .venv
|
||||
# Prefer persistent cache if runner provides /cache
|
||||
USE_CACHE=0
|
||||
if [ -d /cache ] && [ -w /cache ]; then
|
||||
export PIP_CACHE_DIR=/cache/pip
|
||||
mkdir -p "$PIP_CACHE_DIR"
|
||||
REQ_HASH=$(sha256sum requirements.txt | awk '{print $1}')
|
||||
PYVER=$(python3 -c 'import sys;print(".".join(map(str, sys.version_info[:2])))')
|
||||
CACHE_VENV="/cache/venv-${REQ_HASH}-py${PYVER}"
|
||||
if [ -d "$CACHE_VENV" ]; then
|
||||
echo "Using cached virtualenv: $CACHE_VENV"
|
||||
ln -s "$CACHE_VENV" .venv
|
||||
USE_CACHE=1
|
||||
else
|
||||
echo "Creating cached virtualenv: $CACHE_VENV"
|
||||
python3 -m venv "$CACHE_VENV"
|
||||
ln -s "$CACHE_VENV" .venv
|
||||
fi
|
||||
fi
|
||||
|
||||
. .venv/bin/activate
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install pytest
|
||||
if [ "$USE_CACHE" = "1" ]; then
|
||||
# Ensure required packages are present; pip will use cache
|
||||
pip install -r requirements.txt pytest || pip install -r requirements.txt pytest
|
||||
else
|
||||
pip install -r requirements.txt pytest
|
||||
fi
|
||||
|
||||
- name: Format check (black)
|
||||
run: |
|
||||
|
@ -84,7 +106,7 @@ jobs:
|
|||
- name: Run tests (pytest)
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
pytest -q
|
||||
pytest -q --maxfail=1
|
||||
|
||||
- name: Build sample reports (no artifact upload)
|
||||
run: |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue