Repository navigation
Expand file tree
/
Copy pathBUILD.bazel
More file actions
158 lines (145 loc) · 5.04 KB
/
Copy pathBUILD.bazel
File metadata and controls
158 lines (145 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 Mike Mol
# ⚑ MIRRORS //witness:BUILD.bazel TARGET FOR TARGET, which mirrors //pathsforward and //ratchet.
# The rationale for each shape lives there; this file says only where it differs.
# A library only, for now: the ledger's CLI (finding_cli) arrives last in row 6, and with it the
# one place a working directory is resolved.
load("@mikemol_check_mutants//:defs.bzl", "mutants_sharded")
load("@ledger_dev//:requirements.bzl", dev_all_requirements = "all_requirements", dev_requirement = "requirement")
load("@mikemol_rules_py//:dist.bzl", "dist_checks")
load("@mikemol_rules_py//:venv.bzl", "venv_from_hub")
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
exports_files([
# ⚑ EXPORTED FOR `//hooks:test_bar_fires`, which globs `*/pyproject.toml` for the population.
"pyproject.toml",
"requirements.txt",
"requirements-dev.txt",
"uv.lock",
])
py_library(
name = "ledger",
srcs = glob(["src/mikemol/ledger/**/*.py"]),
data = glob(["src/mikemol/ledger/py.typed"], allow_empty = True),
imports = ["src"],
# ⚑ THE SIBLING EDGE (W566 variant c): declared in pyproject.toml for uv, carried here for Bazel.
deps = ["//witness:witness"],
visibility = ["//visibility:public"],
)
# ⚑⚑⚑ ONE TARGET PER TEST MODULE, AND EACH IS A WITNESS. All fixtures are synthetic and inline;
# the witness commands run under `tmp_path`, never against this tree.
[
py_test(
name = src.removeprefix("tests/").removesuffix(".py"),
srcs = [src, "@mikemol_rules_py//:pytest_main.py"] + glob(["tests/conftest.py"], allow_empty = True),
main = "@mikemol_rules_py//:pytest_main.py",
args = [
"$(location " + src + ")",
"-q",
"--strict-markers",
"--strict-config",
"-o",
"faulthandler_timeout=60",
"-c",
"$(location pyproject.toml)",
],
data = ["pyproject.toml"],
size = "small",
deps = [
":ledger",
"//witness:witness",
dev_requirement("pytest"),
],
imports = ["src"],
# ⚑ TWO SOURCE ROOTS: legacy implicit `__init__.py` would make `mikemol` a regular package
# from the first root and shadow the namespace (W566).
legacy_create_init = 0,
)
for src in glob(["tests/test_*.py"])
]
exports_files(["BUILD.bazel"])
sh_test(
name = "ruff",
srcs = ["@mikemol_check_ruff//:ruff_check.sh"],
args = [
"$(location @mikemol_check_ruff//:bin)",
"$(location :pyproject.toml)",
] + ["$(location " + f + ")" for f in glob(["src/**/*.py", "tests/**/*.py"])],
data = [
"pyproject.toml",
"@mikemol_check_ruff//:bin",
] + glob(["src/**/*.py", "tests/**/*.py"]),
size = "small",
)
# ⚑ THE BASELINE WAS MINTED EMPTY: the distribution enters clean under preview, so the ratchet
# can only hold it there.
sh_test(
name = "ratchet",
srcs = ["@mikemol_check_ratchet//:ratchet_check.sh"],
args = [
"$(location //ratchet:ratchet_cli)",
"$(location @mikemol_check_ruff//:bin)",
"$(location :pyproject.toml)",
],
data = [
"pyproject.toml",
"ratchet-preview.txt",
"//ratchet:ratchet_cli",
"@mikemol_check_ruff//:bin",
] + glob(["src/**/*.py", "tests/**/*.py"]),
size = "small",
)
mutants_sharded(
name = "mutants",
shards = 1,
cpus = 6,
srcs = ["@mikemol_check_mutants//:mutate_check.sh"],
args = [
"$(location :pyproject.toml)",
"$(location @mikemol_check_mutants//:mutate_runner.py)",
],
data = [
"pyproject.toml",
# W629: the defect classes this distribution declares, planted one at a time by the runner.
"mutants.regex",
":.venv",
"//fence:fence",
"//mutation:mutation",
"@mikemol_check_mutants//:mutate_runner.py",
] + glob(["src/**/*.py", "tests/**/*.py"]),
size = "medium",
)
py_binary(
name = "mypy_runner",
srcs = ["@mikemol_check_mypy//:mypy_runner.py"],
main = "@mikemol_check_mypy//:mypy_runner.py",
deps = [
"//witness:witness",
dev_requirement("mypy"),
dev_requirement("pytest"),
],
)
sh_test(
name = "mypy",
srcs = ["@mikemol_check_mypy//:mypy_check.sh"],
args = [
"$(location :mypy_runner)",
"$(location :pyproject.toml)",
],
data = [
"pyproject.toml",
":mypy_runner",
] + glob(["src/**/*.py", "tests/**/*.py", "stubs/**"], allow_empty = True),
size = "small",
# ⚑ A GENEROUS TIMEOUT, NOT A TIGHT ONE (operator, 2026-09-24: "I hate wallclock-sensitive
# things"), as every sibling's mypy target.
timeout = "long",
)
venv_from_hub(
name = ".venv",
hub_requirements = dev_all_requirements,
python_version = "3.13.13",
python_version_short = "3.13",
srcs = glob(["src/mikemol/ledger/**"]) + ["//witness:witness"],
)
# W376: this distribution's :venv (W342) and :suite (W362), declared together.
dist_checks()