Skip to content

Commit e459973

Browse files
committed
actions_ci pytests - more granular
1 parent d1e4fed commit e459973

File tree

2 files changed

+31
-72
lines changed

2 files changed

+31
-72
lines changed

tests/lint/actions_ci.py

+25-11
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,36 @@ def test_actions_ci_pass(self):
2121
assert len(results.get("ignored", [])) == 0
2222

2323

24-
def test_actions_ci_fail(self):
25-
"""Lint test: actions_actions_ci - FAIL"""
24+
def test_actions_ci_fail_wrong_nf(self):
25+
"""Lint test: actions_ci - FAIL - wrong minimum version of Nextflow tested"""
26+
self.lint_obj._load()
27+
self.lint_obj.minNextflowVersion = "1.2.3"
28+
results = self.lint_obj.actions_ci()
29+
assert results["failed"] == ["Minimum NF version in '.github/workflows/ci.yml' different to pipeline's manifest"]
30+
31+
32+
def test_actions_ci_fail_wrong_docker_ver(self):
33+
"""Lint test: actions_actions_ci - FAIL - wrong pipeline version used for docker commands"""
34+
35+
self.lint_obj._load()
36+
self.lint_obj.nf_config["process.container"] = "'nfcore/tools:0.4'"
37+
results = self.lint_obj.actions_ci()
38+
assert results["failed"] == [
39+
"CI is not building the correct docker image. Should be: `docker build --no-cache . -t nfcore/tools:0.4`",
40+
"CI is not pulling the correct docker image. Should be: `docker pull nfcore/tools:dev`",
41+
"CI is not tagging docker image correctly. Should be: `docker tag nfcore/tools:dev nfcore/tools:0.4`",
42+
]
43+
44+
45+
def test_actions_ci_fail_wrong_trigger(self):
46+
"""Lint test: actions_actions_ci - FAIL - workflow triggered incorrectly, NF ver not checked at all"""
2647

2748
# Edit .github/workflows/actions_ci.yml to mess stuff up!
2849
new_pipeline = self._make_pipeline_copy()
2950
with open(os.path.join(new_pipeline, ".github", "workflows", "ci.yml"), "r") as fh:
3051
ci_yml = yaml.safe_load(fh)
3152
ci_yml[True]["push"] = ["dev", "patch"]
32-
ci_yml["jobs"]["test"]["strategy"]["matrix"]["nxf_ver"] = ["foo", ""]
33-
ci_yml["jobs"]["test"]["steps"] = [{"name": "Check out pipeline code", "uses": "actions/checkout@v2"}]
53+
ci_yml["jobs"]["test"]["strategy"]["matrix"] = {"nxf_versionnn": ["foo", ""]}
3454
with open(os.path.join(new_pipeline, ".github", "workflows", "ci.yml"), "w") as fh:
3555
yaml.dump(ci_yml, fh)
3656

@@ -41,11 +61,5 @@ def test_actions_ci_fail(self):
4161
results = lint_obj.actions_ci()
4262
assert results["failed"] == [
4363
"'.github/workflows/ci.yml' is not triggered on expected events",
44-
"CI is not building the correct docker image. Should be: `docker build --no-cache . -t nfcore/testpipeline:dev`",
45-
"CI is not pulling the correct docker image. Should be: `docker pull nfcore/testpipeline:dev`",
46-
"CI is not tagging docker image correctly. Should be: `docker tag nfcore/testpipeline:dev nfcore/testpipeline:dev`",
47-
"Minimum NF version in '.github/workflows/ci.yml' different to pipeline's manifest"
64+
"'.github/workflows/ci.yml' does not check minimum NF version",
4865
]
49-
assert len(results.get("warned", [])) == 0
50-
assert len(results.get("passed", [])) == 0
51-
assert len(results.get("ignored", [])) == 0

tests/test_lint.py

+6-61
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,12 @@ def test_sphinx_rst_files(self):
187187
test_actions_branch_protection_fail,
188188
test_actions_branch_protection_ignore,
189189
)
190-
from lint.actions_ci import test_actions_ci_pass, test_actions_ci_fail
190+
from lint.actions_ci import (
191+
test_actions_ci_pass,
192+
test_actions_ci_fail_wrong_nf,
193+
test_actions_ci_fail_wrong_docker_ver,
194+
test_actions_ci_fail_wrong_trigger,
195+
)
191196

