-
Notifications
You must be signed in to change notification settings - Fork 11
132 lines (123 loc) · 4.01 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
name: tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ 3.9 ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: Gr1N/setup-poetry@v4
- uses: actions/cache@v1
with:
path: ~/.cache/pypoetry/virtualenvs
key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-
- name: Install dependencies
run: poetry install
- name: check format with black
run: |
poetry run black --version
poetry run black --check .
- name: check import order with isort
run: |
poetry run isort --version
poetry run isort -c .
- name: Lint with pylint
run: |
poetry run pylint --version
poetry run pylint --fail-under=9 myhpi
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ 3.8, 3.9 ]
database: [ sqlite, mysql, postgres ]
include:
- database: sqlite
database_url: "sqlite:///data/db.sqlite3"
- database: mysql
database_url: "mysql://root:[email protected]:3306/myHPI"
- database: postgres
database_url: "psql://user:[email protected]:5432/myHPI"
env:
DJANGO_SETTINGS_MODULE: myhpi.settings
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
#- uses: Gr1N/setup-poetry@v4
#- uses: actions/cache@v1
# with:
# path: ~/.cache/pypoetry/virtualenvs
# key: myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
# restore-keys: |
# myHPI-${{ runner.os }}-poetry-py${{ matrix.python-version }}-
- name: Setup python venv and poetry
run: |
#sudo apt-get install python-venv
python -m venv env
source env/bin/activate
pip install poetry
- name: Install dependencies
# always install all -E extras to use a single cache
run: |
sudo apt-get install gettext
source env/bin/activate
poetry install -E mysql -E pgsql
- name: Prepare files for test run
continue-on-error: true
run: |
cp .env.example .env
source env/bin/activate
poetry run python manage.py compilemessages --settings myhpi.settings
poetry run python manage.py collectstatic --settings myhpi.settings
- name: Setup postgres
uses: harmon758/postgresql-action@v1
with:
postgresql version: '11' # See https://hub.docker.com/_/postgres for available versions
postgresql db: myHPI
postgresql user: user
postgresql password: pass
if: matrix.database == 'postgres'
- name: Setup postgres dependency
run: |
source env/bin/activate
poetry add psycopg2
if: matrix.database == 'postgres'
#- uses: mirromutth/[email protected]
# with:
# mysql database: 'myHPI'
# mysql root password: 'root'
# if: matrix.database == 'mysql'
- name: Setup mysql
run: |
sudo systemctl start mysql.service
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot -proot -Dmysql
echo "CREATE DATABASE myHPI;" | mysql -uroot -proot
source env/bin/activate
poetry add mysqlclient
if: matrix.database == 'mysql'
- name: Test apps
env:
DATABASE_URL: ${{ matrix.database_url }}
run: |
source env/bin/activate
poetry run coverage run --source=myhpi -m pytest tests/
#- name: Coveralls
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# source env/bin/activate
# poetry run coveralls
# if: matrix.python-version == '3.9' && matrix.database == 'sqlite'