From 7bd43a75bbfae341d5ad98538d51adc5084841d6 Mon Sep 17 00:00:00 2001 From: tschilling Date: Mon, 13 Dec 2021 19:11:23 -0600 Subject: [PATCH 1/6] Remove codecov, solely use coverage. CodeCov has become a bit flaky in their evaluation of code coverage. Using GitHub actions, we can utilize coverage to combine multiple reports. Thanks to Hynek Schlawack for the approach. https://hynek.me/articles/ditch-codecov-python/ Remove .coveragerc file in favor of configuration in setup.cfg Also applies coverage's parallel mode always. --- .coveragerc | 6 ----- .github/workflows/test.yml | 52 +++++++++++++++++++++++++++++++------- setup.cfg | 13 ++++++++++ tox.ini | 4 ++- 4 files changed, 59 insertions(+), 16 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 0e2d03b56..000000000 --- a/.coveragerc +++ /dev/null @@ -1,6 +0,0 @@ -[run] -source = debug_toolbar -branch = 1 - -[report] -omit = *tests*,*migrations* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 050d5b11d..4f09ec8d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -70,10 +70,11 @@ jobs: DB_HOST: 127.0.0.1 DB_PORT: 3306 - - name: Upload coverage - uses: codecov/codecov-action@v1 + - name: Upload coverage data + uses: actions/upload-artifact@v2 with: - name: Python ${{ matrix.python-version }} + name: coverage-data + path: ".coverage.*" postgres: runs-on: ubuntu-latest @@ -137,10 +138,11 @@ jobs: DB_HOST: localhost DB_PORT: 5432 - - name: Upload coverage - uses: codecov/codecov-action@v1 + - name: Upload coverage data + uses: actions/upload-artifact@v2 with: - name: Python ${{ matrix.python-version }} + name: coverage-data + path: ".coverage.*" sqlite: runs-on: ubuntu-latest @@ -183,10 +185,42 @@ jobs: DB_BACKEND: sqlite3 DB_NAME: ":memory:" - - name: Upload coverage - uses: codecov/codecov-action@v1 + - name: Upload coverage data + uses: actions/upload-artifact@v2 with: - name: Python ${{ matrix.python-version }} + name: coverage-data + path: ".coverage.*" + + coverage: + name: Check coverage. + runs-on: "ubuntu-latest" + needs: [sqlite, mysql, postgres] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + # Use latest, so it understands all syntax. + python-version: "3.10" + + - run: python -m pip install --upgrade coverage + + - name: Download coverage data. + uses: actions/download-artifact@v2 + with: + name: coverage-data + + - name: Combine coverage & fail if it's <100%. + run: | + python -m coverage combine + python -m coverage html --skip-covered --skip-empty + python -m coverage report --fail-under=100 + + - name: Upload HTML report if check failed. + uses: actions/upload-artifact@v2 + with: + name: html-report + path: htmlcov + if: ${{ failure() }} lint: runs-on: ubuntu-latest diff --git a/setup.cfg b/setup.cfg index 5cc680607..0e7f4814c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,19 @@ exclude = tests tests.* +[coverage:run] +branch = True +parallel = True +source = debug_toolbar + +[coverage:paths] +source = + src + .tox/*/site-packages + +[coverage:report] +show_missing = True + [flake8] extend-ignore = E203, E501 diff --git a/tox.ini b/tox.ini index 3abd404bc..452de8cc5 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,7 @@ deps = sqlparse passenv= CI + COVERAGE_ARGS DB_BACKEND DB_NAME DB_USER @@ -39,9 +40,10 @@ setenv = DB_USER = {env:DB_USER:debug_toolbar} DB_HOST = {env:DB_HOST:localhost} DB_PASSWORD = {env:DB_PASSWORD:debug_toolbar} + DJANGO_SETTINGS_MODULE = tests.settings whitelist_externals = make pip_pre = True -commands = make coverage TEST_ARGS='{posargs:tests}' +commands = python -b -W always -m coverage run -m django test -v2 {posargs:tests} [testenv:py{36,37,38,39,310}-dj{22,31,32}-postgresql] setenv = From b9ece2ce89c742481955ebaf51deb8d237e8b91e Mon Sep 17 00:00:00 2001 From: Asif Saif Uddin Date: Thu, 16 Dec 2021 16:55:13 +0600 Subject: [PATCH 2/6] Update setup.cfg Co-authored-by: Paolo Melchiorre --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 0e7f4814c..b25ebfb46 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,6 +56,7 @@ source = .tox/*/site-packages [coverage:report] +fail_under = 100 show_missing = True [flake8] From 697061bd645029215e7cb92d1732d98c67415e80 Mon Sep 17 00:00:00 2001 From: Asif Saif Uddin Date: Thu, 16 Dec 2021 16:55:29 +0600 Subject: [PATCH 3/6] Update .github/workflows/test.yml Co-authored-by: Paolo Melchiorre --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f09ec8d5..bfa8d47fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -213,7 +213,7 @@ jobs: run: | python -m coverage combine python -m coverage html --skip-covered --skip-empty - python -m coverage report --fail-under=100 + python -m coverage report - name: Upload HTML report if check failed. uses: actions/upload-artifact@v2 From 11700641f3c5b66826942959be0126f2f64b887d Mon Sep 17 00:00:00 2001 From: Asif Saif Uddin Date: Thu, 16 Dec 2021 16:55:41 +0600 Subject: [PATCH 4/6] Update .github/workflows/test.yml Co-authored-by: Paolo Melchiorre --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfa8d47fb..276b0099d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -212,7 +212,7 @@ jobs: - name: Combine coverage & fail if it's <100%. run: | python -m coverage combine - python -m coverage html --skip-covered --skip-empty + python -m coverage html python -m coverage report - name: Upload HTML report if check failed. From 57db77b684ee1d2cf79a263d433d0db2acea827a Mon Sep 17 00:00:00 2001 From: Asif Saif Uddin Date: Thu, 16 Dec 2021 16:55:57 +0600 Subject: [PATCH 5/6] Update setup.cfg Co-authored-by: Paolo Melchiorre --- setup.cfg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.cfg b/setup.cfg index b25ebfb46..edbad5cb0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,11 @@ exclude = tests tests.* + +[coverage.html] +skip_covered = True +skip_empty = True + [coverage:run] branch = True parallel = True From b9eaabd88e73b297fdcf871ae7649ff870a6d4f3 Mon Sep 17 00:00:00 2001 From: Tim Schilling Date: Sat, 18 Dec 2021 08:02:57 -0600 Subject: [PATCH 6/6] Reduce acceptable code coverage percentage. --- .github/workflows/test.yml | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 276b0099d..2c8a56811 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -209,7 +209,7 @@ jobs: with: name: coverage-data - - name: Combine coverage & fail if it's <100%. + - name: Combine coverage & check percentage run: | python -m coverage combine python -m coverage html diff --git a/setup.cfg b/setup.cfg index edbad5cb0..7ee46f7be 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,7 +61,7 @@ source = .tox/*/site-packages [coverage:report] -fail_under = 100 +fail_under = 89 show_missing = True [flake8]