File tree Expand file tree Collapse file tree 5 files changed +37
-16
lines changed Expand file tree Collapse file tree 5 files changed +37
-16
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ name: Test
3
3
on : [push, pull_request]
4
4
5
5
env :
6
+ POSTGRES_USER : postgres
7
+ POSTGRES_PASSWORD : postgres
8
+ POSTGRES_DB : postgres
6
9
FORCE_COLOR : 1
7
10
8
11
jobs :
@@ -16,11 +19,11 @@ jobs:
16
19
17
20
services :
18
21
postgres :
19
- image : postgres:12
22
+ image : postgres:13-alpine
20
23
env :
21
- POSTGRES_USER : postgres
22
- POSTGRES_PASSWORD : postgres
23
- POSTGRES_DB : postgres
24
+ POSTGRES_USER : ${{ env.POSTGRES_USER }}
25
+ POSTGRES_PASSWORD : ${{ env.POSTGRES_PASSWORD }}
26
+ POSTGRES_DB : ${{ env.POSTGRES_DB }}
24
27
ports :
25
28
- 5432:5432
26
29
options : >-
60
63
run : |
61
64
tox -v -- --cov --cov-append --cov-report term-missing --cov-report xml
62
65
env :
63
- DB_NAME : postgres
64
- DB_USER : postgres
65
- DB_PASSWORD : postgres
66
- DB_HOST : localhost
67
- DB_PORT : 5432
66
+ POSTGRES_DB : ${{ env.POSTGRES_DB }}
67
+ POSTGRES_USER : ${{ env.POSTGRES_USER }}
68
+ POSTGRES_PASSWORD : ${{ env.POSTGRES_PASSWORD }}
68
69
69
70
- name : Upload coverage
70
71
uses : codecov/codecov-action@v3
Original file line number Diff line number Diff line change @@ -74,6 +74,18 @@ To run tox and generate a coverage report (in ``htmlcov`` directory)::
74
74
75
75
make test
76
76
77
+ A database is required to run the tests. For convince there is a ``docker-compose.yml `` file for spinning up a
78
+ database container. To start the database container run:
79
+
80
+ docker-compose up -d
81
+
82
+ Another way to run the tests with a sqlite database is to export the `SQLITE ` variable::
83
+
84
+ export SQLITE=1
85
+ make test
86
+ # or
87
+ SQLITE=1 python setup.py test
88
+
77
89
**Please note **: Before a pull request can be merged, all tests must pass and
78
90
code/branch coverage in tests must be 100%.
79
91
Original file line number Diff line number Diff line change
1
+ services :
2
+ postgres :
3
+ image : postgres:13-alpine
4
+ environment :
5
+ POSTGRES_HOST_AUTH_METHOD : trust
6
+ POSTGRES_DB : modelutils
7
+ POSTGRES_USER : postgres
8
+ ports :
9
+ - 5432:5432
Original file line number Diff line number Diff line change 15
15
DATABASES = {
16
16
"default" : {
17
17
"ENGINE" : "django.db.backends.postgresql" ,
18
- "NAME" : os .environ .get ("DB_NAME " , "modelutils" ),
19
- "USER" : os .environ .get ("DB_USER " , 'postgres' ),
20
- "PASSWORD" : os .environ .get ("DB_PASSWORD " , "" ),
21
- "HOST" : os .environ .get ("DB_HOST " , "localhost" ),
22
- "PORT" : os .environ .get ("DB_PORT " , 5432 )
18
+ "NAME" : os .environ .get ("POSTGRES_DB " , "modelutils" ),
19
+ "USER" : os .environ .get ("POSTGRES_USER " , 'postgres' ),
20
+ "PASSWORD" : os .environ .get ("POSTGRES_PASSWORD " , "" ),
21
+ "HOST" : os .environ .get ("POSTGRES_HOST " , "localhost" ),
22
+ "PORT" : os .environ .get ("POSTGRES_PORT " , 5432 )
23
23
},
24
24
}
25
-
26
25
SECRET_KEY = 'dummy'
27
26
28
27
CACHES = {
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ passenv =
36
36
CI
37
37
FORCE_COLOR
38
38
GITHUB_*
39
- DB_ *
39
+ POSTGRES_ *
40
40
usedevelop = True
41
41
commands =
42
42
python -m pytest {posargs}
You can’t perform that action at this time.
0 commit comments