Skip to content

Commit

Permalink
feat: add test coverage
Browse files Browse the repository at this point in the history
- Remove xdist configuration from pyproject.toml for Pycharm test runner compatibility
- Add xdist to `make test` environment
- Add code coverage
- Add codecov upload
  • Loading branch information
khvn26 committed Jul 20, 2023
1 parent a50b2b8 commit f20767a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/api-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ jobs:
env:
DOTENV_OVERRIDE_FILE: .env-ci
run: make test

- name: Upload Coverage
uses: codecov/codecov-action@v3
env:
PYTHON: ${{ matrix.python-version }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: PYTHON
1 change: 1 addition & 0 deletions api/.env-ci
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
ANALYTICS_DATABASE_URL=postgres://postgres:postgres@localhost:5432/analytics
PYTEST_ADDOPTS==--cov-report xml -n auto
1 change: 1 addition & 0 deletions api/.env-local
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DATABASE_URL=postgresql://postgres:password@localhost:5432/flagsmith
DJANGO_SETTINGS_MODULE=app.settings.local
PYTEST_ADDOPTS=--cov-report html -n auto
5 changes: 4 additions & 1 deletion api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ static/

# SaaS only modules
saml/
features/workflows/logic/
features/workflows/logic/

# Unit test coverage
.coverage
2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ known_third_party=['_pytest','apiclient','app_analytics','axes','chargebee','cor
skip = ['migrations','.venv','.direnv']

[tool.pytest.ini_options]
addopts = ['--ds=app.settings.test', '-vvvv', '-p', 'no:warnings', '-n', 'auto']
addopts = ['--ds=app.settings.test', '-vvvv', '-p', 'no:warnings', '--cov', '.']
1 change: 1 addition & 0 deletions api/requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ flake8
pytest-mock
pytest-lazy-fixture
moto
pytest-cov
pytest-freezegun
pytest-xdist
5 changes: 5 additions & 0 deletions api/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ click==8.1.3
# via
# black
# pip-tools
coverage[toml]==7.2.7
# via pytest-cov
cryptography==41.0.2
# via moto
dill==0.3.6
Expand Down Expand Up @@ -114,11 +116,14 @@ pyproject-hooks==1.0.0
pytest==7.2.1
# via
# -r requirements-dev.in
# pytest-cov
# pytest-django
# pytest-freezegun
# pytest-lazy-fixture
# pytest-mock
# pytest-xdist
pytest-cov==4.1.0
# via -r requirements-dev.in
pytest-django==4.5.2
# via -r requirements-dev.in
pytest-freezegun==0.4.2
Expand Down

0 comments on commit f20767a

Please sign in to comment.