Skip to content

Commit 5883719

Browse files
committed
don't require pipeline version in nf-test snapshots
closes #3453
1 parent 24d1db8 commit 5883719

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

nf_core/pipelines/bump_version.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def bump_pipeline_version(pipeline_obj: Pipeline, new_version: str) -> None:
101101
)
102102
# nf-test snap files
103103
pipeline_name = pipeline_obj.nf_config.get("manifest.name", "").strip(" '\"")
104-
snap_files = [f for f in Path().glob("tests/pipeline/*.snap")]
104+
snap_files = [f for f in Path(pipeline_obj.wf_path).glob("tests/pipeline/*.snap")]
105105
for snap_file in snap_files:
106106
update_file_version(
107107
snap_file,
@@ -112,6 +112,7 @@ def bump_pipeline_version(pipeline_obj: Pipeline, new_version: str) -> None:
112112
f"{pipeline_name}={new_version}",
113113
)
114114
],
115+
required=False,
115116
)
116117
# .nf-core.yml - pipeline version
117118
# update entry: version: 1.0.0dev, but not `nf_core_version`, or `bump_version`

tests/pipelines/test_bump_version.py

+38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Some tests covering the bump_version code."""
22

3+
import logging
4+
35
import yaml
46

57
import nf_core.pipelines.bump_version
@@ -66,3 +68,39 @@ def test_bump_nextflow_version(self):
6668
f"[![Nextflow](https://img.shields.io/badge/version-%E2%89%A5{version}-green?style=flat&logo=nextflow&logoColor=white&color=%230DC09D&link=https%3A%2F%2Fnextflow.io)]"
6769
"(https://www.nextflow.io/)" in readme
6870
)
71+
72+
def test_bump_pipeline_version_in_snapshot(self):
73+
"""Test that bump version also updates versions in the snapshot."""
74+
75+
# Create dummy snapshot
76+
snapshot_dir = self.pipeline_dir / "tests" / "pipeline"
77+
78+
snapshot_dir.mkdir(parents=True, exist_ok=True)
79+
snapshot_fn = snapshot_dir / "main.nf.test.snap"
80+
snapshot_fn.touch()
81+
# write version number in snapshot
82+
with open(snapshot_fn, "w") as fh:
83+
fh.write("nf-core/testpipeline=1.0.0dev")
84+
85+
# Bump the version number
86+
nf_core.pipelines.bump_version.bump_pipeline_version(self.pipeline_obj, "1.1.0")
87+
88+
# Check the snapshot
89+
with open(snapshot_fn) as fh:
90+
assert fh.read().strip() == "nf-core/testpipeline=1.1.0"
91+
92+
def test_bump_pipeline_version_in_snapshot_no_version(self):
93+
"""Test that bump version does not update versions in the snapshot if no version is given."""
94+
95+
# Create dummy snapshot
96+
snapshot_dir = self.pipeline_dir / "tests" / "pipeline"
97+
98+
snapshot_dir.mkdir(parents=True, exist_ok=True)
99+
snapshot_fn = snapshot_dir / "main2.nf.test.snap"
100+
snapshot_fn.touch()
101+
with open(snapshot_fn, "w") as fh:
102+
fh.write("test")
103+
# assert log info message
104+
self.caplog.set_level(logging.INFO)
105+
nf_core.pipelines.bump_version.bump_pipeline_version(self.pipeline_obj, "1.1.0")
106+
assert "Could not find version number in " in self.caplog.text

0 commit comments

Comments
 (0)