Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise report level for some shed linting #1111

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions planemo/shed_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ def lint_shed_yaml(realized_repository, lint_ctx):
path = realized_repository.real_path
shed_yaml = os.path.join(path, ".shed.yml")
if not os.path.exists(shed_yaml):
lint_ctx.info("No .shed.yml file found, skipping.")
lint_ctx.error("No .shed.yml file found, skipping.")
return
try:
with open(shed_yaml, "r") as fh:
yaml.safe_load(fh)
except Exception as e:
lint_ctx.warn("Failed to parse .shed.yml file [%s]" % unicodify(e))
lint_ctx.error("Failed to parse .shed.yml file [%s]" % unicodify(e))
return
lint_ctx.info(".shed.yml found and appears to be valid YAML.")
_lint_shed_contents(lint_ctx, realized_repository)
Expand All @@ -311,7 +311,9 @@ def _lint_if_present(key, func, *args):
if value is not None:
msg = func(value, *args)
if msg:
lint_ctx.warn(msg)
lint_ctx.error(msg)
else:
lint_ctx.error("Repository does not define: %s" % key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going against the original intent of the method _lint_if_present ? E.g. type is unrestricted by default, so probably no need to give an error if it's not present.

Copy link
Contributor Author

@bernt-matthias bernt-matthias Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can rename the function? My aim it to error in cases where shed_lint upload to the toolshed will error ... and I guess this is the case here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I see .. the type does not need to be defined in .shed.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also the case for name, owner, and categories?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name and owner can be specified on the command-line with e.g. shed_update. name defaults to the directory name if it's not specified in other ways. Categories I think are optional? I suppose these can all be warnings if not present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think name and owner should also be in the realized repo if given on the command line:

config = self._realize_config(name)
(but I do not understand the code for setting name ..)


_lint_if_present("owner", validate_repo_owner)
_lint_if_present("name", validate_repo_name)
Expand Down
6 changes: 6 additions & 0 deletions tests/data/repos/bad_invalid_tool_xml/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: cat
owner: iuc
description: cat1 tool
type: unrestricted
categories:
- Text Manipulation
3 changes: 3 additions & 0 deletions tests/data/repos/multi_repos_nested/cat1/.shed.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
name: cat1
owner: iuc
description: cat1 tool
type: unrestricted
categories:
- Text Manipulation
3 changes: 3 additions & 0 deletions tests/data/repos/multi_repos_nested/cat2/.shed.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
name: cat2
owner: iuc
description: cat2 tool
type: unrestricted
categories:
- Text Manipulation