Skip to content

Commit 3ded8a8

Browse files
committed
feat: add test coverage
- Remove xdist configuration from pyproject.toml for Pycharm test runner compatibility - Add xdist to `make test` environment - Add code coverage - Add codecov upload
1 parent a50b2b8 commit 3ded8a8

7 files changed

+21
-2
lines changed

.github/workflows/api-pull-request.yml

+8
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,11 @@ jobs:
6464
env:
6565
DOTENV_OVERRIDE_FILE: .env-ci
6666
run: make test
67+
68+
- name: Upload Coverage
69+
uses: codecov/codecov-action@v3
70+
env:
71+
PYTHON: ${{ matrix.python-version }}
72+
with:
73+
token: ${{ secrets.CODECOV_TOKEN }}
74+
env_vars: PYTHON

api/.env-ci

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
22
ANALYTICS_DATABASE_URL=postgres://postgres:postgres@localhost:5432/analytics
3+
PYTEST_ADDOPTS=--cov-report xml -n auto

api/.env-local

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
DATABASE_URL=postgresql://postgres:password@localhost:5432/flagsmith
22
DJANGO_SETTINGS_MODULE=app.settings.local
3+
PYTEST_ADDOPTS=--cov-report html -n auto

api/.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ static/
33

44
# SaaS only modules
55
saml/
6-
features/workflows/logic/
6+
features/workflows/logic/
7+
8+
# Unit test coverage
9+
.coverage

api/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ known_third_party=['_pytest','apiclient','app_analytics','axes','chargebee','cor
3434
skip = ['migrations','.venv','.direnv']
3535

3636
[tool.pytest.ini_options]
37-
addopts = ['--ds=app.settings.test', '-vvvv', '-p', 'no:warnings', '-n', 'auto']
37+
addopts = ['--ds=app.settings.test', '-vvvv', '-p', 'no:warnings', '--cov', '.']

api/requirements-dev.in

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ flake8
1313
pytest-mock
1414
pytest-lazy-fixture
1515
moto
16+
pytest-cov
1617
pytest-freezegun
1718
pytest-xdist

api/requirements-dev.txt

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ click==8.1.3
3333
# via
3434
# black
3535
# pip-tools
36+
coverage[toml]==7.2.7
37+
# via pytest-cov
3638
cryptography==41.0.2
3739
# via moto
3840
dill==0.3.6
@@ -114,11 +116,14 @@ pyproject-hooks==1.0.0
114116
pytest==7.2.1
115117
# via
116118
# -r requirements-dev.in
119+
# pytest-cov
117120
# pytest-django
118121
# pytest-freezegun
119122
# pytest-lazy-fixture
120123
# pytest-mock
121124
# pytest-xdist
125+
pytest-cov==4.1.0
126+
# via -r requirements-dev.in
122127
pytest-django==4.5.2
123128
# via -r requirements-dev.in
124129
pytest-freezegun==0.4.2

0 commit comments

Comments
 (0)