From 3c1f9f25ad3514b0b5d16475b6f72854ea18dd0c Mon Sep 17 00:00:00 2001 From: Kishan B Date: Wed, 8 Nov 2023 14:22:50 +0530 Subject: [PATCH 1/2] Add glob support for self hosted runner known labels configuration --- rule_runner_label.go | 8 +++++++- rule_runner_label_test.go | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/rule_runner_label.go b/rule_runner_label.go index 21936499f..f9146ca20 100644 --- a/rule_runner_label.go +++ b/rule_runner_label.go @@ -1,6 +1,7 @@ package actionlint import ( + "path/filepath" "strings" ) @@ -192,7 +193,12 @@ func (rule *RuleRunnerLabel) verifyRunnerLabel(label *String) runnerOSCompat { known := rule.getKnownLabels() for _, k := range known { - if strings.EqualFold(l, k) { + matched, err := filepath.Match(k, l) + if matched { + return compatInvalid + } + if err != nil { + rule.Errorf(label.Pos, "label pattern %q is an invalid glob, kindly check list of labels in actionlint.yaml config file: %v", k, err) return compatInvalid } } diff --git a/rule_runner_label_test.go b/rule_runner_label_test.go index 0453ca45b..11f676fa2 100644 --- a/rule_runner_label_test.go +++ b/rule_runner_label_test.go @@ -63,6 +63,17 @@ func TestRuleRunnerLabelCheckLabels(t *testing.T) { labels: []string{"self-hosted", "foo", "bar", "linux"}, known: []string{"foo", "bar"}, }, + { + what: "user-defined labels with patterns", + labels: []string{"self-hosted", "INSTANCE_TYPE=m6a.large", "some-base-prefix:size=large&cpu=8"}, + known: []string{"INSTANCE_TYPE=*", "some-base-prefix:size=*&cpu=?"}, + }, + { + what: "user-defined labels with invalid glob pattern", + labels: []string{"self-hosted", "INSTANCE_TYPE=m6a.large"}, + known: []string{"INSTANCE_TYPE=["}, + errs: []string{`label pattern "INSTANCE_TYPE=[" is an invalid glob, kindly check list of labels in actionlint.yaml config file: syntax error in pattern`}, + }, { what: "matrix", labels: []string{"${{matrix.os}}"}, From 6161b3b169eb93d61c7a94beb5eb98a628ad28e5 Mon Sep 17 00:00:00 2001 From: Kishan B Date: Wed, 8 Nov 2023 14:23:16 +0530 Subject: [PATCH 2/2] Add intellij ide folder to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e1b7be05a..680b5f980 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ /man/actionlint.1.html /playground-dist /actionlint-workflow-ast +# IntelliJ IDE Folder +.idea/