mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
fix: explain why a workflow cannot be used to run a job (#666)
- report back to the Forgejo instance - log Forgejo runner side in debug mode - display the workflow with line number to facilitate matching with errors - split the error into multiple lines if possible  Refs forgejo/act#170 Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/666 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
d23b354cbc
commit
6e6ebbc981
2 changed files with 36 additions and 1 deletions
|
@ -2,13 +2,30 @@ package run
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
|
||||
"runner.forgejo.org/internal/pkg/labels"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestExplainFailedGenerateWorkflow(t *testing.T) {
|
||||
logged := ""
|
||||
log := func(message string, args ...any) {
|
||||
logged += fmt.Sprintf(message, args...) + "\n"
|
||||
}
|
||||
task := &runnerv1.Task{
|
||||
WorkflowPayload: []byte("on: [push]\njobs:\n"),
|
||||
}
|
||||
generateWorkflowError := errors.New("message 1\nmessage 2")
|
||||
err := explainFailedGenerateWorkflow(task, log, generateWorkflowError)
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "1: on: [push]\n2: jobs:\n3: \nErrors were found and although they tend to be cryptic the line number they refer to gives a hint as to where the problem might be.\nmessage 1\nmessage 2\n", logged)
|
||||
}
|
||||
|
||||
func TestLabelUpdate(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ls := labels.Labels{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue