Skip to content

Commit de3c3c8

Browse files
authored
Merge pull request #16 from GallVp/update/test
Bug fix for filter by tag strategy
2 parents d9265f6 + 9df9743 commit de3c3c8

File tree

2 files changed

+67
-32
lines changed

2 files changed

+67
-32
lines changed

.github/workflows/test.yml

+47-21
Original file line numberDiff line numberDiff line change
@@ -23,91 +23,117 @@ jobs:
2323
&& tar -xzvf .github/workflows/test.tar.gz -C testrepo --no-same-owner
2424
2525
- name: default
26-
id: detect_module_a_default
26+
id: detect_module_a_default # Expected: modules/a/tests/main.nf.test, modules/b/tests/main.nf.test (depends on A)
2727
uses: ./
2828
with:
2929
root: testrepo/test
3030
head: change_module_a
3131
base: main
32+
log_level: DEBUG
3233

33-
- name: Ignore changes in module A
34+
- name: Ignore changes in module A # Expected: Nothing
3435
id: ignore_module_a
3536
uses: ./
3637
with:
3738
root: testrepo/test
3839
head: change_module_a
3940
base: main
4041
ignored: "modules/a/*"
42+
log_level: DEBUG
4143

42-
- name: Do not return workflows
43-
id: do_not_return_workflows
44+
- name: Return directory # Expected: modules/a, modules/b (depends on A)
45+
id: detect_module_a_directory
4446
uses: ./
4547
with:
4648
root: testrepo/test
4749
head: change_module_a
4850
base: main
49-
types: "function,process,pipeline"
51+
n_parents: 2
52+
log_level: DEBUG
5053

51-
- name: Return directory
52-
id: detect_module_a_directory
54+
- name: Detect config changes # Expected: modules/c/tests/main.nf.test, subworkflows/a/tests/main.nf.test, tests/main.pipeline.nf.test, tests/main.workflow.nf.test
55+
id: detect_config_changes
5356
uses: ./
5457
with:
5558
root: testrepo/test
56-
head: change_module_a
59+
head: modify_nextflow_config_in_module_c
5760
base: main
58-
n_parents: 2
59-
60-
- name: Detect config changes
61-
id: detect_config_changes
61+
log_level: DEBUG
62+
63+
- name: Do not return workflows # Expected: modules/c/tests/main.nf.test, tests/main.pipeline.nf.test; Same as above but without workflows
64+
id: do_not_return_workflows
6265
uses: ./
6366
with:
6467
root: testrepo/test
6568
head: modify_nextflow_config_in_module_c
6669
base: main
70+
types: "function,process,pipeline"
71+
log_level: DEBUG
6772

68-
- name: Detect additional include statement file
73+
- name: Detect additional include statement file # Expected: tests/main.pipeline.nf.test, tests/main.workflow.nf.test
6974
id: detect_additional_include_file
7075
uses: ./
7176
with:
7277
root: testrepo/test
7378
head: modify_main_nextflow_file
7479
base: main
80+
log_level: DEBUG
7581

76-
- name: Include tags
82+
- name: Include tags # Expected: "tests/main.pipeline.nf.test"
7783
id: detect_tags
7884
uses: ./
7985
with:
8086
root: testrepo/test
8187
head: modify_main_nextflow_file
8288
base: main
83-
tags: "PIPELINE" # should pick one test
89+
tags: "PIPELINE"
90+
log_level: DEBUG
8491

85-
- name: Exclude tags
92+
- name: Exclude tags # Expected: Nothing
8693
id: exclude_tags
8794
uses: ./
8895
with:
8996
root: testrepo/test
9097
head: modify_main_nextflow_file
9198
base: main
92-
tags: "PIPELINE" # should pick one test
93-
exclude_tags: "PIPELINE" # should drop the test
99+
tags: "PIPELINE"
100+
exclude_tags: "PIPELINE"
101+
log_level: DEBUG
94102

95-
- name: Detect multi-line include
103+
- name: Detect multi-line include # Expected: subworkflows/a/tests/main.nf.test, tests/main.pipeline.nf.test, tests/main.workflow.nf.test
96104
id: multi_line_include
97105
uses: ./
98106
with:
99107
root: testrepo/test
100108
head: multi_line_include
101109
base: main
110+
log_level: DEBUG
102111

