Skip to content

Tests

Tests #1495

Workflow file for this run

name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * 0"
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
ENV: dev
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: pipx install poetry
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Install dependencies
run: poetry install --all-extras
- name: Run gitlint
run: poetry run gitlint --contrib contrib-title-conventional-commits
- name: Run ruff check
run: poetry run ruff check .
- name: Run mypy
run: poetry run mypy document_merge_service
- name: Run ruff format
run: poetry run ruff format --check --diff .
- name: Run migration check
run: poetry run python manage.py makemigrations --check --dry-run --no-input
docker-tests:
name: Docker tests
needs: [lint]
runs-on: ubuntu-latest
env:
ENV: dev
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set UID
run: |
echo "UID=$(id --user)" > .env
echo "ISOLATE_UNOCONV=true" >> .env
- name: Build docker containers
run: docker compose up -d --build
- name: Run pytest
run: docker compose exec -T document-merge-service poetry run pytest --no-cov-on-fail --cov --create-db -vv
compatibility-tests:
name: Compatibility tests
needs: [lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- "3.10"
- "3.11"
- "3.12"
database:
- "sqlite"
- "postgres"
- "mysql"
services:
postgres:
image: postgres:alpine
env:
POSTGRES_USER: document-merge-service
POSTGRES_PASSWORD: document-merge-service
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mysql:
image: mysql:latest
env:
MYSQL_DATABASE: document-merge-service
MYSQL_USER: document-merge-service
MYSQL_PASSWORD: document-merge-service
MYSQL_RANDOM_ROOT_PASSWORD: yes
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
ports:
- 3306:3306
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
cache: "poetry"
- name: Prepare directories
run: mkdir -p ${{ runner.temp }}/document-merge-service/data ${{ runner.temp }}/document-merge-service/media/attachments ${{ runner.temp }}/document-merge-service/media/__convert__
- name: Install dependendies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends util-linux unoconv libreoffice-writer
poetry install --all-extras
- name: Set environment
run: |
echo "ENV=dev" >> .env
echo "UID=$(id --user)" >> .env
echo "ISOLATE_UNOCONV=true" >> .env
echo "DATABASE_DIR=${{ runner.temp }}/document-merge-service/data" >> .env
echo "MEDIA_ROOT=${{ runner.temp }}/document-merge-service/media" >> .env
- name: Configure postgres
if: ${{ matrix.database == 'postgres' }}
run: |
echo "DATABASE_ENGINE=django.db.backends.postgresql"
echo "DATABASE_HOST=localhost"
echo "DATABASE_PORT=5432"
echo "DATABASE_NAME=document-merge-service"
echo "DATABASE_USER=document-merge-service"
echo "DATABASE_PASSWORD=document-merge-service"
- name: Configure mysql
if: ${{ matrix.database == 'mysql' }}
run: |
echo "DATABASE_ENGINE=django.db.backends.mysql"
echo "DATABASE_HOST=localhost"
echo "DATABASE_PORT=3306"
echo "DATABASE_NAME=document-merge-service"
echo "DATABASE_USER=document-merge-service"
echo "DATABASE_PASSWORD=document-merge-service"
- name: Run tests
run: poetry run pytest --no-cov-on-fail --cov --create-db -vv