Skip to content

build: move the coverage settings into pyproject.toml - #967

Open
blaipr wants to merge 3 commits into
ctrliq:mainfrom
blaipr:build/coverage-into-pyproject
Open

build: move the coverage settings into pyproject.toml#967
blaipr wants to merge 3 commits into
ctrliq:mainfrom
blaipr:build/coverage-into-pyproject

Conversation

@blaipr

@blaipr blaipr commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Sits on #960, the pytest half, which touches the same file. Split out so the two can be reviewed, and reverted, on their own.

.coveragerc becomes [tool.coverage.run], [tool.coverage.report] and [tool.coverage.xml], and the file goes. That leaves tox.ini and .yamllint as the only config files at the root that are not pyproject.toml, and neither of them reads it.

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, 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

config file: /awx_devel/pyproject.toml
source: ['awx']          branch: True
omit: ['awx/main/migrations/*']
exclude patterns: 7      xml output: ./reports/coverage.xml

Every value is what .coveragerc had.

Checks

  • A run with --cov produces a terminal report: 47 tests, 16% total.
  • A run with --cov-report=xml writes 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant