-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
446 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Metrics Schema | ||
|
||
This project contains a small script to generate the JSON schema for Exasol metrics. | ||
It has been intentionally separated and should not be used as a dependency. | ||
Its sole purpose is to generate the schema for the metrics statistics. | ||
|
||
## How to Generate a Schema | ||
|
||
**Note:** Ensure that the script is run from the directory where this README is located. | ||
|
||
### 1. Create a new poetry shell | ||
|
||
```shell | ||
poetry shell | ||
``` | ||
|
||
### 2. Install all necessary dependencies | ||
|
||
```shell | ||
poetry install | ||
``` | ||
|
||
### 3. Generate the schema | ||
|
||
**Note:** Please make sure to replace `MAJOR`, `MINOR` and `PATCH` with the appropriate version numbers. | ||
|
||
```shell | ||
python metrics_schema.py > metrics-MAJOR-MINOR-PATCH.json | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import sys | ||
from pathlib import Path | ||
import json | ||
from datetime import datetime | ||
from inspect import cleandoc | ||
|
||
from pydantic import ( | ||
BaseModel, | ||
Field, | ||
) | ||
|
||
_TOOLBOX_PATH = Path(__file__).parent / ".." | ||
sys.path.append(f'{_TOOLBOX_PATH}') | ||
|
||
from exasol.toolbox.metrics import Rating | ||
|
||
|
||
class Metrics(BaseModel): | ||
"""This schema defines the structure and values for reporting Q/A metrics for projects.""" | ||
|
||
commit: str = Field( | ||
description=( | ||
"Commit-Hash pointing to the state of the codebase used for generating the metrics." | ||
) | ||
) | ||
date: datetime = Field( | ||
description="The date and time when the metrics were recorded." | ||
) | ||
coverage: float = Field( | ||
description="Represents the percentage of the codebase that is covered by automated tests.", | ||
ge=0, le=100 | ||
) | ||
maintainability: Rating = Field( | ||
description="Rating of how easily the codebase can be understood, adapted, and extended.", | ||
) | ||
reliability: Rating = Field( | ||
description="Stability and dependability of the software. " | ||
) | ||
security: Rating = Field( | ||
description="Resilience against security threats and vulnerabilities." | ||
) | ||
technical_debt: Rating = Field( | ||
description="Amount of 'technical debt' in the project." | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
schema = { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$id": "https://schemas.exasol.com/metrics-0.1.0.json", | ||
} | ||
schema.update(Metrics.model_json_schema()) | ||
print(json.dumps(schema, indent=2)) |
Oops, something went wrong.