Skip to content

Commit

Permalink
Merge pull request #2278 from adamrtalbot/catch_modules_with_quay.io
Browse files Browse the repository at this point in the history
Linting error if quay.io found in biocontainer name
  • Loading branch information
adamrtalbot authored May 9, 2023
2 parents 12404d2 + 00bd8ef commit 14b0736
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### Linting

- Warn if container access is denied ([#2270](https://github.com/nf-core/tools/pull/2270))
- Error if module container specification has quay.io as prefix when it shouldn't have ([#2278])(https://github.com/nf-core/tools/pull/2278/files)
- Detect if container is 'simple name' and try to contact quay.io server by default ([#2281](https://github.com/nf-core/tools/pull/2281))

### Modules
Expand Down
47 changes: 30 additions & 17 deletions nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,7 @@ def check_process_section(self, lines, fix_version, progress_bar):
self.failed.append(("singularity_tag", "Unable to parse singularity tag", self.main_nf))
singularity_tag = None
url = urlparse(l.split("'")[0])
# lint double quotes
if l.count('"') > 2:
self.failed.append(
(
"container_links",
"Too many double quotes found when specifying singularity container",
self.main_nf,
)
)

if _container_type(l) == "docker":
# e.g. "quay.io/biocontainers/krona:2.7.1--pl526_5' }" -> 2.7.1--pl526_5
# e.g. "biocontainers/biocontainers:v1.2.0_cv1' }" -> v1.2.0_cv1
Expand All @@ -289,23 +281,44 @@ def check_process_section(self, lines, fix_version, progress_bar):
self.passed.append(("docker_tag", f"Found docker tag: {docker_tag}", self.main_nf))
else:
self.failed.append(("docker_tag", "Unable to parse docker tag", self.main_nf))
docker_tag = None
docker_tag = NoneD
if l.startswith("quay.io/"):
l_stripped = re.sub("\W+$", "", l)
self.failed.append(
(
"container_links",
f"{l_stripped} container name found, please use just 'organisation/container:tag' instead.",
self.main_nf,
)
)
else:
self.passed.append(("container_links", f"Container prefix is correct", self.main_nf))

# Guess if container name is simple one (e.g. nfcore/ubuntu:20.04)
# If so, add quay.io as default container prefix
if l.count("/") == 1 and l.count(":") == 1:
l = "quay.io/" + l
url = urlparse(l.split("'")[0])
# lint double quotes
if l.count('"') > 2:
self.failed.append(
("container_links", "Too many double quotes found when specifying docker container", self.main_nf)
)

# lint double quotes
if l.startswith("container"):
if l.startswith("container") or _container_type(l) == "docker" or _container_type(l) == "singularity":
if l.count('"') > 2:
self.failed.append(
("container_links", "Too many double quotes found when specifying containers", self.main_nf)
(
"container_links",
f"Too many double quotes found when specifying container: {l.lstrip('container ')}",
self.main_nf,
)
)
else:
self.passed.append(
(
"container_links",
f"Correct number of double quotes found when specifying container: {l.lstrip('container ')}",
self.main_nf,
)
)

# lint more than one container in the same line
if ("https://containers" in l or "https://depot" in l) and ("biocontainers/" in l or "quay.io/" in l):
self.warned.append(
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""

ORG_SHA = "002623ccc88a3b0cb302c7d8f13792a95354d9f2"
CORRECT_SHA = "0245a9277d51a47c8aa68d264d294cf45312fab8"
CORRECT_SHA = "1dff30bfca2d98eb7ac7b09269a15e822451d99f"
SUCCEED_SHA = "ba15c20c032c549d77c5773659f19c2927daf48e"
FAIL_SHA = "67b642d4471c4005220a342cad3818d5ba2b5a73"
BISMARK_ALIGN = "bismark/align"
Expand Down

0 comments on commit 14b0736

Please sign in to comment.