Skip to content

Commit c8448aa

Browse files
Migrate architecture checks to pytest marker workflow
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 48d3df9 commit c8448aa

12 files changed

+48
-13
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ make test
6060
make architecture-check
6161
```
6262

63+
This runs `pytest -m architecture` against guardrail suites.
64+
6365
### Full local CI parity
6466

6567
```bash

Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ test:
1818
$(PYTHON) -m pytest -q
1919

2020
architecture-check:
21-
$(PYTHON) -m pytest -q \
22-
tests/test_guardrail_ast_utils.py \
23-
tests/test_manager_model_dump_usage.py \
24-
tests/test_mapping_reader_usage.py \
25-
tests/test_mapping_keys_access_usage.py \
26-
tests/test_tool_mapping_reader_usage.py \
27-
tests/test_display_helper_usage.py \
28-
tests/test_ci_workflow_quality_gates.py \
29-
tests/test_makefile_quality_targets.py
21+
$(PYTHON) -m pytest -q -m architecture
3022

3123
compile:
3224
$(PYTHON) -m compileall -q hyperbrowser examples tests

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ make ci
249249
```
250250

251251
`make architecture-check` runs fast architecture guard suites
252-
(shared-helper adoption and quality-gate workflow checks).
252+
(shared-helper adoption and quality-gate workflow checks) via `pytest -m architecture`.
253253

254254
Contributor workflow details are available in [CONTRIBUTING.md](CONTRIBUTING.md).
255255

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ pytest = "^8.0.0"
2222

2323
[tool.pytest.ini_options]
2424
testpaths = ["tests"]
25+
markers = [
26+
"architecture: architecture/guardrail quality gate tests",
27+
]
2528

2629

2730
[build-system]

tests/test_ci_workflow_quality_gates.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from pathlib import Path
22

3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
37

48
def test_ci_workflow_includes_architecture_guard_job():
59
ci_workflow = Path(".github/workflows/ci.yml").read_text(encoding="utf-8")

tests/test_display_helper_usage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from pathlib import Path
22

3+
import pytest
4+
35
from tests.guardrail_ast_utils import collect_name_call_lines, read_module_ast
46

7+
pytestmark = pytest.mark.architecture
8+
59
HYPERBROWSER_ROOT = Path(__file__).resolve().parents[1] / "hyperbrowser"
610
ALLOWED_NORMALIZE_DISPLAY_CALL_FILES = {
711
Path("display_utils.py"),
@@ -13,6 +17,7 @@
1317
def _python_files() -> list[Path]:
1418
return sorted(HYPERBROWSER_ROOT.rglob("*.py"))
1519

20+
1621
def test_normalize_display_text_usage_is_centralized():
1722
violations: list[str] = []
1823

tests/test_guardrail_ast_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import ast
22

3+
import pytest
4+
35
from tests.guardrail_ast_utils import (
46
collect_attribute_call_lines,
57
collect_list_keys_call_lines,
68
collect_name_call_lines,
79
)
810

11+
pytestmark = pytest.mark.architecture
12+
913

1014
SAMPLE_MODULE = ast.parse(
1115
"""
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
from pathlib import Path
22

3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
37

48
def test_makefile_defines_architecture_check_target():
59
makefile_text = Path("Makefile").read_text(encoding="utf-8")
610

711
assert "architecture-check:" in makefile_text
8-
assert "tests/test_manager_model_dump_usage.py" in makefile_text
9-
assert "tests/test_ci_workflow_quality_gates.py" in makefile_text
12+
assert "-m architecture" in makefile_text
1013

1114

1215
def test_makefile_check_target_includes_architecture_checks():
1316
makefile_text = Path("Makefile").read_text(encoding="utf-8")
1417

15-
assert "check: lint format-check compile architecture-check test build" in makefile_text
18+
assert (
19+
"check: lint format-check compile architecture-check test build"
20+
in makefile_text
21+
)

tests/test_manager_model_dump_usage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from pathlib import Path
22

3+
import pytest
4+
35
from tests.guardrail_ast_utils import collect_attribute_call_lines, read_module_ast
46

7+
pytestmark = pytest.mark.architecture
8+
59
MANAGERS_DIR = (
610
Path(__file__).resolve().parents[1] / "hyperbrowser" / "client" / "managers"
711
)

tests/test_mapping_keys_access_usage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from pathlib import Path
22

3+
import pytest
4+
35
from tests.guardrail_ast_utils import collect_list_keys_call_lines, read_module_ast
46

7+
pytestmark = pytest.mark.architecture
8+
59
HYPERBROWSER_ROOT = Path(__file__).resolve().parents[1] / "hyperbrowser"
610
ALLOWED_KEYS_LIST_FILES = {
711
Path("mapping_utils.py"),
@@ -12,6 +16,7 @@
1216
def _python_files() -> list[Path]:
1317
return sorted(HYPERBROWSER_ROOT.rglob("*.py"))
1418

19+
1520
def test_mapping_key_iteration_is_centralized():
1621
violations: list[str] = []
1722

0 commit comments

Comments
 (0)