diff --git a/.github/.coveragerc b/.github/.coveragerc index 24a419ae0..cbdcccdac 100644 --- a/.github/.coveragerc +++ b/.github/.coveragerc @@ -2,4 +2,3 @@ omit = nf_core/*-template/* source = nf_core relative_files = True - diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index a29a6970e..2f48e67b5 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -151,12 +151,14 @@ jobs: uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 if: always() with: + include-hidden-files: true name: Snapshot Report ${{ env.test }} path: ./snapshot_report.html - name: Upload coverage uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 with: + include-hidden-files: true name: coverage_${{ env.test }} path: .coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index eac5adcdd..29400037c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Update python:3.12-slim Docker digest to 032c526 ([#3232](https://github.com/nf-core/tools/pull/3232)) - use correct `--profile` options for `nf-core subworkflows test` ([#3233](https://github.com/nf-core/tools/pull/3233)) - Update GitHub Actions ([#3237](https://github.com/nf-core/tools/pull/3237)) +- add `--dir/-d` option to schema commands ([#3247](https://github.com/nf-core/tools/pull/3247)) ## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11] diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 356b16f7f..bb4c5e708 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -4,6 +4,7 @@ import logging import os import sys +from pathlib import Path import rich import rich.console @@ -696,12 +697,24 @@ def pipeline_schema(): # nf-core pipelines schema validate @pipeline_schema.command("validate") +@click.option( + "-d", + "--dir", + "directory", + type=click.Path(exists=True), + default=".", + help=r"Pipeline directory. [dim]\[default: current working directory][/]", +) @click.argument("pipeline", required=True, metavar="") @click.argument("params", type=click.Path(exists=True), required=True, metavar="") -def command_pipelines_schema_validate(pipeline, params): +def command_pipelines_schema_validate(directory, pipeline, params): """ Validate a set of parameters against a pipeline schema. """ + if Path(directory, pipeline).exists(): + # this is a local pipeline + pipeline = Path(directory, pipeline) + pipelines_schema_validate(pipeline, params) @@ -740,23 +753,39 @@ def command_pipelines_schema_build(directory, no_prompts, web_only, url): # nf-core pipelines schema lint @pipeline_schema.command("lint") +@click.option( + "-d", + "--dir", + "directory", + type=click.Path(exists=True), + default=".", + help=r"Pipeline directory. [dim]\[default: current working directory][/]", +) @click.argument( - "schema_path", + "schema_file", type=click.Path(exists=True), default="nextflow_schema.json", metavar="", ) -def command_pipelines_schema_lint(schema_path): +def command_pipelines_schema_lint(directory, schema_file): """ Check that a given pipeline schema is valid. """ - pipelines_schema_lint(schema_path) + pipelines_schema_lint(Path(directory, schema_file)) # nf-core pipelines schema docs @pipeline_schema.command("docs") +@click.option( + "-d", + "--dir", + "directory", + type=click.Path(exists=True), + default=".", + help=r"Pipeline directory. [dim]\[default: current working directory][/]", +) @click.argument( - "schema_path", + "schema_file", type=click.Path(exists=True), default="nextflow_schema.json", required=False, @@ -785,11 +814,11 @@ def command_pipelines_schema_lint(schema_path): help="CSV list of columns to include in the parameter tables (parameter,description,type,default,required,hidden)", default="parameter,description,type,default,required,hidden", ) -def command_pipelines_schema_docs(schema_path, output, format, force, columns): +def command_pipelines_schema_docs(directory, schema_file, output, format, force, columns): """ Outputs parameter documentation for a pipeline schema. """ - pipelines_schema_docs(schema_path, output, format, force, columns) + pipelines_schema_docs(Path(directory, schema_file), output, format, force, columns) # nf-core modules subcommands diff --git a/tests/test_cli.py b/tests/test_cli.py index bea0223f0..8df1e210b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -358,7 +358,7 @@ def test_schema_lint(self, mock_get_schema_path): with open("nextflow_schema.json", "w") as f: f.write("{}") self.invoke_cli(cmd) - mock_get_schema_path.assert_called_with("nextflow_schema.json") + mock_get_schema_path.assert_called_with(Path("nextflow_schema.json")) @mock.patch("nf_core.pipelines.schema.PipelineSchema.get_schema_path") def test_schema_lint_filename(self, mock_get_schema_path): @@ -368,7 +368,7 @@ def test_schema_lint_filename(self, mock_get_schema_path): with open("some_other_filename", "w") as f: f.write("{}") self.invoke_cli(cmd) - mock_get_schema_path.assert_called_with("some_other_filename") + mock_get_schema_path.assert_called_with(Path("some_other_filename")) @mock.patch("nf_core.pipelines.create_logo.create_logo") def test_create_logo(self, mock_create_logo):