-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CheckRun.Names scale-up trigger configuration (#390)
This allows you to trigger autoscaling depending on check_run names(i.e. actions job names). If you are willing to differentiate scale amount only for a specific job, or want to scale only on a specific job, try this.
- Loading branch information
Showing
9 changed files
with
329 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
This package is an implementation of glob that is intended to simulate the behaviour of | ||
https://github.com/actions/toolkit/tree/master/packages/glob in many cases. | ||
|
||
This isn't a complete reimplementation of the referenced nodejs package. | ||
|
||
Differences: | ||
|
||
- This package doesn't implement `**` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package actionsglob | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func Match(pat string, s string) bool { | ||
if len(pat) == 0 { | ||
panic(fmt.Sprintf("unexpected length of pattern: %d", len(pat))) | ||
} | ||
|
||
var inverse bool | ||
|
||
if pat[0] == '!' { | ||
pat = pat[1:] | ||
inverse = true | ||
} | ||
|
||
tokens := strings.SplitAfter(pat, "*") | ||
|
||
var wildcardInHead bool | ||
|
||
for i := 0; i < len(tokens); i++ { | ||
p := tokens[i] | ||
|
||
if p == "" { | ||
s = "" | ||
break | ||
} | ||
|
||
if p == "*" { | ||
if i == len(tokens)-1 { | ||
s = "" | ||
break | ||
} | ||
|
||
wildcardInHead = true | ||
|
||
continue | ||
} | ||
|
||
wildcardInTail := p[len(p)-1] == '*' | ||
if wildcardInTail { | ||
p = p[:len(p)-1] | ||
} | ||
|
||
subs := strings.SplitN(s, p, 2) | ||
|
||
if len(subs) == 0 { | ||
break | ||
} | ||
|
||
if subs[0] != "" { | ||
if !wildcardInHead { | ||
break | ||
} | ||
} | ||
|
||
if subs[1] != "" { | ||
if !wildcardInTail { | ||
break | ||
} | ||
} | ||
|
||
s = subs[1] | ||
|
||
wildcardInHead = false | ||
} | ||
|
||
r := s == "" | ||
|
||
if inverse { | ||
r = !r | ||
} | ||
|
||
return r | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
package actionsglob | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMatch(t *testing.T) { | ||
type testcase struct { | ||
Pattern, Target string | ||
Want bool | ||
} | ||
|
||
run := func(t *testing.T, tc testcase) { | ||
t.Helper() | ||
|
||
got := Match(tc.Pattern, tc.Target) | ||
|
||
if got != tc.Want { | ||
t.Errorf("%s against %s: want %v, got %v", tc.Pattern, tc.Target, tc.Want, got) | ||
} | ||
} | ||
|
||
t.Run("foo == foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "foo", | ||
Target: "foo", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!foo == foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!foo", | ||
Target: "foo", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("foo == foo1", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "foo", | ||
Target: "foo1", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("!foo == foo1", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!foo", | ||
Target: "foo1", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("*foo == foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "*foo", | ||
Target: "foo", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!*foo == foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!*foo", | ||
Target: "foo", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("*foo == 1foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "*foo", | ||
Target: "1foo", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!*foo == 1foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!*foo", | ||
Target: "1foo", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("*foo == foo1", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "*foo", | ||
Target: "foo1", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("!*foo == foo1", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!*foo", | ||
Target: "foo1", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("*foo* == foo1", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "*foo*", | ||
Target: "foo1", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!*foo* == foo1", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!*foo*", | ||
Target: "foo1", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("*foo == foobar", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "*foo", | ||
Target: "foobar", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("!*foo == foobar", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!*foo", | ||
Target: "foobar", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("*foo* == foobar", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "*foo*", | ||
Target: "foobar", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!*foo* == foobar", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!*foo*", | ||
Target: "foobar", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("foo* == foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "foo*", | ||
Target: "foo", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!foo* == foo", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!foo*", | ||
Target: "foo", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("foo* == foobar", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "foo*", | ||
Target: "foobar", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!foo* == foobar", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!foo*", | ||
Target: "foobar", | ||
Want: false, | ||
}) | ||
}) | ||
|
||
t.Run("foo (* == foo ( 1 / 2 )", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "foo (*", | ||
Target: "foo ( 1 / 2 )", | ||
Want: true, | ||
}) | ||
}) | ||
|
||
t.Run("!foo (* == foo ( 1 / 2 )", func(t *testing.T) { | ||
run(t, testcase{ | ||
Pattern: "!foo (*", | ||
Target: "foo ( 1 / 2 )", | ||
Want: false, | ||
}) | ||
}) | ||
} |