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

Modules: Add --profile parameter to nf-test command #2767

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Modules

- Handle dirty local module repos by force checkout of commits and branches if needed ([#2734](https://github.com/nf-core/tools/pull/2734))
- Add `--profile` parameter to nf-test command ([#2767](https://github.com/nf-core/tools/pull/2767))

### General

Expand Down
18 changes: 16 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,13 @@ def create_module(
default=False,
help="Run tests only once. Don't check snapshot stability",
)
def test_module(ctx, tool, dir, no_prompts, update, once):
@click.option(
"--profile",
type=click.Choice(["docker", "singularity", "conda"]),
default=None,
help="Run tests with a specific profile",
)
def test_module(ctx, tool, dir, no_prompts, update, once, profile):
"""
Run nf-test for a module.

Expand All @@ -1153,6 +1159,7 @@ def test_module(ctx, tool, dir, no_prompts, update, once):
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
verbose=ctx.obj["verbose"],
profile=profile,
)
module_tester.run()
except (UserWarning, LookupError) as e:
Expand Down Expand Up @@ -1398,7 +1405,13 @@ def create_subworkflow(ctx, subworkflow, dir, author, force, migrate_pytest):
default=False,
help="Run tests only once. Don't check snapshot stability",
)
def test_subworkflow(ctx, subworkflow, dir, no_prompts, update, once):
@click.option(
"--profile",
type=click.Choice(["none", "singularity"]),
default=None,
help="Run tests with a specific profile",
)
def test_subworkflow(ctx, subworkflow, dir, no_prompts, update, once, profile):
"""
Run nf-test for a subworkflow.

Expand All @@ -1417,6 +1430,7 @@ def test_subworkflow(ctx, subworkflow, dir, no_prompts, update, once):
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
verbose=ctx.obj["verbose"],
profile=profile,
)
sw_tester.run()
except (UserWarning, LookupError) as e:
Expand Down
7 changes: 6 additions & 1 deletion nf_core/components/components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class ComponentsTest(ComponentCommand): # type: ignore[misc]
flag indicating if the existing snapshot should be updated
once : bool
flag indicating if the test should be run only once
profile : str
container software to use (docker, singularity or conda)

Methods
-------
Expand All @@ -72,6 +74,7 @@ def __init__(
verbose: bool = False,
update: bool = False,
once: bool = False,
profile: Optional[str] = None,
):
super().__init__(component_type, directory, remote_url, branch, no_prompts=no_prompts)
self.component_name = component_name
Expand All @@ -82,6 +85,7 @@ def __init__(
self.obsolete_snapshots: bool = False
self.update = update
self.once = once
self.profile = profile

def run(self) -> None:
"""Run build steps"""
Expand Down Expand Up @@ -190,10 +194,11 @@ def generate_snapshot(self) -> bool:
update = "--update-snapshot" if self.update else ""
self.update = False # reset self.update to False to test if the new snapshot is stable
tag = f"subworkflows/{self.component_name}" if self.component_type == "subworkflows" else self.component_name
profile = self.profile if self.profile else os.environ["PROFILE"]

result = nf_core.utils.run_cmd(
"nf-test",
f"test --tag {tag} --profile {os.environ['PROFILE']} {verbose} {update}",
f"test --tag {tag} --profile {profile} {verbose} {update}",
)
if result is not None:
nftest_out, nftest_err = result
Expand Down
Loading