Skip to content

Commit acf3a1f

Browse files
resolved conversation
1 parent 07c7896 commit acf3a1f

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

exasol/toolbox/nox/_artifacts.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import pathlib
3+
import re
34
import sqlite3
45
import sys
56
from pathlib import Path
@@ -14,15 +15,14 @@
1415
def check_artifacts(session: Session) -> None:
1516
"""Validate that all project artifacts are available and consistent"""
1617
if not_available := _missing_files(
17-
{".lint.json", ".lint.txt", ".security.json", ".coverage"}, PROJECT_CONFIG.root
18+
{".lint.txt", ".security.json", ".coverage"}, PROJECT_CONFIG.root
1819
):
1920
print(f"not available: {not_available}")
2021
sys.exit(1)
2122

2223
error = False
23-
if msg := _validate_lint_json(Path(PROJECT_CONFIG.root, ".lint.json")):
24-
print(f"error in [.lint.json]: {msg}")
25-
error = True
24+
if msg := _validate_lint_txt(Path(PROJECT_CONFIG.root, ".lint.txt")):
25+
print(f"error in [.lint.txt]: {msg}")
2626
if msg := _validate_security_json(Path(PROJECT_CONFIG.root, ".security.json")):
2727
print(f"error in [.security.json]: {msg}")
2828
error = True
@@ -38,6 +38,18 @@ def _missing_files(expected_files: set, directory: Path) -> set:
3838
return expected_files - files
3939

4040

41+
def _validate_lint_txt(file: Path) -> str:
42+
try:
43+
content = file.read_text()
44+
except FileNotFoundError as ex:
45+
return f"Could not find file {file}, details: {ex}"
46+
expr = re.compile(r"^Your code has been rated at (\d+.\d+)/.*", re.MULTILINE)
47+
matches = expr.search(content)
48+
if not matches:
49+
return f"Could not find a rating"
50+
return ""
51+
52+
4153
def _validate_lint_json(file: Path) -> str:
4254
try:
4355
content = file.read_text()

test/unit/lint_file_check_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ def test_check_lint_files(files, requested_files, expected, tmp_path):
5151
assert actual == expected
5252

5353

54+
@pytest.mark.parametrize(
55+
"file,expected",
56+
[
57+
("Your code has been rated at 7.85/10 (previous run: 7.83/10, +0.02", ""),
58+
(
59+
"test_text\nYour code has been rated at 7.85/10 (previous run: 7.83/10, +0.02\ntest_text",
60+
"",
61+
),
62+
("", "Could not find a rating"),
63+
("test_text", "Could not find a rating"),
64+
],
65+
)
66+
def test_check_lint_txt(file, expected, tmp_path):
67+
path = Path(tmp_path, ".lint.txt")
68+
path.touch()
69+
path.write_text(file)
70+
actual = _artifacts._validate_lint_txt(path)
71+
assert actual == expected
72+
73+
5474
@pytest.mark.parametrize(
5575
"attributes,expected",
5676
[

0 commit comments

Comments
 (0)