Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
127 lines
3.3 KiB
YAML
127 lines
3.3 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
jobs:
|
|
backend-tests:
|
|
name: Backend Tests (Python)
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ['3.10', '3.11', '3.12']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r app/requirements.txt
|
|
pip install pytest pytest-asyncio pytest-cov httpx respx freezegun pytest-mock
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
pytest tests/backend -v --tb=short -m "unit" --cov=app --cov-report=xml --cov-report=term-missing
|
|
env:
|
|
DATABASE_URL: "sqlite+aiosqlite:///:memory:"
|
|
API_KEY: "test-api-key-12345"
|
|
JWT_SECRET_KEY: "test-jwt-secret-key"
|
|
NTFY_ENABLED: "false"
|
|
ANSIBLE_DIR: "."
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
if: matrix.python-version == '3.11'
|
|
with:
|
|
files: ./coverage.xml
|
|
flags: backend
|
|
name: backend-coverage
|
|
fail_ci_if_error: false
|
|
|
|
frontend-tests:
|
|
name: Frontend Tests (JS)
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run frontend tests
|
|
run: npm test -- --coverage
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: ./coverage/lcov.info
|
|
flags: frontend
|
|
name: frontend-coverage
|
|
fail_ci_if_error: false
|
|
|
|
integration-tests:
|
|
name: Integration Tests
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-tests]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r app/requirements.txt
|
|
pip install pytest pytest-asyncio pytest-cov httpx respx freezegun pytest-mock
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
pytest tests/backend -v --tb=short -m "integration" || true
|
|
env:
|
|
DATABASE_URL: "sqlite+aiosqlite:///:memory:"
|
|
API_KEY: "test-api-key-12345"
|
|
JWT_SECRET_KEY: "test-jwt-secret-key"
|
|
NTFY_ENABLED: "false"
|
|
ANSIBLE_DIR: "."
|
|
|
|
all-tests-passed:
|
|
name: All Tests Passed
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-tests, frontend-tests]
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Check test results
|
|
run: |
|
|
if [ "${{ needs.backend-tests.result }}" != "success" ]; then
|
|
echo "Backend tests failed"
|
|
exit 1
|
|
fi
|
|
if [ "${{ needs.frontend-tests.result }}" != "success" ]; then
|
|
echo "Frontend tests failed"
|
|
exit 1
|
|
fi
|
|
echo "All tests passed!"
|