Skip to content

Commit

Permalink
Merge pull request #685 from wolfv/enable-v1-lint
Browse files Browse the repository at this point in the history
feat: enable v1 lint for PRs
  • Loading branch information
beckermr authored Sep 23, 2024
2 parents 44ca445 + 335873e commit 06c5b8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 54 deletions.
12 changes: 0 additions & 12 deletions conda_forge_webservices/linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ def lint_all_recipes(all_recipe_dir: Path, base_recipes: list[Path]) -> tuple[st
rel_path = recipe.relative_to(all_recipe_dir)
rel_pr_recipes.append(rel_path)

if recipe.name == "recipe.yaml":
# this is a v1 recipe and not yet handled
hint = "\nFor **{}**:\n\n{}".format(
rel_path,
"This is a v1 recipe and not yet lintable. " "We are working on it!",
)
messages.append(hint)
# also add it to hints so that the PR is marked as mixed
hints.append(hint)
hints_found = True
continue

try:
lints, hints = conda_smithy.lint_recipe.main(
str(recipe_dir), conda_forge=True, return_hints=True
Expand Down
58 changes: 17 additions & 41 deletions conda_forge_webservices/tests/linting/test_compute_lint_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import textwrap
from pathlib import Path

from inline_snapshot import snapshot

from conda_forge_webservices.linting import compute_lint_message, lint_all_recipes

Expand Down Expand Up @@ -66,21 +65,21 @@ def test_ok_recipe_above_good_recipe():
lint = compute_lint_message(
"conda-forge", "conda-forge-webservices", 54, set_pending_status=False
)
assert expected_message == lint["message"]
assert lint["message"].startswith(expected_message)


def test_ok_recipe_beside_good_recipe():
expected_message = textwrap.dedent("""
Hi! This is the friendly automated conda-forge-linting service.
I just wanted to let you know that I linted all conda-recipes in your PR (```recipe/meta.yaml```, ```recipes/recipe/meta.yaml```) and found it was in an excellent condition.
I just wanted to let you know that I linted all conda-recipes in your PR (```recipe/blah/meta.yaml```, ```recipe/meta.yaml```, ```recipes/recipe/meta.yaml```) and found it was in an excellent condition.
""") # noqa

lint = compute_lint_message(
"conda-forge", "conda-forge-webservices", 62, set_pending_status=False
)
assert expected_message == lint["message"]
assert lint["message"].startswith(expected_message)


def test_ok_recipe_above_ignored_good_recipe():
Expand All @@ -94,21 +93,21 @@ def test_ok_recipe_above_ignored_good_recipe():
lint = compute_lint_message(
"conda-forge", "conda-forge-webservices", 54, True, set_pending_status=False
)
assert expected_message == lint["message"]
assert lint["message"].startswith(expected_message)


def test_ok_recipe_beside_ignored_good_recipe():
expected_message = textwrap.dedent("""
Hi! This is the friendly automated conda-forge-linting service.
I just wanted to let you know that I linted all conda-recipes in your PR (```recipe/meta.yaml```) and found it was in an excellent condition.
I just wanted to let you know that I linted all conda-recipes in your PR (```recipe/blah/meta.yaml```, ```recipe/meta.yaml```) and found it was in an excellent condition.
""") # noqa

lint = compute_lint_message(
"conda-forge", "conda-forge-webservices", 62, True, set_pending_status=False
)
assert expected_message == lint["message"]
assert lint["message"].startswith(expected_message)


def test_conflict_ok_recipe():
Expand Down Expand Up @@ -146,25 +145,16 @@ def test_conflict_2_ok_recipe():


def test_v1_recipe():
expected_message = textwrap.dedent("""
Hi! This is the friendly automated conda-forge-linting service.
I just wanted to let you know that I linted all conda-recipes in your PR (```recipe/recipe.yaml```) and found it was in an excellent condition.
I do have some suggestions for making it better though...
For **recipe/recipe.yaml**:
This is a v1 recipe and not yet lintable. We are working on it!
""") # noqa

expected = (
"I wanted to let you know that I linted all conda-recipes in your PR "
"(```recipe/recipe.yaml```) and found some lint."
)
lint = lint_all_recipes(data_folder(), [])
lint = compute_lint_message(
"conda-forge", "conda-forge-webservices", 632, set_pending_status=False
)
assert lint is not None, lint["message"]
assert expected_message == lint["message"]
assert expected in lint["message"], lint["message"]


def test_bad_recipe():
Expand Down Expand Up @@ -252,23 +242,9 @@ def test_new_recipe(tmp_path):
recipe_file.parent.mkdir(parents=True)
shutil.copy(data_folder() / "recipe.yaml", recipe_file)

message = lint_all_recipes(Path(tmp_path), [])
assert message == snapshot(
(
"""\
Hi! This is the friendly automated conda-forge-linting service.
I just wanted to let you know that I linted all conda-recipes in your PR (```recipe/recipe.yaml```) and found it was in an excellent condition.
I do have some suggestions for making it better though...
For **recipe/recipe.yaml**:
This is a v1 recipe and not yet lintable. We are working on it!
""", # noqa
"mixed",
)
message, status = lint_all_recipes(Path(tmp_path), [])
assert status == "bad"
assert (
"I wanted to let you know that I linted all conda-recipes in your PR "
"(```recipe/recipe.yaml```) and found some lint." in message
)
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ dependencies:
- tqdm
# dev dependencies
- pytest <8.2.0
- inline-snapshot >=0.11

0 comments on commit 06c5b8a

Please sign in to comment.