-
Notifications
You must be signed in to change notification settings - Fork 94
162 lines (142 loc) · 5.1 KB
/
automated-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
151
152
153
154
155
156
157
158
159
160
161
162
name: Automated tests
on:
push:
branches:
- 'v*'
- 'development'
pull_request:
branches-ignore:
- 'dependabot/'
jobs:
# The most verbose and complete job.
main_test:
name: 'Python ${{ matrix.python-version }}'
runs-on: ubuntu-latest
timeout-minutes: 10 # Don't run forever when stale
strategy:
matrix:
python-version:
- '3.11'
services:
postgres:
image: 'postgres:14-alpine'
ports:
- 5432
env:
POSTGRES_USER: root
POSTGRES_DB: test_dsmrreader
POSTGRES_PASSWORD: testpasswd
options: --health-cmd pg_isready --health-interval 5s --health-timeout 1s --health-retries 10
mysql:
image: 'mysql:8'
ports:
- 3306
env:
MYSQL_DATABASE: test_dsmrreader
MYSQL_ALLOW_EMPTY_PASSWORD: yes
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=1s --health-retries=10
env:
# Do not log verbosely
DSMRREADER_LOGLEVEL: ERROR
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install APT dependencies
run: |
sudo apt-get update
sudo apt-get install -y gettext libgettextpo-dev libmariadb-dev-compat libmariadb-dev
- name: Cached dependencies & virtualenv
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/
~/dsmr-reader/.venv
key: dependencies-update-check-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
pip install --upgrade pip poetry
poetry config virtualenvs.in-project true
poetry check
poetry run pip install -r $GITHUB_WORKSPACE/dsmrreader/provisioning/requirements/base.txt -r $GITHUB_WORKSPACE/dsmrreader/provisioning/requirements/dev.txt
- name: Check flake8
run: poetry run flake8
- name: Check translation status
run: sphinx-intl stat -d dsmrreader/locales/ -d docs/_locale/ | grep -v "0 fuzzy, 0 untranslated" | grep -v changelog.po | wc -l | grep -e '^0$'
- name: Run SQLite tests
run: poetry run py.test --cov --cov-report=xml
env:
DJANGO_SETTINGS_MODULE: dsmrreader.config.test
DJANGO_SECRET_KEY: non-production-value
DJANGO_DATABASE_ENGINE: django.db.backends.sqlite3
- name: Run PostgreSQL tests
run: poetry run py.test
env:
DJANGO_SETTINGS_MODULE: dsmrreader.config.test
DJANGO_SECRET_KEY: unsafe-test-value
DJANGO_DATABASE_ENGINE: django.db.backends.postgresql
DJANGO_DATABASE_HOST: 127.0.0.1
DJANGO_DATABASE_PORT: '${{ job.services.postgres.ports[5432] }}'
DJANGO_DATABASE_NAME: test_dsmrreader
DJANGO_DATABASE_USER: root
DJANGO_DATABASE_PASSWORD: testpasswd
- name: Run MySQL tests
run: poetry run py.test
env:
DJANGO_SETTINGS_MODULE: dsmrreader.config.test
DJANGO_SECRET_KEY: unsafe-test-value
DJANGO_DATABASE_ENGINE: django.db.backends.mysql
DJANGO_DATABASE_HOST: 127.0.0.1
DJANGO_DATABASE_PORT: '${{ job.services.mysql.ports[3306] }}'
DJANGO_DATABASE_NAME: dsmrreader # NOT a typo, django prefixes "test_" automatically.
DJANGO_DATABASE_USER: root
DJANGO_DATABASE_PASSWORD: ''
- name: Code coverage upload
uses: codecov/codecov-action@v3
# Shallow tests for (older) supported Python versions.
matrix_tests:
needs: main_test
name: 'Python ${{ matrix.python-version }}'
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
env:
# Do not log verbosely
DSMRREADER_LOGLEVEL: ERROR
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install APT dependencies
run: |
sudo apt-get update
sudo apt-get install -y gettext libgettextpo-dev libmariadb-dev-compat libmariadb-dev
- name: Cached dependencies & virtualenv
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry/
~/dsmr-reader/dsmr-reader/.venv
key: dependencies-update-check-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
pip install --upgrade pip poetry
poetry config virtualenvs.in-project true
poetry check
poetry install
- name: Run SQLite tests
run: poetry run py.test --cov --cov-report=xml
env:
DJANGO_SETTINGS_MODULE: dsmrreader.config.test
DJANGO_SECRET_KEY: non-production-value
DJANGO_DATABASE_ENGINE: django.db.backends.sqlite3