ci: robust venv creation; verify cached venv has activate and fallback to local
Some checks failed
CI / Lint, test, and build (push) Failing after 45s
Some checks failed
CI / Lint, test, and build (push) Failing after 45s
This commit is contained in:
parent
136b4196ea
commit
ab4f017ba8
1 changed files with 16 additions and 7 deletions
|
@ -73,15 +73,24 @@ jobs:
|
|||
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"
|
||||
if [ ! -f "$CACHE_VENV/bin/activate" ]; then
|
||||
echo "Preparing cached virtualenv: $CACHE_VENV"
|
||||
rm -rf "$CACHE_VENV" || true
|
||||
python3 -m venv "$CACHE_VENV"
|
||||
ln -s "$CACHE_VENV" .venv
|
||||
fi
|
||||
ln -sfn "$CACHE_VENV" .venv
|
||||
USE_CACHE=1
|
||||
else
|
||||
# Fallback to local venv
|
||||
python3 -m venv .venv
|
||||
fi
|
||||
|
||||
# If the link didn't produce an activate file, fallback to local venv
|
||||
if [ ! -f .venv/bin/activate ]; then
|
||||
echo "Cached venv missing; creating local .venv"
|
||||
rm -f .venv
|
||||
python3 -m venv .venv
|
||||
USE_CACHE=0
|
||||
fi
|
||||
|
||||
. .venv/bin/activate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue