Police Pagination #611
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Backend Tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| jobs: | |
| backend-test: | |
| runs-on: ubuntu-latest | |
| services: | |
| sqlserver: | |
| image: mcr.microsoft.com/mssql/server:2022-latest | |
| env: | |
| ACCEPT_EULA: Y | |
| MSSQL_SA_PASSWORD: YourStrong!Passw0rd | |
| MSSQL_PID: Express | |
| ports: | |
| - 1433:1433 | |
| options: >- | |
| --health-cmd "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'YourStrong!Passw0rd' -Q 'SELECT 1' -C" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| --health-start-period 30s | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| cache-dependency-path: | | |
| pyproject.toml | |
| backend/pyproject.toml | |
| - name: Install ODBC Driver 18 for SQL Server | |
| run: | | |
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-archive-keyring.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/ubuntu/22.04/prod jammy main" | sudo tee /etc/apt/sources.list.d/mssql-release.list | |
| sudo apt-get update | |
| sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e backend/ | |
| - name: Create test database | |
| env: | |
| MSSQL_USER: sa | |
| MSSQL_PASSWORD: YourStrong!Passw0rd | |
| MSSQL_HOST: localhost | |
| MSSQL_PORT: 1433 | |
| MSSQL_DATABASE: ocsl_test | |
| MSSQL_DRIVER: ODBC Driver 18 for SQL Server | |
| MSSQL_TRUST_SERVER_CERTIFICATE: "yes" | |
| GOOGLE_MAPS_API_KEY: "test_api_key_not_used" | |
| JWT_SECRET_KEY: "test-jwt-secret-for-ci" | |
| REFRESH_TOKEN_SECRET_KEY: "test-refresh-secret-for-ci" | |
| INTERNAL_API_SECRET: "test-internal-secret-for-ci" | |
| run: PYTHONPATH=backend python -m script.create_test_db | |
| - name: Run pytest | |
| run: PYTHONPATH=backend:backend/src pytest backend/test -v --tb=long --junitxml=backend/test-results/junit.xml | |
| env: | |
| GOOGLE_MAPS_API_KEY: "test_api_key_not_used" | |
| MSSQL_USER: sa | |
| MSSQL_PASSWORD: YourStrong!Passw0rd | |
| MSSQL_HOST: localhost | |
| MSSQL_PORT: 1433 | |
| MSSQL_DATABASE: ocsl_test | |
| MSSQL_DRIVER: ODBC Driver 18 for SQL Server | |
| MSSQL_TRUST_SERVER_CERTIFICATE: "yes" | |
| JWT_SECRET_KEY: "test-jwt-secret-for-ci" | |
| REFRESH_TOKEN_SECRET_KEY: "test-refresh-secret-for-ci" | |
| INTERNAL_API_SECRET: "test-internal-secret-for-ci" | |
| - name: Publish Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: backend/test-results/junit.xml | |
| check_name: Test Results | |
| comment_title: Test Results Summary | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pytest-results | |
| path: | | |
| backend/test-results/ | |
| backend/.pytest_cache/ | |
| retention-days: 7 |