Measuring Code Quality#
The PTB uses various Nox sessions incl. linting and tests to collect code-quality data and upload the results to Sonar for aggregation and review.
Overview#
The PTB code-quality flow has three stages:
Run linting and test sessions that generate artifact files.
Collect and validate those artifacts in
report.yml.Upload the consolidated results with
sonar:check.
The individual tools still produce the raw data, but Sonar is the main place where PTB projects review the combined results in CI.
Generate Code Quality Results#
For each result type, there is a dedicated nox session, generating one or multiple files and based on a selected external Python tool.
Nox session |
Generated files |
Based on |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
These results are computed for each element in your build matrix, e.g. for
each Python version defined in constant PROJECT_CONFIG in file
noxconfig.py.
The GitHub workflows of your project can use a build matrix and multiple test workflows, for example to distinguish fast and slow tests.
The test workflows can use CLI option --paths supported by both nox
sessions test:unit and test:integration to only run a subset of the
tests in specific directories or files:
poetry run -- nox -s test:integration -- \
--paths test/gpu test/test_regression.py \
--coverage
Still, option --coverage enables to collect coverage data and pass it to
SonarQube analysis for aggregation and reporting.
Report Code Quality Results#
The PTB uses only the results associated with the Python version specified by
exasol.toolbox.config.BaseConfig.minimum_python_version().
In CI, workflow report.yml downloads the previously generated artifacts and
then runs the following Nox sessions:
Nox session |
Actions |
|---|---|
|
|
|
|
|
|
After that, Sonar becomes the main review surface for combined PTB code-quality results, see the dedicated subsections for details on configuration and handling findings.