nordabiz/.github/workflows/test.yml
Maciej Pienczyn a57187e05f
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
test: Add comprehensive testing infrastructure
- pytest framework with fixtures for auth (auth_client, admin_client)
- Unit tests for SearchService
- Integration tests for auth flow
- Security tests (OWASP Top 10: SQL injection, XSS, CSRF)
- Smoke tests for production health and backup monitoring
- E2E tests with Playwright (basic structure)
- DR tests for backup/restore procedures
- GitHub Actions CI/CD workflow (.github/workflows/test.yml)
- Coverage configuration (.coveragerc) with 80% minimum
- DR documentation and restore script

Staging environment: VM 248, staging.nordabiznes.pl

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 07:52:34 +01:00

174 lines
5.1 KiB
YAML

name: NordaBiz Tests
on:
push:
branches: [master, develop]
pull_request:
branches: [master]
env:
PYTHON_VERSION: '3.11'
jobs:
# =============================================================================
# Unit and Integration Tests
# =============================================================================
unit-tests:
name: Unit & Integration Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: nordabiz_test
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: nordabiz_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
run: |
pytest tests/unit/ -v --cov=. --cov-report=xml
env:
TESTING: 'true'
DATABASE_URL: postgresql://nordabiz_test:testpassword@localhost:5432/nordabiz_test
- name: Run integration tests
run: |
pytest tests/integration/ -v --cov=. --cov-report=xml --cov-append
env:
TESTING: 'true'
DATABASE_URL: postgresql://nordabiz_test:testpassword@localhost:5432/nordabiz_test
- name: Run security tests
run: |
pytest tests/security/ -v
env:
TESTING: 'true'
DATABASE_URL: postgresql://nordabiz_test:testpassword@localhost:5432/nordabiz_test
- name: Check coverage
run: |
coverage report --fail-under=80
continue-on-error: true # Don't fail build on coverage (for now)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
fail_ci_if_error: false
# =============================================================================
# E2E Tests (on staging)
# =============================================================================
e2e-tests:
name: E2E Tests (Playwright)
runs-on: ubuntu-latest
needs: unit-tests # Only run if unit tests pass
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
playwright install chromium
- name: Run E2E tests on staging
run: |
pytest tests/e2e/ -v --base-url=${{ secrets.STAGING_URL }}
env:
BASE_URL: ${{ secrets.STAGING_URL }}
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
continue-on-error: true # E2E tests may fail if staging unavailable
# =============================================================================
# Smoke Tests (on production) - only on master
# =============================================================================
smoke-tests:
name: Smoke Tests (Production)
runs-on: ubuntu-latest
needs: unit-tests
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
pip install pytest requests
- name: Run smoke tests
run: |
pytest tests/smoke/test_production_health.py -v
env:
PROD_URL: https://nordabiznes.pl
# =============================================================================
# Notify on Failure
# =============================================================================
notify-on-failure:
name: Send Failure Notification
runs-on: ubuntu-latest
needs: [unit-tests, e2e-tests]
if: failure()
steps:
- name: Send failure email
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: "❌ NordaBiz Tests Failed - ${{ github.ref_name }}"
to: ${{ secrets.NOTIFY_EMAIL }}
from: NordaBiz CI <ci@nordabiznes.pl>
body: |
Testy nie przeszły!
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Autor: ${{ github.actor }}
Wiadomość: ${{ github.event.head_commit.message }}
Zobacz szczegóły:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}