Skip to content

Commit

Permalink
use path.Match instead of filepath.Match to avoid OS-specific beh…
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Feb 10, 2024
1 parent 0ec7808 commit 1cbe234
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ config-variables:
```
- `self-hosted-runner`: Configuration for your self-hosted runner environment.
- `labels`: Label names added to your self-hosted runners as list of pattern. Glob syntax supported by [`filepath.Match`][pat]
- `labels`: Label names added to your self-hosted runners as list of pattern. Glob syntax supported by [`path.Match`][pat]
is available.
- `config-variables`: [Configuration variables][vars]. When an array is set, actionlint will check `vars` properties strictly.
An empty array means no variable is allowed. The default value `null` disables the check.
Expand All @@ -48,5 +48,5 @@ config-variables:
[Checks](checks.md) | [Installation](install.md) | [Usage](usage.md) | [Go API](api.md) | [References](reference.md)

[Super-Linter]: https://github.com/super-linter/super-linter
[pat]: https://pkg.go.dev/path/filepath#Match
[pat]: https://pkg.go.dev/path#Match
[vars]: https://docs.github.com/en/actions/learn-github-actions/variables
4 changes: 2 additions & 2 deletions rule_runner_label.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package actionlint

import (
"path/filepath"
"path"
"strings"
)

Expand Down Expand Up @@ -206,7 +206,7 @@ func (rule *RuleRunnerLabel) verifyRunnerLabel(label *String) runnerOSCompat {

known := rule.getKnownLabels()
for _, k := range known {
m, err := filepath.Match(k, l)
m, err := path.Match(k, l)
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
5 changes: 5 additions & 0 deletions rule_runner_label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func TestRuleRunnerLabelCheckLabels(t *testing.T) {
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: "some character is escaped in user-defined label patterns",
labels: []string{`linux-[arch]`},
known: []string{`*-\[*]`},
},
{
what: "user-defined labels with invalid glob pattern",
labels: []string{"self-hosted", "INSTANCE_TYPE=m6a.large"},
Expand Down

0 comments on commit 1cbe234

Please sign in to comment.