Skip to content

Commit

Permalink
Merge pull request nf-core#3005 from nvnieuwk/add-org-to-tag
Browse files Browse the repository at this point in the history
Add organization to `main.nf.test` tag instead of using `nfcore`
  • Loading branch information
nvnieuwk authored May 28, 2024
2 parents 2f0f4a0 + a4ecb70 commit d0b7594
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

### Components

- The `modules_nfcore` tag in the `main.nf.test` file of modules/subworkflows now displays the organization name in custom modules repositories ([#3005](https://github.com/nf-core/tools/pull/3005))

### General

- Update pre-commit hook astral-sh/ruff-pre-commit to v0.4.4 ([#2974](https://github.com/nf-core/tools/pull/2974))
Expand Down
4 changes: 4 additions & 0 deletions nf_core/components/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def create(self):
if self.component_type == "modules":
self._get_module_structure_components()

# Add a valid organization name for nf-test tags
not_alphabet = re.compile(r"[^a-zA-Z]")
self.org_alphabet = not_alphabet.sub("", self.org)

# Create component template with jinja2
self._render_template()
log.info(f"Created component template: '{self.component_name}'")
Expand Down
2 changes: 1 addition & 1 deletion nf_core/module-template/tests/main.nf.test.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nextflow_process {
process "{{ component_name_underscore|upper }}"

tag "modules"
tag "modules_nfcore"
tag "modules_{{ org_alphabet }}"
{%- if subtool %}
tag "{{ component }}"
{%- endif %}
Expand Down
6 changes: 5 additions & 1 deletion nf_core/modules/lint/module_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
import logging
import re
from pathlib import Path

import yaml
Expand Down Expand Up @@ -137,7 +138,10 @@ def module_tests(_, module: NFCoreComponent):
)
# Verify that tags are correct.
main_nf_tags = module._get_main_nf_tags(module.nftest_main_nf)
required_tags = ["modules", "modules_nfcore", module.component_name]
not_alphabet = re.compile(r"[^a-zA-Z]")
org_alp = not_alphabet.sub("", module.org)
org_alphabet = org_alp if org_alp != "" else "nfcore"
required_tags = ["modules", f"modules_{org_alphabet}", module.component_name]
if module.component_name.count("/") == 1:
required_tags.append(module.component_name.split("/")[0])
chained_components_tags = module._get_included_components_in_chained_tests(module.nftest_main_nf)
Expand Down
2 changes: 1 addition & 1 deletion nf_core/subworkflow-template/tests/main.nf.test.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nextflow_workflow {
workflow "{{ component_name_underscore|upper }}"

tag "subworkflows"
tag "subworkflows_nfcore"
tag "subworkflows_{{ org_alphabet }}"
tag "subworkflows/{{ component_name }}"
// TODO nf-core: Add tags for all modules used within this subworkflow. Example:
tag "samtools"
Expand Down
6 changes: 5 additions & 1 deletion nf_core/subworkflows/lint/subworkflow_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
import logging
import re
from pathlib import Path

import yaml
Expand Down Expand Up @@ -144,10 +145,13 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent):
)
# Verify that tags are correct.
main_nf_tags = subworkflow._get_main_nf_tags(subworkflow.nftest_main_nf)
not_alphabet = re.compile(r"[^a-zA-Z]")
org_alp = not_alphabet.sub("", subworkflow.org)
org_alphabet = org_alp if org_alp != "" else "nfcore"
required_tags = [
"subworkflows",
f"subworkflows/{subworkflow.component_name}",
"subworkflows_nfcore",
f"subworkflows_{org_alphabet}",
]
included_components = []
if subworkflow.main_nf.is_file():
Expand Down

0 comments on commit d0b7594

Please sign in to comment.