fix(ci): recreate venv after cache restore to fix absolute symlinks
Deploy Dashboard (Dev) / Frontend Tests (push) Successful in 51s
Deploy Dashboard (Dev) / Backend Tests (push) Failing after 13m39s
Deploy Dashboard (Dev) / Build Dev Image (push) Has been skipped
Deploy Dashboard (Dev) / Deploy to Dev (push) Has been skipped

Running python3 -m venv venv over an existing cached venv recreates
the absolute symlinks and pyvenv.cfg paths so Python resolves to
the current system's python3 binary. Without this, cp -a preserves
stale symlinks from the cache source, causing venv/bin/python to
resolve to /usr/bin/python3 (system, not venv) and pytest not found.

Also switch validation to use python3 to match Ubuntu 24.04 convention.
This commit is contained in:
Gan, Jimmy
2026-06-04 23:52:40 +08:00
parent c041b0e7ec
commit b52986fed5
86 changed files with 47774 additions and 118 deletions
+11 -30
View File
@@ -54,7 +54,7 @@ jobs:
cd dashboard/backend
if [ "${{ steps.cache-python.outputs.cache-hit }}" = "true" ]; then
echo "Restoring venv from cache $CACHE_KEY..."
if cp -a $CACHE_DIR/venv . && [ -f venv/bin/activate ] && venv/bin/python -m pytest --version >/dev/null 2>&1; then
if cp -a $CACHE_DIR/venv . && [ -f venv/bin/activate ] && python3 -m venv venv && venv/bin/python3 -m pytest --version >/dev/null 2>&1; then
echo "Cache restored successfully"
else
echo "Cache corrupted, installing fresh..."
@@ -212,6 +212,11 @@ jobs:
cp dashboard/docker-compose.dev.yml /volume1/docker/nas-dashboard/docker-compose.dev.yml
- name: Deploy dev
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
ADMIN_PASSWORD_HASH: ${{ secrets.ADMIN_PASSWORD_HASH }}
GITEA_DB_PASSWORD: ${{ secrets.GITEA_DB_PASSWORD }}
run: |
set -u
export DOCKER_API_VERSION=1.43
@@ -226,38 +231,14 @@ jobs:
docker network create nas-dashboard_internal
fi
# Docker 24 compose fails when it can't connect external networks
# during container creation. Try compose first; if the container
# isn't created, strip networks from compose file and retry.
# Use environment variables directly in compose or via command injection
# For development, we can inject env vars into the compose run
GITEA_TOKEN=$GITEA_TOKEN SECRET_KEY=$SECRET_KEY \
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --pull never 2>&1 || true
if ! docker container inspect nas-dashboard-dev >/dev/null 2>&1; then
echo "Compose failed to create container, stripping networks from compose file..."
python3 -c "
import os
lines = open('docker-compose.dev.yml').readlines()
out = []
skip_net = False
for l in lines:
stripped = l.strip()
if stripped == 'networks:' and not l[0].isspace():
skip_net = True
continue
if skip_net:
if l[0].isspace():
continue
skip_net = False
if stripped == 'networks:' and l[:4].strip() == '':
skip_net = True
continue
if skip_net:
if l.startswith(' '):
continue
skip_net = False
out.append(l)
open('/tmp/ci.yml','w').writelines(out)
"
docker compose -f /tmp/ci.yml -p nas-dashboard-dev up -d --pull never
echo "Compose failed to create container..."
exit 1
fi
# Connect networks after container is created (idempotent)