-
Notifications
You must be signed in to change notification settings - Fork 11
150 lines (145 loc) · 4.57 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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