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

Add fail-warned to pipeline linting workflow #1593

Merged
merged 10 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

### General

- 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

## [v2.4.1 - Cobolt Koala Patch](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16]
Expand Down
5 changes: 3 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,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 @@ -324,7 +325,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 @@ -27,7 +27,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 @@ -60,7 +68,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 @@ -165,7 +173,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 @@ -177,6 +185,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 @@ -311,7 +320,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