build: move the coverage settings into pyproject.toml - #967
Open
blaipr wants to merge 3 commits into
Open
Conversation
MANIFEST.in names eight paths that are not in the tree: awx/lib/site-packages, awx/plugins, awx/api/tests, awx/ui/client, awx/playbooks/library/mkfifo.py, awx/public, VERSION, COPYING All inherited, and some of them long gone: awx/ui/client is the AngularJS UI, which went years before the 22.5.0 import this fork starts from. It only costs setuptools warnings, so the change is cosmetic in effect. What it is not cosmetic about is trust: this is the file that decides what ships in the sdist, and one that names eight things that do not exist reads as nobody's business. After this every path it names is real. .coveragerc carries the same rot in its omit list, awx/lib/site-packages/*, so that goes in the same change. Checked by building from a copy of the tree: setuptools reports no missing path warnings afterwards.
pyproject already owns setuptools, setuptools_scm and ruff, so pytest.ini becomes [tool.pytest.ini_options] and the file goes. tox.ini and .yamllint stay, since neither reads pyproject. .coveragerc moves separately, so the two can be reviewed and reverted on their own. One value changed on the way, and it is the reason collection has been reporting 14 errors. pytest.ini set python_files to every .py, so collecting imported the whole repository looking for tests, including modules that parse argv at import time. One of them, tools/data_generators/rbac_dummy_data_ generator.py, calls sys.exit(2) from optparse, which takes the whole run down with an INTERNALERROR rather than reporting a failure. Nobody has seen it because CI collects named paths rather than the tree. Nothing needed that wider net. Not one file outside pytest's own patterns defines a test: the only two that look like they do are fixtures named test_* inside a conftest.py, which is never collected as a module anyway. So python_files is pytest's default now, and collecting the tree gives the same 4,020 tests with no errors, in 8 seconds instead of 26. before 4,020 tests collected, 14 errors, 26.1s after 4,020 tests collected, 0 errors, 8.5s Everything else is moved unchanged. All eight markers still register and the unit suite passes. README, CONTRIBUTING and the copilot instructions pointed readers at pytest.ini and now point at pyproject.toml.
The other half of the config consolidation, on its own so the two can be reviewed and reverted separately. .coveragerc becomes [tool.coverage.run], [tool.coverage.report] and [tool.coverage.xml], and the file goes. Nothing is reworded. The exclude_lines entries are regular expressions, so they are TOML literal strings: the backslash in if self\.debug is the regex's rather than TOML's, which is the one thing this move can get wrong quietly. All seven still compile as regexes. Coverage was asked what it reads rather than assumed. It picks pyproject.toml, with source awx, branch on, the same single omit of the migrations, seven exclude patterns, and the same ./reports/coverage.xml output path, which a run with --cov-report=xml does write to. Sits on the pytest move, which touches the same file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sits on #960, the pytest half, which touches the same file. Split out so the two can be reviewed, and reverted, on their own.
.coveragercbecomes[tool.coverage.run],[tool.coverage.report]and[tool.coverage.xml], and the file goes. That leavestox.iniand.yamllintas the only config files at the root that are notpyproject.toml, and neither of them reads it.Nothing is reworded
The
exclude_linesentries are regular expressions, so they are TOML literal strings. The backslash inif self\.debugis the regex's, not TOML's, and that is the one thing this move can get wrong quietly: a double-quoted string would eat it and the pattern would stop matching without failing anything. All seven still compile as regexes.Coverage was asked what it reads, not assumed
Every value is what
.coveragerchad.Checks
--covproduces a terminal report: 47 tests, 16% total.--cov-report=xmlwrites to the configured path:Coverage XML written to file ./reports/coverage.xml, 2.8 MB, so the[tool.coverage.xml]section is being honoured and not just parsed.