feat: terminal fullscreen, asyncpg fix, CI improvements #59
@@ -11,9 +11,153 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
backend-tests:
|
||||||
|
name: Backend Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
SECRET_KEY: test-secret-key-for-ci-environment-32chars-minimum
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
run: |
|
||||||
|
python3 --version
|
||||||
|
pip3 --version
|
||||||
|
|
||||||
|
- name: Cache Python dependencies
|
||||||
|
id: cache-python
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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 ]; then
|
||||||
|
echo "Cache restored successfully"
|
||||||
|
else
|
||||||
|
echo "Cache corrupted, installing fresh..."
|
||||||
|
rm -rf venv
|
||||||
|
python3 -m venv venv
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements.txt || pip install -r requirements.txt
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt || pip install -r requirements-dev.txt
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Installing fresh dependencies..."
|
||||||
|
python3 -m venv venv
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements.txt || pip install -r requirements.txt
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt || pip install -r requirements-dev.txt
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
||||||
|
echo "Saving venv to cache $CACHE_KEY..."
|
||||||
|
cp -a venv $CACHE_DIR/ || echo "Warning: cache save failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Run tests with coverage
|
||||||
|
run: |
|
||||||
|
cd dashboard/backend
|
||||||
|
. venv/bin/activate
|
||||||
|
pytest tests/ -v --timeout=60 \
|
||||||
|
--cov=. --cov-report=xml --cov-report=term \
|
||||||
|
--junit-xml=test-results.xml \
|
||||||
|
--cov-fail-under=49
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "❌ Backend tests failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✅ Backend tests passed"
|
||||||
|
|
||||||
|
frontend-tests:
|
||||||
|
name: Frontend Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
run: |
|
||||||
|
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
|
||||||
|
echo "CACHE_KEY=$CACHE_KEY" >> $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
|
||||||
|
if [ "${{ steps.cache-node.outputs.cache-hit }}" = "true" ]; then
|
||||||
|
echo "Restoring from cache $CACHE_KEY..."
|
||||||
|
if cp -a $CACHE_DIR/node_modules . && [ -d node_modules ]; then
|
||||||
|
echo "Cache restored successfully"
|
||||||
|
else
|
||||||
|
echo "Cache corrupted, installing fresh..."
|
||||||
|
rm -rf node_modules
|
||||||
|
npm ci
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Installing fresh dependencies..."
|
||||||
|
npm ci
|
||||||
|
echo "Saving to cache $CACHE_KEY..."
|
||||||
|
cp -a node_modules $CACHE_DIR/ || echo "Warning: cache save failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: "--max-old-space-size=2048"
|
||||||
|
run: |
|
||||||
|
cd dashboard/frontend
|
||||||
|
npm run test:coverage -- --reporter=verbose --run --pool=forks --poolOptions.forks.maxForks=2
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "❌ Frontend tests failed!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✅ Frontend tests passed"
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Production
|
name: Deploy to Production
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: [backend-tests, frontend-tests]
|
||||||
container:
|
container:
|
||||||
volumes:
|
volumes:
|
||||||
- /var/packages/ContainerManager/target/usr/bin/docker:/usr/bin/docker
|
- /var/packages/ContainerManager/target/usr/bin/docker:/usr/bin/docker
|
||||||
|
|||||||
+29
-18
@@ -1,17 +1,12 @@
|
|||||||
name: Run Tests
|
name: Run Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- 'dashboard/**'
|
||||||
|
- '.gitea/workflows/test.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
# push:
|
|
||||||
# branches: [main]
|
|
||||||
# paths:
|
|
||||||
# - 'dashboard/**'
|
|
||||||
# - '.gitea/workflows/test.yml'
|
|
||||||
# pull_request:
|
|
||||||
# branches: [main]
|
|
||||||
# paths:
|
|
||||||
# - 'dashboard/**'
|
|
||||||
# - '.gitea/workflows/test.yml'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
backend-tests:
|
backend-tests:
|
||||||
@@ -55,23 +50,33 @@ jobs:
|
|||||||
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 venv from cache $CACHE_KEY..."
|
echo "Restoring venv from cache $CACHE_KEY..."
|
||||||
cp -a $CACHE_DIR/venv .
|
if cp -a $CACHE_DIR/venv . && [ -f venv/bin/activate ]; then
|
||||||
|
echo "Cache restored successfully"
|
||||||
|
else
|
||||||
|
echo "Cache corrupted, installing fresh..."
|
||||||
|
rm -rf venv
|
||||||
|
python3 -m venv venv
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements.txt || pip install -r requirements.txt
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt || pip install -r requirements-dev.txt
|
||||||
|
pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
||||||
|
fi
|
||||||
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 --cache-dir=$PIP_CACHE_DIR -r requirements.txt
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements.txt || pip install -r requirements.txt
|
||||||
pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt
|
pip install --cache-dir=$PIP_CACHE_DIR -r requirements-dev.txt || pip install -r requirements-dev.txt
|
||||||
pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov
|
pip install --cache-dir=$PIP_CACHE_DIR pytest-timeout pytest-cov || pip install pytest-timeout pytest-cov
|
||||||
echo "Saving venv to cache $CACHE_KEY..."
|
echo "Saving venv to cache $CACHE_KEY..."
|
||||||
cp -a venv $CACHE_DIR/
|
cp -a venv $CACHE_DIR/ || echo "Warning: cache save failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: |
|
run: |
|
||||||
cd dashboard/backend
|
cd dashboard/backend
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
pytest tests/ -v --timeout=30 \
|
pytest tests/ -v --timeout=60 \
|
||||||
--cov=. --cov-report=xml --cov-report=term \
|
--cov=. --cov-report=xml --cov-report=term \
|
||||||
--junit-xml=test-results.xml \
|
--junit-xml=test-results.xml \
|
||||||
--cov-fail-under=49
|
--cov-fail-under=49
|
||||||
@@ -138,12 +143,18 @@ jobs:
|
|||||||
cd dashboard/frontend
|
cd dashboard/frontend
|
||||||
if [ "${{ steps.cache-node.outputs.cache-hit }}" = "true" ]; then
|
if [ "${{ steps.cache-node.outputs.cache-hit }}" = "true" ]; then
|
||||||
echo "Restoring from cache $CACHE_KEY..."
|
echo "Restoring from cache $CACHE_KEY..."
|
||||||
cp -a $CACHE_DIR/node_modules .
|
if cp -a $CACHE_DIR/node_modules . && [ -d node_modules ]; then
|
||||||
|
echo "Cache restored successfully"
|
||||||
|
else
|
||||||
|
echo "Cache corrupted, installing fresh..."
|
||||||
|
rm -rf node_modules
|
||||||
|
npm ci
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Installing fresh dependencies..."
|
echo "Installing fresh dependencies..."
|
||||||
npm ci
|
npm ci
|
||||||
echo "Saving to cache $CACHE_KEY..."
|
echo "Saving to cache $CACHE_KEY..."
|
||||||
cp -a node_modules $CACHE_DIR/
|
cp -a node_modules $CACHE_DIR/ || echo "Warning: cache save failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|||||||
Reference in New Issue
Block a user