Skip to content

Commit

Permalink
Merge pull request #2225 from nf-core/schema-lint-argument
Browse files Browse the repository at this point in the history
  • Loading branch information
sersorrel committed Mar 29, 2023
2 parents 8a9569b + b4e22d3 commit 14951aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
### Linting

- Read module lint configuration from `.nf-core.yml`, not `.nf-core-lint.yml` ([#2221](https://github.com/nf-core/tools/pull/2221))
- `nf-core schema lint` now defaults to linting `nextflow_schema.json` if no filename is provided ([#2225](https://github.com/nf-core/tools/pull/2225))

### Modules

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,13 @@ It's important to change the default value of a parameter in the `nextflow.confi
The pipeline schema is linted as part of the main pipeline `nf-core lint` command,
however sometimes it can be useful to quickly check the syntax of the JSONSchema without running a full lint run.

Usage is `nf-core schema lint <schema>`, eg:
Usage is `nf-core schema lint <schema>` (defaulting to `nextflow_schema.json`), eg:

<!-- RICH-CODEX
working_dir: tmp/nf-core-nextbigthing
-->

![`nf-core schema lint nextflow_schema.json`](docs/images/nf-core-schema-lint.svg)
![`nf-core schema lint`](docs/images/nf-core-schema-lint.svg)

## Bumping a pipeline version number

Expand Down
4 changes: 3 additions & 1 deletion nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ def build(dir, no_prompts, web_only, url):

# nf-core schema lint
@schema.command()
@click.argument("schema_path", type=click.Path(exists=True), required=True, metavar="<pipeline schema>")
@click.argument("schema_path", type=click.Path(exists=True), default="nextflow_schema.json", metavar="<pipeline schema>")
def lint(schema_path):
"""
Check that a given pipeline schema is valid.
Expand All @@ -1408,6 +1408,8 @@ def lint(schema_path):
This function runs as part of the nf-core lint command, this is a convenience
command that does just the schema linting nice and quickly.
If no schema path is provided, "nextflow_schema.json" will be used (if it exists).
"""
schema_obj = nf_core.schema.PipelineSchema()
try:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,20 @@ def test_lint_log_user_warning(self, mock_lint, mock_is_pipeline):
assert result.exit_code == 1
assert error_txt in captured_logs.output[-1]
assert captured_logs.records[-1].levelname == "ERROR"

@mock.patch("nf_core.schema.PipelineSchema.get_schema_path")
def test_schema_lint(self, mock_get_schema_path):
"""Test nf-core schema lint defaults to nextflow_schema.json"""
cmd = ["schema", "lint"]
result = self.invoke_cli(cmd)
assert mock_get_schema_path.called_with("nextflow_schema.json")
assert "nextflow_schema.json" in result.output

@mock.patch("nf_core.schema.PipelineSchema.get_schema_path")
def test_schema_lint_filename(self, mock_get_schema_path):
"""Test nf-core schema lint accepts a filename"""
cmd = ["schema", "lint", "some_other_filename"]
result = self.invoke_cli(cmd)
assert mock_get_schema_path.called_with("some_other_filename")
assert "some_other_filename" in result.output
assert "nextflow_schema.json" not in result.output

0 comments on commit 14951aa

Please sign in to comment.