From 95ba45f4d494bd28678384bfc3d7b3d5d4ae5d86 Mon Sep 17 00:00:00 2001 From: "Gan, Jimmy" Date: Mon, 6 Apr 2026 22:23:38 +0800 Subject: [PATCH] fix: use pip cache instead of --no-cache-dir - Remove --no-cache-dir flag that was forcing slow downloads - Use pip's own cache directory at /tmp/pip-cache - This allows pip to cache downloaded packages between runs - Venv cache still works for when requirements don't change - Should significantly speed up dependency installation --- .gitea/workflows/test.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index d8468bf..959709c 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -30,8 +30,11 @@ jobs: run: | CACHE_KEY="python-$(cat dashboard/backend/requirements.txt dashboard/backend/requirements-dev.txt | md5sum | cut -d' ' -f1)" CACHE_DIR="/tmp/pytest-cache/$CACHE_KEY" + PIP_CACHE_DIR="/tmp/pip-cache" echo "CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_ENV + echo "PIP_CACHE_DIR=$PIP_CACHE_DIR" >> $GITHUB_ENV + mkdir -p "$PIP_CACHE_DIR" if [ -d "$CACHE_DIR" ]; then echo "Cache hit for $CACHE_KEY" echo "cache-hit=true" >> $GITHUB_OUTPUT @@ -45,17 +48,17 @@ jobs: run: | cd dashboard/backend if [ "${{ steps.cache-python.outputs.cache-hit }}" = "true" ]; then - echo "Restoring from cache $CACHE_KEY..." + echo "Restoring venv from cache $CACHE_KEY..." cp -a $CACHE_DIR/venv . else echo "Installing fresh dependencies..." python3 -m venv venv . venv/bin/activate - pip install --no-cache-dir -r requirements.txt - pip install --no-cache-dir -r requirements-dev.txt - pip install --no-cache-dir pytest-timeout + pip install --cache-dir=$PIP_CACHE_DIR -r requirements.txt + pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt + pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout # Save to cache - echo "Saving to cache $CACHE_KEY..." + echo "Saving venv to cache $CACHE_KEY..." cp -a venv $CACHE_DIR/ fi