Skip to content

Commit b1eb8a7

Browse files
authored
feat: record errors when linting (#17)
* feat: record errors when linting * doc: updated doc string * chore: roll back
1 parent 77d3426 commit b1eb8a7

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

.github/workflows/tests.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1
2828
with:
2929
environment-file: environment.yml
30+
micromamba-version: "1.5.10-0"
3031

3132
- name: configure conda and install code
3233
run: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,4 @@ cython_debug/
164164
conda_forge_feedstock_ops/_version.py
165165
**/.DS_Store
166166
.ruff_cache/*
167+
.ruff_cache/

conda_forge_feedstock_ops/__main__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ def _lint():
279279
"copied container feedstock dir %s: %s", fs_dir, os.listdir(fs_dir)
280280
)
281281

282-
lints, hints = lint(fs_dir, use_container=False)
282+
lints, hints, errors = lint(fs_dir, use_container=False)
283283

284-
return {"lints": lints, "hints": hints}
284+
return {"lints": lints, "hints": hints, "errors": errors}
285285

286286

287287
@click.group()

conda_forge_feedstock_ops/lint.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def lint(feedstock_dir, use_container=None):
3737
Dictionary mapping relative recipe path to its lints.
3838
hints : dict
3939
Dictionary mapping relative recipe path to its hints.
40+
errors : dict
41+
Dictionary mapping relative recipe path to whether an error occurred
42+
while linting the recipe.
4043
"""
4144
if should_use_container(use_container=use_container):
4245
return _lint_containerized(feedstock_dir)
@@ -77,7 +80,7 @@ def _lint_containerized(feedstock_dir):
7780
# in the container. So we remove the subdir we made before cleaning up.
7881
shutil.rmtree(tmpdir)
7982

80-
return data["lints"], data["hints"]
83+
return data["lints"], data["hints"], data["errors"]
8184

8285

8386
#############################################################
@@ -97,19 +100,27 @@ def _lint_local(feedstock_dir):
97100

98101
lints = defaultdict(list)
99102
hints = defaultdict(list)
103+
errors = {}
100104

101105
for recipe in recipes:
102106
recipe_dir = recipe.parent
103107
rel_path = str(recipe.relative_to(feedstock_dir))
104108

105-
_lints, _hints = conda_smithy.lint_recipe.main(
106-
str(recipe_dir), conda_forge=True, return_hints=True
107-
)
109+
try:
110+
_lints, _hints = conda_smithy.lint_recipe.main(
111+
str(recipe_dir), conda_forge=True, return_hints=True
112+
)
113+
_error = False
114+
except Exception:
115+
_lints = []
116+
_hints = []
117+
_error = True
108118

109119
lints[rel_path] = _lints
110120
hints[rel_path] = _hints
121+
errors[rel_path] = _error
111122

112-
return dict(lints), dict(hints)
123+
return dict(lints), dict(hints), errors
113124

114125

115126
# end of code from conda-forge-webservices w/ modifications

tests/test_lint.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,30 @@
77

88
def test_lint_local():
99
feedstock_dir = os.path.join(os.path.dirname(__file__), "data")
10-
lints, hints = lint(
10+
lints, hints, errors = lint(
1111
feedstock_dir,
1212
use_container=False,
1313
)
1414
assert len(hints) + len(lints) > 0
15-
all_keys = set(lints.keys()) | set(hints.keys())
15+
all_keys = set(lints.keys()) | set(hints.keys()) | set(errors.keys())
1616
assert all_keys == {
1717
"llvmdev-feedstock/recipe/meta.yaml",
1818
"ngmix-blah/recipe/meta.yaml",
1919
}
20+
assert not any(err for err in errors.values())
2021

2122

2223
@skipif_no_containers
2324
def test_lint_container(use_containers):
2425
feedstock_dir = os.path.join(os.path.dirname(__file__), "data")
25-
lints, hints = lint(
26+
lints, hints, errors = lint(
2627
feedstock_dir,
2728
use_container=False,
2829
)
2930
assert len(hints) + len(lints) > 0
30-
all_keys = set(lints.keys()) | set(hints.keys())
31+
all_keys = set(lints.keys()) | set(hints.keys()) | set(errors.keys())
3132
assert all_keys == {
3233
"llvmdev-feedstock/recipe/meta.yaml",
3334
"ngmix-blah/recipe/meta.yaml",
3435
}
36+
assert not any(err for err in errors.values())

0 commit comments

Comments
 (0)