192197

193198
# def test_critical_missingfiles_example(self):
@@ -236,52 +241,6 @@ def test_sphinx_rst_files(self):
236241
# bad_lint_obj = nf_core.lint.PipelineLint("/non/existant/path")
237242
# bad_lint_obj.check_nextflow_config()
238243
#
239-
# def test_actions_wf_branch_pass(self):
240-
# """Tests that linting for GitHub Actions workflow for branch protection works for a good example"""
241-
# lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
242-
# lint_obj.pipeline_name = "tools"
243-
# lint_obj.check_actions_branch_protection()
244-
# expectations = {"failed": 0, "warned": 0, "passed": 2}
245-
# self.assess_lint_status(lint_obj, **expectations)
246-
#
247-
# def test_actions_wf_branch_fail(self):
248-
# """Tests that linting for GitHub Actions workflow for branch protection fails for a bad example"""
249-
# lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE)
250-
# lint_obj.pipeline_name = "tools"
251-
# lint_obj.check_actions_branch_protection()
252-
# expectations = {"failed": 2, "warned": 0, "passed": 0}
253-
# self.assess_lint_status(lint_obj, **expectations)
254-
#
255-
# def test_actions_wf_ci_pass(self):
256-
# """Tests that linting for GitHub Actions CI workflow works for a good example"""
257-
# lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
258-
# lint_obj.minNextflowVersion = "20.04.0"
259-
# lint_obj.pipeline_name = "tools"
260-
# lint_obj.config["process.container"] = "'nfcore/tools:0.4'"
261-
# lint_obj.check_actions_ci()
262-
# expectations = {"failed": 0, "warned": 0, "passed": 5}
263-
# self.assess_lint_status(lint_obj, **expectations)
264-
#
265-
# def test_actions_wf_ci_fail(self):
266-
# """Tests that linting for GitHub Actions CI workflow fails for a bad example"""
267-
# lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE)
268-
# lint_obj.minNextflowVersion = "20.04.0"
269-
# lint_obj.pipeline_name = "tools"
270-
# lint_obj.config["process.container"] = "'nfcore/tools:0.4'"
271-
# lint_obj.check_actions_ci()
272-
# expectations = {"failed": 5, "warned": 0, "passed": 0}
273-
# self.assess_lint_status(lint_obj, **expectations)
274-
#
275-
# def test_actions_wf_ci_fail_wrong_NF_version(self):
276-
# """Tests that linting for GitHub Actions CI workflow fails for a bad NXF version"""
277-
# lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
278-
# lint_obj.minNextflowVersion = "0.28.0"
279-
# lint_obj.pipeline_name = "tools"
280-
# lint_obj.config["process.container"] = "'nfcore/tools:0.4'"
281-
# lint_obj.check_actions_ci()
282-
# expectations = {"failed": 1, "warned": 0, "passed": 4}
283-
# self.assess_lint_status(lint_obj, **expectations)
284-
#
285244
# def test_actions_wf_lint_pass(self):
286245
# """Tests that linting for GitHub Actions linting wf works for a good example"""
287246
# lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
@@ -296,20 +255,6 @@ def test_sphinx_rst_files(self):
296255
# expectations = {"failed": 3, "warned": 0, "passed": 0}
297256
# self.assess_lint_status(lint_obj, **expectations)
298257
#
299-
# def test_actions_wf_awstest_pass(self):
300-
# """Tests that linting for GitHub Actions AWS test wf works for a good example"""
301-
# lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
302-
# lint_obj.check_actions_awstest()
303-
# expectations = {"failed": 0, "warned": 0, "passed": 1}
304-
# self.assess_lint_status(lint_obj, **expectations)
305-
#
306-
# def test_actions_wf_awstest_fail(self):
307-
# """Tests that linting for GitHub Actions AWS test wf fails for a bad example"""
308-
# lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE)
309-
# lint_obj.check_actions_awstest()
310-
# expectations = {"failed": 1, "warned": 0, "passed": 0}
311-
# self.assess_lint_status(lint_obj, **expectations)
312-
#
313258
# def test_wrong_license_examples_with_failed(self):
314259
# """Tests for checking the license test behavior"""
315260
# for example in PATHS_WRONG_LICENSE_EXAMPLE:

0 commit comments

Comments
 (0)