Skip to content

Pipeline version consistency check #3643

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

Merged
merged 15 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from 12 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
11 changes: 8 additions & 3 deletions nf_core/pipelines/lint/version_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ def version_consistency(self):
.. note:: This test only runs when the ``--release`` flag is set for ``nf-core pipelines lint``,
or ``$GITHUB_REF`` is equal to ``main``.

This lint fetches the pipeline version number from three possible locations:
This lint fetches the pipeline version number from four possible locations:

* The pipeline config, ``manifest.version``
* The docker container in the pipeline config, ``process.container``

Some pipelines may not have this set on a pipeline level. If it is not found, it is ignored.

* ``$GITHUB_REF``, if it looks like a release tag (``refs/tags/<something>``)
* The YAML file .nf-core.yml

The test then checks that:

Expand Down Expand Up @@ -45,6 +46,10 @@ def version_consistency(self):
):
versions["GITHUB_REF"] = os.path.basename(os.environ["GITHUB_REF"].strip(" '\""))

# Get version from the .nf-core.yml template
if self.nf_config.get("config_yml.template.version", ""):
versions["nfcore_yml.version"] = self.nf_config.get("config_yml.template.version", "").strip(" '\"")

# Check if they are all numeric
for v_type, version in versions.items():
if not version.replace(".", "").isdigit():
Expand All @@ -57,7 +62,7 @@ def version_consistency(self):
", ".join([f"{k} = {v}" for k, v in versions.items()])
)
)

passed.append("Version tags are numeric and consistent between container, release tag and config.")
else:
passed.append("Version tags are consistent between container, release tag, config and .nf-core.yml.")

return {"passed": passed, "failed": failed}
62 changes: 59 additions & 3 deletions tests/pipelines/lint/test_version_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,71 @@


class TestLintVersionConsistency(TestLint):
def test_version_consistency(self):
"""Tests that config variable existence test fails with bad pipeline name"""
def test_version_consistency_pass(self):
"""Tests that pipeline version consistency test passes with good pipeline name"""
new_pipeline = self._make_pipeline_copy()
lint_obj = nf_core.pipelines.lint.PipelineLint(new_pipeline)
lint_obj.load_pipeline_config()
lint_obj.nextflow_config()

# Set the version numbers to be consistent
lint_obj.nf_config["manifest.version"] = "1.0.0"
lint_obj.nf_config["config_yml.template.version"] = "1.0.0"

result = lint_obj.version_consistency()
assert result["passed"] == [
"Version tags are consistent between container, release tag, config and .nf-core.yml."
]
assert result["failed"] == []

def test_version_consistency_not_numeric(self):
"""Tests that pipeline version consistency test fails with non-numeric version numbers"""
new_pipeline = self._make_pipeline_copy()
lint_obj = nf_core.pipelines.lint.PipelineLint(new_pipeline)
lint_obj.load_pipeline_config()
lint_obj.nextflow_config()

result = lint_obj.version_consistency()
assert result["passed"] == [
"Version tags are numeric and consistent between container, release tag and config."
"Version tags are consistent between container, release tag, config and .nf-core.yml."
]
assert result["failed"] == ["manifest.version was not numeric: 1.0.0dev!"]

def test_version_consistency_container_not_consistent(self):
"""Tests that pipeline version consistency test fails with inconsistent version numbers"""
new_pipeline = self._make_pipeline_copy()
lint_obj = nf_core.pipelines.lint.PipelineLint(new_pipeline)
lint_obj.load_pipeline_config()
lint_obj.nextflow_config()

# Set a bad version number for the container
lint_obj.nf_config["process.container"] = "nfcore/pipeline:latest"
# Set the version numbers to be consistent
lint_obj.nf_config["manifest.version"] = "1.0.0"
lint_obj.nf_config["config_yml.template.version"] = "1.0.0"

result = lint_obj.version_consistency()
assert len(result["passed"]) == 0
assert result["failed"] == [
"process.container was not numeric: latest!",
"The versioning is not consistent between container, release tag and config. Found manifest.version = 1.0.0, process.container = latest, nfcore_yml.version = 1.0.0",
]

def test_version_consistency_yml_not_consistent(self):
"""Tests that pipeline version consistency test fails with inconsistent version numbers"""
new_pipeline = self._make_pipeline_copy()
lint_obj = nf_core.pipelines.lint.PipelineLint(new_pipeline)
lint_obj.load_pipeline_config()
lint_obj.nextflow_config()

# Set a bad version number for the YAML file
lint_obj.nf_config["config_yml.template.version"] = "0.0.0"
# Set the version numbers to be consistent
lint_obj.nf_config["process.container"] = "nfcore/pipeline:1.0.0"
lint_obj.nf_config["manifest.version"] = "1.0.0"

result = lint_obj.version_consistency()
assert len(result["passed"]) == 0
assert result["failed"] == [
"The versioning is not consistent between container, release tag and config. Found manifest.version = 1.0.0, process.container = 1.0.0, nfcore_yml.version = 0.0.0",
]