From dec277f146014f3bcc8c5db766305efd6b4f455e Mon Sep 17 00:00:00 2001 From: can Date: Wed, 8 May 2024 21:21:38 +0000 Subject: [PATCH] [rayci] support select+tag together as a filter Signed-off-by: can --- raycicmd/make.go | 6 +++++- raycicmd/step_filter_test.go | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/raycicmd/make.go b/raycicmd/make.go index 3b1765f..fe3e2d7 100644 --- a/raycicmd/make.go +++ b/raycicmd/make.go @@ -92,7 +92,11 @@ func makePipeline(repoDir string, config *config, info *buildInfo) ( var filter *stepFilter if len(info.selects) > 0 && len(config.TagFilterCommand) > 0 { - f, err := newSelectAndTagsStepFilter(config.SkipTags, info.selects, config.TagFilterCommand) + f, err := newSelectAndTagsStepFilter( + config.SkipTags, + info.selects, + config.TagFilterCommand, + ) if err != nil { return nil, fmt.Errorf("run tag filter command: %w", err) } diff --git a/raycicmd/step_filter_test.go b/raycicmd/step_filter_test.go index 9077615..cf87e4d 100644 --- a/raycicmd/step_filter_test.go +++ b/raycicmd/step_filter_test.go @@ -204,3 +204,26 @@ func TestStepFilter_selects(t *testing.T) { } } } + +func TestStepFilter_selectsAndTags(t *testing.T) { + filter, _ := newSelectAndTagsStepFilter([]string{"disabled"}, []string{"foo", "bar"}, []string{"echo", "tune"}) + for _, node := range []*stepNode{ + {key: "foo"}, + {id: "foo", tags: []string{"tune"}}, + {id: "bar"}, + } { + if !filter.accept(node) { + t.Errorf("miss %+v", node) + } + } + + for _, node := range []*stepNode{ + {id: "foo", tags: []string{"not_tune"}}, + {id: "bar", tags: []string{"tune_not"}}, + {key: "w00t"}, + } { + if filter.accept(node) { + t.Errorf("miss %+v", node) + } + } +}