Skip to content

Commit

Permalink
Merge pull request #2316 from mirpedrol/test-git-aware
Browse files Browse the repository at this point in the history
add docs to commit new files before pytest
  • Loading branch information
mirpedrol authored Jun 16, 2023
2 parents c96c1d1 + b4e8f82 commit 37c3d06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,8 @@ before_command: sed 's/1.13a/1.10/g' modules/multiqc/main.nf > modules/multiqc/m

To run unit tests of a module that you have installed or the test created by the command [`nf-core modules create-test-yml`](#create-a-module-test-config-file), you can use `nf-core modules test` command. This command runs the tests specified in `modules/tests/software/<tool>/<subtool>/test.yml` file using [pytest](https://pytest-workflow.readthedocs.io/en/stable/).

> This command uses the pytest argument `--git-aware` to avoid copying the whole `.git` directory and files ignored by `git`. This means that it will only include files listed by `git ls-files`. Remember to **commit your changes** after adding a new module to add the new files to your git index.

You can specify the module name in the form TOOL/SUBTOOL in command line or provide it later by prompts.

<!-- RICH-CODEX
Expand Down Expand Up @@ -1199,6 +1201,8 @@ extra_env:

To run unit tests of a subworkflow that you have installed or the test created by the command [`nf-core subworkflow create-test-yml`](#create-a-subworkflow-test-config-file), you can use `nf-core subworkflows test` command. This command runs the tests specified in `tests/subworkflows/<subworkflow_name>/test.yml` file using [pytest](https://pytest-workflow.readthedocs.io/en/stable/).

> This command uses the pytest argument `--git-aware` to avoid copying the whole `.git` directory and files ignored by `git`. This means that it will only include files listed by `git ls-files`. Remember to **commit your changes** after adding a new subworkflow to add the new files to your git index.

You can specify the subworkflow name in the form TOOL/SUBTOOL in command line or provide it later by prompts.

<!-- RICH-CODEX
Expand Down
9 changes: 9 additions & 0 deletions nf_core/components/components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import questionary
import rich
from git import InvalidGitRepositoryError, Repo

import nf_core.modules.modules_utils
import nf_core.utils
Expand Down Expand Up @@ -179,6 +180,14 @@ def _run_pytests(self):
console = rich.console.Console()
console.rule(self.component_name, style="black")

# Check uncommitted changed
try:
repo = Repo(self.dir)
if repo.is_dirty():
log.warning("You have uncommitted changes. Make sure to commit last changes before running the tests.")
except InvalidGitRepositoryError:
pass

# Set pytest arguments
tag = self.component_name
if self.component_type == "subworkflows":
Expand Down

0 comments on commit 37c3d06

Please sign in to comment.