fix: correct test assertions and add dependency caching
- Fix logout test to expect {ok: true} instead of {message: ...}
- Fix logout without auth test (endpoint doesn't require auth)
- Fix password change tests to use current_password instead of old_password
- Fix password change error code expectation (400 instead of 401)
- Add Python venv caching to speed up backend tests
- Add Node modules caching to speed up frontend tests
- Cache is keyed by requirements/package-lock file hashes
This commit is contained in:
@@ -25,14 +25,37 @@ jobs:
|
||||
python3 --version
|
||||
pip3 --version
|
||||
|
||||
- name: Cache Python dependencies
|
||||
id: cache-python
|
||||
run: |
|
||||
CACHE_KEY="python-$(md5sum dashboard/backend/requirements.txt dashboard/backend/requirements-dev.txt | md5sum | cut -d' ' -f1)"
|
||||
CACHE_DIR="/tmp/pytest-cache/$CACHE_KEY"
|
||||
echo "CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
|
||||
if [ -d "$CACHE_DIR" ]; then
|
||||
echo "Cache hit for $CACHE_KEY"
|
||||
echo "cache-hit=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Cache miss for $CACHE_KEY"
|
||||
echo "cache-hit=false" >> $GITHUB_OUTPUT
|
||||
mkdir -p "$CACHE_DIR"
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd dashboard/backend
|
||||
python3 -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-dev.txt
|
||||
pip install pytest-timeout
|
||||
if [ "${{ steps.cache-python.outputs.cache-hit }}" = "true" ]; then
|
||||
echo "Restoring from cache..."
|
||||
cp -r $CACHE_DIR/venv .
|
||||
else
|
||||
echo "Installing fresh dependencies..."
|
||||
python3 -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-dev.txt
|
||||
pip install pytest-timeout
|
||||
# Save to cache
|
||||
cp -r venv $CACHE_DIR/
|
||||
fi
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
@@ -62,12 +85,35 @@ jobs:
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Cache Node dependencies
|
||||
id: cache-node
|
||||
run: |
|
||||
CACHE_KEY="node-$(md5sum dashboard/frontend/package-lock.json | cut -d' ' -f1)"
|
||||
CACHE_DIR="/tmp/npm-cache/$CACHE_KEY"
|
||||
echo "CACHE_DIR=$CACHE_DIR" >> $GITHUB_ENV
|
||||
if [ -d "$CACHE_DIR" ]; then
|
||||
echo "Cache hit for $CACHE_KEY"
|
||||
echo "cache-hit=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Cache miss for $CACHE_KEY"
|
||||
echo "cache-hit=false" >> $GITHUB_OUTPUT
|
||||
mkdir -p "$CACHE_DIR"
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
NODE_OPTIONS: "--max-old-space-size=2048"
|
||||
run: |
|
||||
cd dashboard/frontend
|
||||
npm ci
|
||||
if [ "${{ steps.cache-node.outputs.cache-hit }}" = "true" ]; then
|
||||
echo "Restoring from cache..."
|
||||
cp -r $CACHE_DIR/node_modules .
|
||||
else
|
||||
echo "Installing fresh dependencies..."
|
||||
npm ci
|
||||
# Save to cache
|
||||
cp -r node_modules $CACHE_DIR/
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user