fix: use pip cache instead of --no-cache-dir
Run Tests / Backend Tests (push) Failing after 13m48s
Run Tests / Test Summary (push) Has been cancelled
Run Tests / Frontend Tests (push) Has been cancelled

- 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
This commit is contained in:
Gan, Jimmy
2026-04-06 22:23:38 +08:00
parent 2991250adf
commit 95ba45f4d4
+8 -5
View File
@@ -30,8 +30,11 @@ jobs:
run: | run: |
CACHE_KEY="python-$(cat dashboard/backend/requirements.txt dashboard/backend/requirements-dev.txt | md5sum | cut -d' ' -f1)" CACHE_KEY="python-$(cat dashboard/backend/requirements.txt dashboard/backend/requirements-dev.txt | md5sum | cut -d' ' -f1)"
CACHE_DIR="/tmp/pytest-cache/$CACHE_KEY" CACHE_DIR="/tmp/pytest-cache/$CACHE_KEY"
PIP_CACHE_DIR="/tmp/pip-cache"
echo "CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV echo "CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
echo "CACHE_KEY=$CACHE_KEY" >> $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 if [ -d "$CACHE_DIR" ]; then
echo "Cache hit for $CACHE_KEY" echo "Cache hit for $CACHE_KEY"
echo "cache-hit=true" >> $GITHUB_OUTPUT echo "cache-hit=true" >> $GITHUB_OUTPUT
@@ -45,17 +48,17 @@ jobs:
run: | run: |
cd dashboard/backend cd dashboard/backend
if [ "${{ steps.cache-python.outputs.cache-hit }}" = "true" ]; then 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 . cp -a $CACHE_DIR/venv .
else else
echo "Installing fresh dependencies..." echo "Installing fresh dependencies..."
python3 -m venv venv python3 -m venv venv
. venv/bin/activate . venv/bin/activate
pip install --no-cache-dir -r requirements.txt pip install --cache-dir=$PIP_CACHE_DIR -r requirements.txt
pip install --no-cache-dir -r requirements-dev.txt pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt
pip install --no-cache-dir pytest-timeout pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout
# Save to cache # Save to cache
echo "Saving to cache $CACHE_KEY..." echo "Saving venv to cache $CACHE_KEY..."
cp -a venv $CACHE_DIR/ cp -a venv $CACHE_DIR/
fi fi