fix: add-matcher fails github workflow (#1532)

* fix: add-matcher fails github workflow

* make linter happy
This commit is contained in:
ChristopherHX 2023-01-13 18:01:40 +01:00 committed by GitHub
parent 3f3b25ae84
commit 8b4f210872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 29 deletions

31
pkg/runner/command.go Executable file → Normal file
View file

@ -16,22 +16,27 @@ func init() {
commandPatternADO = regexp.MustCompile("^##\\[([^ ]+)( (.+))?]([^\r\n]*)[\r\n]+$")
}
func tryParseRawActionCommand(line string) (command string, kvPairs map[string]string, arg string, ok bool) {
if m := commandPatternGA.FindStringSubmatch(line); m != nil {
command = m[1]
kvPairs = parseKeyValuePairs(m[3], ",")
arg = m[4]
ok = true
} else if m := commandPatternADO.FindStringSubmatch(line); m != nil {
command = m[1]
kvPairs = parseKeyValuePairs(m[3], ";")
arg = m[4]
ok = true
}
return
}
func (rc *RunContext) commandHandler(ctx context.Context) common.LineHandler {
logger := common.Logger(ctx)
resumeCommand := ""
return func(line string) bool {
var command string
var kvPairs map[string]string
var arg string
if m := commandPatternGA.FindStringSubmatch(line); m != nil {
command = m[1]
kvPairs = parseKeyValuePairs(m[3], ",")
arg = m[4]
} else if m := commandPatternADO.FindStringSubmatch(line); m != nil {
command = m[1]
kvPairs = parseKeyValuePairs(m[3], ";")
arg = m[4]
} else {
command, kvPairs, arg, ok := tryParseRawActionCommand(line)
if !ok {
return true
}
@ -66,6 +71,8 @@ func (rc *RunContext) commandHandler(ctx context.Context) common.LineHandler {
case "save-state":
logger.Infof(" \U0001f4be %s", line)
rc.saveState(ctx, kvPairs, arg)
case "add-matcher":
logger.Infof(" \U00002753 add-matcher %s", arg)
default:
logger.Infof(" \U00002753 %s", line)
}

View file

@ -9,23 +9,22 @@ inputs:
runs:
using: "composite"
steps:
# The output of actions/setup-node@v2 seems to fail the workflow
# - uses: actions/setup-node@v2
# with:
# node-version: '16'
# - run: |
# console.log(process.version);
# console.log("Hi from node");
# console.log("${{ inputs.test_input_optional }}");
# if("${{ inputs.test_input_optional }}" !== "Test") {
# console.log("Invalid input test_input_optional expected \"Test\" as value");
# process.exit(1);
# }
# if(!process.version.startsWith('v16')) {
# console.log("Expected node v16, but got " + process.version);
# process.exit(1);
# }
# shell: node {0}
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: |
console.log(process.version);
console.log("Hi from node");
console.log("${{ inputs.test_input_optional }}");
if("${{ inputs.test_input_optional }}" !== "Test") {
console.log("Invalid input test_input_optional expected \"Test\" as value");
process.exit(1);
}
if(!process.version.startsWith('v16')) {
console.log("Expected node v16, but got " + process.version);
process.exit(1);
}
shell: node {0}
- uses: ./uses-composite/composite_action
id: composite
with: