Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage #946

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
9911687
Testing the waters..
kingbuzzman Jun 23, 2022
b0d8ac2
The settings file interferes with examples
kingbuzzman Jun 23, 2022
75b13aa
test coverage
kingbuzzman Jun 23, 2022
8cc8c71
Take 2
kingbuzzman Jun 23, 2022
8e567a8
Basic report
kingbuzzman Jun 23, 2022
5413d68
Adds conditionals
kingbuzzman Jun 23, 2022
b1d3fd1
is this needed?
kingbuzzman Jun 23, 2022
4ef59fc
This doesnt look like its needed at all
kingbuzzman Jun 23, 2022
4134033
unify everything into the makefile
kingbuzzman Jun 23, 2022
24e4423
This one is really needed
kingbuzzman Jun 23, 2022
7c11583
Bad copy/paste
kingbuzzman Jun 23, 2022
d2992e1
All tests pass, lets see with coverage
kingbuzzman Jun 23, 2022
4bea7d5
Cleans up makefile
kingbuzzman Jun 24, 2022
4565581
Adds better artifact names
kingbuzzman Jun 24, 2022
385363a
Add missing matrix item
kingbuzzman Jun 24, 2022
e7505ae
Removes code from another PR
kingbuzzman Jun 24, 2022
20e44c4
Testing stuff out
kingbuzzman Jun 24, 2022
4e16817
testing only pypy
kingbuzzman Jun 24, 2022
d60e154
Just my luck..
kingbuzzman Jun 24, 2022
ac48025
Attempt 3
kingbuzzman Jun 24, 2022
e9c0b8d
Finally got the error, didn't catch it properly
kingbuzzman Jun 24, 2022
e1b88f6
Attempt 5
kingbuzzman Jun 24, 2022
419d7bb
Attempt 6
kingbuzzman Jun 24, 2022
c31d7bc
Attempt 7
kingbuzzman Jun 24, 2022
606895d
Attempt 8
kingbuzzman Jun 24, 2022
51e3bbe
Attempt 9
kingbuzzman Jun 24, 2022
07fec44
Success, now to try it semi-for-realz
kingbuzzman Jun 24, 2022
4bbd026
Real test
kingbuzzman Jun 24, 2022
012230b
Real test -- making sure its no fluke #1
kingbuzzman Jun 24, 2022
d958058
Real test -- making sure its no fluke 2
kingbuzzman Jun 24, 2022
4bf4194
Adds pypy3.9
kingbuzzman Jun 24, 2022
36893c1
Fixes linter
kingbuzzman Jun 24, 2022
904a011
Did not work..
kingbuzzman Jun 24, 2022
7e19da9
Maybe?
kingbuzzman Jun 24, 2022
920405a
Removes unused import
kingbuzzman Jun 24, 2022
5fcff25
Renames variable to better suit its purpose
kingbuzzman Jun 25, 2022
21c257b
Improve SQLAlchemy tests session cleanup
kingbuzzman Jun 28, 2022
0993845
Update tox.ini
kingbuzzman Jun 28, 2022
7948e6f
Merge branch 'master' into feature/tox-cov
kingbuzzman Jun 28, 2022
c036111
No coverage
kingbuzzman Jun 28, 2022
f8ddaa1
Merge branch 'feature/tox-cov' of github.com:kingbuzzman/factory_boy …
kingbuzzman Jun 28, 2022
a47c7b9
Useless commit that has coverage in it.. to run coverage ;)
kingbuzzman Jun 28, 2022
0106d15
Why doesn't coverage work
kingbuzzman Jun 28, 2022
b115519
How about this? coverage
kingbuzzman Jun 28, 2022
2467838
Removes debug vars
kingbuzzman Jun 28, 2022
b02f838
Update tox.ini
kingbuzzman Jun 29, 2022
6e99e69
Merge branch 'master' into feature/tox-cov
kingbuzzman Jun 29, 2022
1b19cbf
Removing the conditional logic, have coverage run always
kingbuzzman Jun 29, 2022
6efe9fc
temp -- adds cache
kingbuzzman Jun 29, 2022
093db6f
Removes conitional more run-coverage logic, will be cached now
kingbuzzman Jun 29, 2022
72adb74
oops, now with coverage
kingbuzzman Jun 29, 2022
8b5ea3d
Does this continue working
kingbuzzman Jun 29, 2022
bb4f9db
Very NOT optional
kingbuzzman Jun 29, 2022
6db9acc
Env not used
kingbuzzman Jun 29, 2022
239054d
Want to see if tox is using the cache
kingbuzzman Jun 29, 2022
67cbc71
Remove verbose
kingbuzzman Jun 29, 2022
ed2f722
Removes cache
kingbuzzman Jun 29, 2022
f18bb61
Keeps command the same as on master
kingbuzzman Jun 29, 2022
7e34206
Merge branch 'master' into feature/tox-cov
kingbuzzman Jul 5, 2022
2508397
Merge branch 'master' into feature/tox-cov
kingbuzzman Jul 5, 2022
bde39ae
Merge remote-tracking branch 'remote/master' into feature/tox-cov
kingbuzzman Jul 18, 2022
6dcd218
Merge remote-tracking branch 'remote/master' into feature/tox-cov
kingbuzzman Jul 18, 2022
6d6743a
Merge branch 'master' into feature/tox-cov
kingbuzzman Aug 23, 2022
777dae4
Merge remote-tracking branch 'remote/master' into feature/tox-cov
kingbuzzman Oct 27, 2022
a2b9149
Merge branch 'master' into feature/tox-cov
kingbuzzman Feb 6, 2023
4d86ac3
Update tox.ini
kingbuzzman Feb 6, 2023
9c01097
Merge branch 'master' into feature/tox-cov
kingbuzzman Feb 7, 2023
400b183
testing..
kingbuzzman Feb 7, 2023
4ab8ee4
Update Makefile
kingbuzzman Feb 7, 2023
c0e5990
Update Makefile
kingbuzzman Feb 7, 2023
2b8fc1a
Merge branch 'master' into feature/tox-cov
kingbuzzman Mar 29, 2023
ad961de
Update test.yml
kingbuzzman Mar 29, 2023
57ac2fb
Merge branch 'master' into feature/tox-cov
kingbuzzman Jun 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ concurrency:

