-
Notifications
You must be signed in to change notification settings - Fork 11
129 lines (121 loc) · 4.15 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
name: tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
- 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
- name: Lint templates with djLint
run: |
poetry run djlint --version
poetry run djlint --lint myhpi
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.11, 3.12]
database: [sqlite, postgres]
include:
- database: sqlite
database_url: "sqlite:///data/db.sqlite3"
- database: postgres
database_url: "psql://user:[email protected]:5432/myHPI"
env:
DJANGO_SETTINGS_MODULE: myhpi.tests.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
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
- name: Install dependencies
# always install all -E extras to use a single cache
run: |
sudo apt-get install gettext
source env/bin/activate
poetry run python -m pip install setuptools -U
poetry install -E mysql -E pgsql
python tools/install_bootstrap.py
- 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 run python -m pip install psycopg2
if: matrix.database == 'postgres'
#- name: Migrate db
# run: |
# source env/bin/activate
# # python manage.py migrate --run-syncdb
- name: Test apps
env:
DATABASE_URL: ${{ matrix.database_url }}
run: |
source env/bin/activate
poetry run coverage run --source=myhpi manage.py test myhpi.tests
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
source env/bin/activate
pip install coveralls
coveralls --service=github
if: matrix.python-version == '3.9' && matrix.database == 'sqlite'