Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add glob support for self hosted runner known labels configuration #378

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
/man/actionlint.1.html
/playground-dist
/actionlint-workflow-ast
# IntelliJ IDE Folder
.idea/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let the maintainers chime in, but typically I'd put this sort of thing in my own global gitignore; people develop in all kinds of environments, so adding that kind of stuff to a project-level gitignore can make it unwieldy

8 changes: 7 additions & 1 deletion rule_runner_label.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package actionlint

import (
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -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
}
}
Expand Down
11 changes: 11 additions & 0 deletions rule_runner_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"},
Expand Down