jobs:
tests:
name: Python ${{ matrix.python-version }}, Database ${{ matrix.database-type }}
name: Python ${{ matrix.python-version[0] }}, Database ${{ matrix.database-type }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "pypy-3.7"
- "pypy-3.8"
- "pypy-3.9"
- ["3.7", "py37"]
Copy link
Contributor Author

@kingbuzzman kingbuzzman Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds pretty names.. for the coverage filename. If we move this to codecov / alternative, there would be no need to have this around.

- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["pypy-3.7", "pypy37"]
- ["pypy-3.8", "pypy38"]
- ["pypy-3.9", "pypy39"]
kingbuzzman marked this conversation as resolved.
Show resolved Hide resolved
database-type:
- "sqlite"
- "postgres"
Expand All @@ -45,10 +45,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version[0] }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python-version[0] }}
cache: pip

- name: Install dependencies
Expand All @@ -58,3 +58,14 @@ jobs:
run: tox
env:
DATABASE_TYPE: ${{ matrix.database-type }}
RUN_COVERAGE: yes

- name: Coverage report
run: tox -e cov-report

- name: 'Upload coverage'
uses: actions/upload-artifact@v3
with:
name: factory_coverage_${{ matrix.python-version[1] }}_${{ matrix.database-type }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to move this over to a codecov / equivalent and not have to download it..

path: htmlcov/
retention-days: 1
37 changes: 22 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ TESTS_DIR=tests
DOC_DIR=docs
EXAMPLES_DIR=examples
SETUP_PY=setup.py
PYTHON_ERROR_ON_WARN=python \
-b \
-X dev \
-Werror \
-Wdefault:"the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses":DeprecationWarning:distutils: \
-Wdefault:"Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working":DeprecationWarning:: \
-Wdefault:"Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working":DeprecationWarning:: \
-Wdefault:"set_output_charset() is deprecated":DeprecationWarning:: \
-Wdefault:"parameter codeset is deprecated":DeprecationWarning:: \
-Wdefault:"'cgi' is deprecated and slated for removal in Python 3.13":DeprecationWarning::
# Remove cgi warning when dropping support for Django<=4.1.

# Use current python binary instead of system default.
COVERAGE = python $(shell which coverage)
COVERAGE_PATH = $(shell which coverage)
COVERAGE = python $(COVERAGE_PATH)
FLAKE8 = flake8
ISORT = isort
CTAGS = ctags
Expand Down Expand Up @@ -54,17 +66,7 @@ testall:
# DOC: Run tests for the currently installed version
# Remove cgi warning when dropping support for Django<=4.1.
test:
python \
-b \
-X dev \
-Werror \
-Wdefault:"the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses":DeprecationWarning:distutils: \
-Wdefault:"Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working":DeprecationWarning:: \
-Wdefault:"Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working":DeprecationWarning:: \
-Wdefault:"set_output_charset() is deprecated":DeprecationWarning:: \
-Wdefault:"parameter codeset is deprecated":DeprecationWarning:: \
-Wdefault:"'cgi' is deprecated and slated for removal in Python 3.13":DeprecationWarning:: \
-m unittest
$(PYTHON_ERROR_ON_WARN) -m unittest

# DOC: Test the examples
example-test:
Expand All @@ -80,14 +82,19 @@ lint:
$(ISORT) --check-only --diff $(EXAMPLES_DIR) $(PACKAGE) $(SETUP_PY) $(TESTS_DIR)
check-manifest

coverage:
coverage-clean:
$(COVERAGE) erase
$(COVERAGE) run --branch -m unittest
@rm -rf .coverage htmlcov/

coverage-test:
$(PYTHON_ERROR_ON_WARN) $(COVERAGE_PATH) run --branch -m unittest

coverage-report:
$(COVERAGE) report
$(COVERAGE) html


.PHONY: test testall example-test lint coverage
.PHONY: test testall example-test lint coverage-clean coverage-test coverage-report


# Development
Expand Down
24 changes: 17 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ envlist =
docs
examples
linkcheck
py{37,38,39,310,311,py37,py38,py39}-sqlite
py{37,38,39,310,311,py37,py38,py39}-django32-mongo-alchemy-{sqlite,postgres}
py{38,39,310,311,py38,py39}-django40-mongo-alchemy-{sqlite,postgres}
py{38,39,310,311,py38,py39}-django41-mongo-alchemy-{sqlite,postgres}
py310-djangomain-mongo-alchemy-{sqlite,postgres}
py{37,38,39,310,311,py37,py38,py39}-sqlite-{cov,nocov}
py{37,38,39,310,311,py37,py38,py39}-django32-mongo-alchemy-{sqlite,postgres}-{cov,nocov}
py{38,39,310,311,py38,py39}-django40-mongo-alchemy-{sqlite,postgres}-{cov,nocov}
py{38,39,310,311,py38,py39}-django41-mongo-alchemy-{sqlite,postgres}-{cov,nocov}
py310-djangomain-mongo-alchemy-{sqlite,postgres}-{cov,nocov}

[gh-actions]
python =
Expand All @@ -26,13 +26,17 @@ python =
DATABASE_TYPE =
sqlite: sqlite
postgres: postgres
RUN_COVERAGE =
yes: cov
no: nocov

[testenv]
passenv =
MONGO_HOST
POSTGRES_HOST
POSTGRES_DATABASE
deps =
cov: coverage
alchemy: SQLAlchemy
alchemy: sqlalchemy_utils
mongo: mongoengine
Expand All @@ -45,11 +49,17 @@ deps =
pypy{37,38,39}-postgres: psycopg2cffi

setenv =
py: DJANGO_SETTINGS_MODULE=tests.djapp.settings
py-!postgres: DJANGO_SETTINGS_MODULE=tests.djapp.settings
postgres: DJANGO_SETTINGS_MODULE=tests.djapp.settings_pg

allowlist_externals = make
commands = make test
commands =
!cov: make test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't want to force anyone to use nocov, this way its more "intelligent", even though there is a bit of "magic".

cov: make coverage-test

[testenv:cov-report]
commands =
make coverage-report

[testenv:docs]
extras = doc
Expand Down