Skip to content

Commit

Permalink
Do not run coverage by default (#5312)
Browse files Browse the repository at this point in the history
Fixes #5242.

This PR moves coverage measurement from the default `pytest` invocation
to a separate action `test-with-coverage`.
  • Loading branch information
snejus committed Jun 16, 2024
2 parents 494c676 + 0e1b5c2 commit 076ec6f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ jobs:

- if: ${{ env.IS_MAIN_PYTHON != 'true' }}
name: Test without coverage
run: poe test --no-cov
run: poe test

- if: ${{ env.IS_MAIN_PYTHON == 'true' }}
name: Test with coverage
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: pytest
run: poe test
run: poe test-with-coverage

- if: ${{ env.IS_MAIN_PYTHON == 'true' }}
name: Store the coverage report
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ htmlcov/
coverage.xml
*,cover
.hypothesis/
.reports

# Flask stuff:
instance/
Expand Down
20 changes: 19 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,25 @@ cmd = "poetry update -vv"

[tool.poe.tasks.test]
help = "Run tests with pytest"
cmd = "pytest"
cmd = "pytest $OPTS"
env.OPTS.default = "-p no:cov"

[tool.poe.tasks.test-with-coverage]
help = "Run tests and record coverage"
ref = "test"
# record coverage in beets and beetsplug packages
# save xml for coverage upload to coveralls
# save html report for local dev use
# measure coverage across logical branches
# show which tests cover specific lines in the code (see the HTML report)
env.OPTS = """
--cov=beets
--cov=beetsplug
--cov-report=xml:.reports/coverage.xml
--cov-report=html:.reports/html
--cov-branch
--cov-context=test
"""

[tool.black]
line-length = 80
Expand Down
11 changes: 0 additions & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ addopts =
# show all skipped/failed/xfailed tests in the summary except passed
-ra
--strict-config
# record coverage in these two packages
--cov=beets
--cov=beetsplug
# save xml for coverage upload
--cov-report=xml:.reports/coverage.xml
# save html files for local dev use
--cov-report=html:.reports/html
# record coverage across logical branches
--cov-branch
# show which tests cover specific lines in the code (available in HTML)
--cov-context=test

[coverage:run]
data_file = .reports/coverage/data
Expand Down

0 comments on commit 076ec6f

Please sign in to comment.