103-
- name: print outputs
112+
- name: Print and assert outputs
104113
run: |
105114
echo Default: ${{ steps.detect_module_a_default.outputs.components }}
115+
[ '${{ steps.detect_module_a_default.outputs.components }}' = '["modules/a/tests/main.nf.test", "modules/b/tests/main.nf.test"]' ]
116+
106117
echo Ignore module A: ${{ steps.ignore_module_a.outputs.components }}
107-
echo No workflows: ${{ steps.do_not_return_workflows.outputs.components }}
118+
[ '${{ steps.ignore_module_a.outputs.components }}' = '[]' ]
119+
108120
echo Directories: ${{ steps.detect_module_a_directory.outputs.components }}
121+
[ '${{ steps.detect_module_a_directory.outputs.components }}' = '["modules/a", "modules/b"]' ]
122+
109123
echo Config files: ${{ steps.detect_config_changes.outputs.components }}
124+
[ '${{ steps.detect_config_changes.outputs.components }}' = '["modules/c/tests/main.nf.test", "subworkflows/a/tests/main.nf.test", "tests/main.pipeline.nf.test", "tests/main.workflow.nf.test"]' ]
125+
126+
echo No workflows: ${{ steps.do_not_return_workflows.outputs.components }}
127+
[ '${{ steps.do_not_return_workflows.outputs.components }}' = '["modules/c/tests/main.nf.test", "tests/main.pipeline.nf.test"]' ]
128+
110129
echo Additional include file: ${{ steps.detect_additional_include_file.outputs.components }}
130+
[ '${{ steps.detect_additional_include_file.outputs.components }}' = '["tests/main.pipeline.nf.test", "tests/main.workflow.nf.test"]' ]
131+
111132
echo Tags: ${{ steps.detect_tags.outputs.components }}
133+
[ '${{ steps.detect_tags.outputs.components }}' = '["tests/main.pipeline.nf.test"]' ]
134+
112135
echo Exclude tags: ${{ steps.exclude_tags.outputs.components }}
136+
[ '${{ steps.exclude_tags.outputs.components }}' = '[]' ]
137+
113138
echo Multi-line include: ${{ steps.multi_line_include.outputs.components }}
139+
[ '${{ steps.multi_line_include.outputs.components }}' = '["subworkflows/a/tests/main.nf.test", "tests/main.pipeline.nf.test", "tests/main.workflow.nf.test"]' ]

entrypoint.py

+20-11
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,15 @@ def detect_files(paths: list[Path], suffix: str) -> list[Path]:
548548
logging.basicConfig(level=args.log_level)
549549
# Argparse handling of nargs is a bit rubbish. So we do it manually here.
550550
args.types = args.types.split(",")
551-
args.tags = [tag.strip().casefold() for tag in args.tags.split(",")]
552-
args.exclude_tags = [tag.strip().casefold() for tag in args.exclude_tags.split(",")]
551+
552+
if args.tags.strip() != "":
553+
args.tags = [tag.strip().casefold() for tag in args.tags.split(",")]
554+
555+
if args.exclude_tags.strip() != "":
556+
args.exclude_tags = [
557+
tag.strip().casefold() for tag in args.exclude_tags.split(",")
558+
]
559+
553560
# Quick validation of args.types since we cant do this in argparse
554561
if any(
555562
_type not in ["function", "process", "workflow", "pipeline"]
@@ -659,15 +666,17 @@ def detect_files(paths: list[Path], suffix: str) -> list[Path]:
659666
# Go back n_parents directories, remove root from path and stringify
660667
# It's a bit much but might as well do all path manipulation in one place
661668
logging.info("Normalising test file paths")
662-
normalised_nf_test_path = list(
663-
{
664-
str(
665-
nf_test.get_parents(args.n_parents)
666-
.resolve()
667-
.relative_to(root_path.resolve())
668-
)
669-
for nf_test in only_selected_nf_tests
670-
}
669+
normalised_nf_test_path = sorted(
670+
list(
671+
{
672+
str(
673+
nf_test.get_parents(args.n_parents)
674+
.resolve()
675+
.relative_to(root_path.resolve())
676+
)
677+
for nf_test in only_selected_nf_tests
678+
}
679+
)
671680
)
672681

673682
# Print to string for outputs

0 commit comments

Comments
 (0)