Collecting metrics

Generated metrics

The PTB allows you to collect various metrics on the quality of your project regarding Coverage, Security, and Static Code Analysis.

For each metric, 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

lint:code

lint.txt, lint.json

pylint

lint:security

.security.json

bandit

test:unit -- --coverage

.coverage

coverage

test:integration -- --coverage

.coverage

coverage

These metrics are computed for each element in your build matrix, e.g. for each Python version defined in the file noxconfig.py:

@dataclass(frozen=True)
class Config:
    python_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]

The GitHub workflows of your project can:

  • Use a build matrix, e.g. using different Python versions as shown above

  • Define multiple test sessions, e.g. for distinguishing fast vs. slow or expensive tests.

Reporting metrics

Currently, the PTB offers two methods to aggregate the Generated metrics into a report:

  1. the nox session project:report

    This is an Exasol-specific summarization tool. For more information, see project:report.

  2. SonarQube analysis

    This summarization tool feeds into a feature-rich UI provided by Sonar. For further details, see SonarQube analysis

Both of these reporting options require that the generated files from the Generated metrics are existing and in the expected formats. As there are metrics for different Python versions, the PTB uses only the metrics associated with the Python version named first in the attribute python_versions of class Config to the reporting metrics tools.

To perform this validation, there are two nox sessions. Due to the direct dependence on the nox session project:report and SonarQube Analysis on the aforementioned nox sessions, all of these are executed in succession in the CI’s report.yml.

Nox session

Actions

artifacts:copy

  • Combines coverage artifacts from various test sources (unit, integration …)

  • Copies downloaded artifacts to their parent directory

artifacts:validate

  • Verifies that the .lint.json, .lint.txt, .security.json, and .coverage are present

  • Checks that each file contains the expected attributes for that file type