Skip to content

Commit

Permalink
Merge pull request #460 from apeltzer/singularity-lint
Browse files Browse the repository at this point in the history
Check for singularity file and raise error if found
  • Loading branch information
apeltzer authored Nov 25, 2019
2 parents 360825b + fe41b21 commit 5d0c5b7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Updated Blacklist of synced pipelines
* Ignore pre-releases in `nf-core list`
* Lint for `Singularity` file [and remove it](https://github.com/nf-core/tools/issues/458)

### Linting

Expand Down
4 changes: 4 additions & 0 deletions docs/lint_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,7 @@ The nf-core workflow template contains a number of comment lines with the follow
```

This lint test runs through all files in the pipeline and searches for these lines.

## Error #11 - Singularity file found ##{#11}

As we are relying on [Docker Hub](https://https://hub.docker.com/) instead of Singularity and all containers are automatically pulled from there, repositories should not have a `Singularity` file present.
7 changes: 7 additions & 0 deletions nf_core/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def lint_pipeline(self, release_mode=False):
'check_files_exist',
'check_licence',
'check_docker',
'check_singularity',
'check_nextflow_config',
'check_ci_config',
'check_readme',
Expand Down Expand Up @@ -277,6 +278,12 @@ def check_docker(self):

self.failed.append((2, "Dockerfile check failed"))

def check_singularity(self):
"""Checks whether a Singularity file exists and warns to remove that file then."""
fn = os.path.join(self.path, "Singularity")
if(os.path.exists(fn)):
self.failed.append((11, "Singularity file exists"))

def check_licence(self):
"""Checks licence file is MIT.
Expand Down
1 change: 1 addition & 0 deletions tests/lint_examples/failing_example/Singularity
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nothing to be found here
7 changes: 7 additions & 0 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ def test_mit_license_example_with_failed(self):
bad_lint_obj.check_licence()
expectations = {"failed": 1, "warned": 0, "passed": 0}
self.assess_lint_status(bad_lint_obj, **expectations)

def test_singularity_with_failed(self):
"""Tests that Singularity file doesn't exist"""
bad_lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE)
bad_lint_obj.check_singularity()
expectations = {"failed": 1, "warned": 0, "passed": 0}
self.assess_lint_status(bad_lint_obj, **expectations)

def test_config_variable_example_pass(self):
"""Tests that config variable existence test works with good pipeline example"""
Expand Down

0 comments on commit 5d0c5b7

Please sign in to comment.