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 2 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 nfcore yaml.")

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


class TestLintVersionConsistency(TestLint):
def test_version_consistency(self):
def test_version_consistency_pass(self):
"""Tests that config variable existence test fails with bad 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()

lint_obj.nf_config["manifest.version"] = "1.0.0"
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 nfcore yaml."
]
assert result["failed"] == []

def test_version_consistency_not_numeric(self):
"""Tests that config variable existence test fails with bad 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()

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

def test_version_consistency_not_consistent(self):
"""Tests that config variable existence test fails with bad 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 a bad version number
lint_obj.nf_config["process.container"] = "nfcore/pipeline:latest"
result = lint_obj.version_consistency()
assert len(result["passed"]) == 0
assert result["failed"] == [
"manifest.version was not numeric: 1.0.0dev!",
"process.container was not numeric: latest!",
"The versioning is not consistent between container, release tag and config. Found manifest.version = 1.0.0dev, process.container = latest",
]
Loading