Skip to content

Commit

Permalink
Merge branch 'dev' into pytest-requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianegli authored Jun 1, 2022
2 parents 57bde0f + dc4e8f1 commit 2117653
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/create-lint-wf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ jobs:
- name: nf-core modules update
run: nf-core --log-file log.txt modules update --dir nf-core-testpipeline --all --no-preview

# Remove TODO statements
- name: remove TODO
run: find nf-core-testpipeline -type f -exec sed -i '/TODO nf-core:/d' {} \;

# Run nf-core linting
- name: nf-core lint
run: nf-core --log-file log.txt lint --dir nf-core-testpipeline --fail-ignored
run: nf-core --log-file log.txt lint --dir nf-core-testpipeline --fail-ignored --fail-warned

# Run the other nf-core commands
- name: nf-core list
Expand All @@ -98,7 +102,7 @@ jobs:
run: nf-core --log-file log.txt bump-version --dir nf-core-testpipeline/ 1.1

- name: nf-core lint in release mode
run: nf-core --log-file log.txt lint --dir nf-core-testpipeline --fail-ignored --release
run: nf-core --log-file log.txt lint --dir nf-core-testpipeline --fail-ignored --fail-warned --release

- name: nf-core modules install
run: nf-core --log-file log.txt modules install fastqc --dir nf-core-testpipeline/ --force
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
### General

- Updated the package requirements to prevent defunct installations of nf-core [#1620](https://github.com/nf-core/tools/pull/1620)
- Add `--fail-warned` flag to `nf-core lint` to make warnings fail [#1593](https://github.com/nf-core/tools/pull/1593)
- Add `--fail-warned` flag to pipeline linting workflow [#1593](https://github.com/nf-core/tools/pull/1593)

### Modules

Expand Down
5 changes: 3 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ def create(name, description, author, version, no_git, force, outdir):
@click.option("-k", "--key", type=str, metavar="<test>", multiple=True, help="Run only these lint tests")
@click.option("-p", "--show-passed", is_flag=True, help="Show passing tests on the command line")
@click.option("-i", "--fail-ignored", is_flag=True, help="Convert ignored tests to failures")
@click.option("-w", "--fail-warned", is_flag=True, help="Convert warn tests to failures")
@click.option("--markdown", type=str, metavar="<filename>", help="File to write linting results to (Markdown)")
@click.option("--json", type=str, metavar="<filename>", help="File to write linting results to (JSON)")
def lint(dir, release, fix, key, show_passed, fail_ignored, markdown, json):
def lint(dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdown, json):
"""
Check pipeline code against nf-core guidelines.
Expand All @@ -325,7 +326,7 @@ def lint(dir, release, fix, key, show_passed, fail_ignored, markdown, json):
# Run the lint tests!
try:
lint_obj, module_lint_obj = nf_core.lint.run_linting(
dir, release, fix, key, show_passed, fail_ignored, markdown, json
dir, release, fix, key, show_passed, fail_ignored, fail_warned, markdown, json
)
if len(lint_obj.failed) + len(module_lint_obj.failed) > 0:
sys.exit(1)
Expand Down
20 changes: 16 additions & 4 deletions nf_core/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@


def run_linting(
pipeline_dir, release_mode=False, fix=(), key=(), show_passed=False, fail_ignored=False, md_fn=None, json_fn=None
pipeline_dir,
release_mode=False,
fix=(),
key=(),
show_passed=False,
fail_ignored=False,
fail_warned=False,
md_fn=None,
json_fn=None,
):
"""Runs all nf-core linting checks on a given Nextflow pipeline project
in either `release` mode or `normal` mode (default). Returns an object
Expand Down Expand Up @@ -62,7 +70,7 @@ def run_linting(
# Create the lint object
pipeline_keys = list(set(key).intersection(set(PipelineLint._get_all_lint_tests(release_mode)))) if key else []

lint_obj = PipelineLint(pipeline_dir, release_mode, fix, pipeline_keys, fail_ignored)
lint_obj = PipelineLint(pipeline_dir, release_mode, fix, pipeline_keys, fail_ignored, fail_warned)

# Load the various pipeline configs
lint_obj._load_lint_config()
Expand Down Expand Up @@ -167,7 +175,7 @@ class PipelineLint(nf_core.utils.Pipeline):
from .template_strings import template_strings
from .version_consistency import version_consistency

def __init__(self, wf_path, release_mode=False, fix=(), key=(), fail_ignored=False):
def __init__(self, wf_path, release_mode=False, fix=(), key=(), fail_ignored=False, fail_warned=False):
"""Initialise linting object"""

# Initialise the parent object
Expand All @@ -179,6 +187,7 @@ def __init__(self, wf_path, release_mode=False, fix=(), key=(), fail_ignored=Fal
self.lint_config = {}
self.release_mode = release_mode
self.fail_ignored = fail_ignored
self.fail_warned = fail_warned
self.failed = []
self.ignored = []
self.fixed = []
Expand Down Expand Up @@ -314,7 +323,10 @@ def _lint_pipeline(self):
for test in test_results.get("fixed", []):
self.fixed.append((test_name, test))
for test in test_results.get("warned", []):
self.warned.append((test_name, test))
if self.fail_warned:
self.failed.append((test_name, test))
else:
self.warned.append((test_name, test))
for test in test_results.get("failed", []):
self.failed.append((test_name, test))
if test_results.get("could_fix", False):
Expand Down

0 comments on commit 2117653

Please sign in to comment.