8431920d26
- Backend: pytest with unit tests (auth, rbac, config) and integration tests (auth flow, docker, files) - Frontend: vitest with unit tests (api client) and component tests (login) - CI: Gitea Actions workflow for automated testing with coverage reports - Documentation: TESTING.md guide with setup, usage, and best practices - Coverage goals: 80%+ backend, 70%+ frontend
116 lines
3.0 KiB
YAML
116 lines
3.0 KiB
YAML
name: Run Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
backend-tests:
|
|
name: Backend Tests
|
|
runs-on: nas-runner
|
|
defaults:
|
|
run:
|
|
working-directory: dashboard/backend
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -r requirements.txt
|
|
pip install -r requirements-dev.txt
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
pytest tests/unit/ -v --cov=. --cov-report=term --cov-report=html --cov-report=xml
|
|
continue-on-error: true
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
pytest tests/integration/ -v --cov=. --cov-append --cov-report=term --cov-report=html --cov-report=xml
|
|
continue-on-error: true
|
|
|
|
- name: Upload backend coverage report
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: backend-coverage
|
|
path: dashboard/backend/htmlcov/
|
|
|
|
- name: Upload backend coverage XML
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: backend-coverage-xml
|
|
path: dashboard/backend/coverage.xml
|
|
|
|
frontend-tests:
|
|
name: Frontend Tests
|
|
runs-on: nas-runner
|
|
defaults:
|
|
run:
|
|
working-directory: dashboard/frontend
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: dashboard/frontend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run tests with coverage
|
|
run: npm run test:coverage
|
|
continue-on-error: true
|
|
|
|
- name: Upload frontend coverage report
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: frontend-coverage
|
|
path: dashboard/frontend/coverage/
|
|
|
|
test-summary:
|
|
name: Test Summary
|
|
runs-on: nas-runner
|
|
needs: [backend-tests, frontend-tests]
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Download backend coverage
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: backend-coverage-xml
|
|
path: ./backend-coverage
|
|
continue-on-error: true
|
|
|
|
- name: Download frontend coverage
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: frontend-coverage
|
|
path: ./frontend-coverage
|
|
continue-on-error: true
|
|
|
|
- name: Test Summary
|
|
run: |
|
|
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "✅ Backend tests completed" >> $GITHUB_STEP_SUMMARY
|
|
echo "✅ Frontend tests completed" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "Coverage reports uploaded as artifacts." >> $GITHUB_STEP_SUMMARY
|