From ab4f017ba815d5b364403a87f4c41a1e866f8302 Mon Sep 17 00:00:00 2001 From: ngxstat-bot Date: Sat, 16 Aug 2025 05:17:51 -0500 Subject: [PATCH] ci: robust venv creation; verify cached venv has activate and fallback to local --- .forgejo/workflows/ci.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index 2717345..cd7fb36 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -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