mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-04 22:37:55 +00:00
Improve logging (#1171)
* feat: use logger from context wherever possible Co-authored-by: Markus Wolf <[email protected]> * feat: add step/job id and results to json logs Co-authored-by: Markus Wolf <[email protected]> * test: value to be masked should not be hard-coded in the action Co-authored-by: Markus Wolf <[email protected]> * fix: replace values following ::add-mask:: in evaluated strings Co-authored-by: Markus Wolf <[email protected]> * feat: [DEBUG] identifier for debug logs to distinguish them Co-authored-by: Markus Wolf <[email protected]> * feat: replace logger with step logger The container gets injected a job logger, but during the time that steps are run, we want to use the step logger. This commit wraps pre/main/post steps in an executor that replaces the job logger with a step logger. Co-authored-by: Markus Wolf <[email protected]> * feat: add pre/post stage identifier fields to json log output Co-authored-by: Markus Wolf <[email protected]> * feat: add job/step result status to skipped steps/jobs Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
35 files changed
+363
-292
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
@@ -16,11 +17,11 @@ func TestSetRefAndSha(t *testing.T) {
|
||||
defer func() { findGitRef = oldFindGitRef }()
|
||||
defer func() { findGitRevision = oldFindGitRevision }()
|
||||
|
||||
findGitRef = func(file string) (string, error) {
|
||||
findGitRef = func(ctx context.Context, file string) (string, error) {
|
||||
return "refs/heads/master", nil
|
||||
}
|
||||
|
||||
findGitRevision = func(file string) (string, string, error) {
|
||||
findGitRevision = func(ctx context.Context, file string) (string, string, error) {
|
||||
return "", "1234fakesha", nil
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ func TestSetRefAndSha(t *testing.T) {
|
||||
Event: table.event,
|
||||
}
|
||||
|
||||
ghc.SetRefAndSha("main", "/some/dir")
|
||||
ghc.SetRefAndSha(context.Background(), "main", "/some/dir")
|
||||
|
||||
assert.Equal(t, table.ref, ghc.Ref)
|
||||
assert.Equal(t, table.sha, ghc.Sha)
|
||||
@@ -115,7 +116,7 @@ func TestSetRefAndSha(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("no-default-branch", func(t *testing.T) {
|
||||
findGitRef = func(file string) (string, error) {
|
||||
findGitRef = func(ctx context.Context, file string) (string, error) {
|
||||
return "", fmt.Errorf("no default branch")
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ func TestSetRefAndSha(t *testing.T) {
|
||||
Event: map[string]interface{}{},
|
||||
}
|
||||
|
||||
ghc.SetRefAndSha("", "/some/dir")
|
||||
ghc.SetRefAndSha(context.Background(), "", "/some/dir")
|
||||
|
||||
assert.Equal(t, "master", ghc.Ref)
|
||||
assert.Equal(t, "1234fakesha", ghc.Sha)
|
||||
|
||||
Reference in new issue
Block a user