mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
fix: log skipped job and step result as info instead of debug
This allows the Forgejo runner to obtain the job result from the logs even when it is not in debug mode.
This commit is contained in:
parent
c42fa5f412
commit
ef243fbf2f
5 changed files with 52 additions and 5 deletions
|
@ -187,6 +187,7 @@ func (j *TestJobFileInfo) runTest(ctx context.Context, t *testing.T, cfg *Config
|
|||
GitHubInstance: "github.com",
|
||||
ContainerArchitecture: cfg.ContainerArchitecture,
|
||||
Matrix: cfg.Matrix,
|
||||
JobLoggerLevel: cfg.JobLoggerLevel,
|
||||
}
|
||||
|
||||
runner, err := New(runnerConfig)
|
||||
|
@ -490,6 +491,43 @@ func TestRunDifferentArchitecture(t *testing.T) {
|
|||
tjfi.runTest(context.Background(), t, &Config{ContainerArchitecture: "linux/arm64"})
|
||||
}
|
||||
|
||||
type runSkippedHook struct {
|
||||
found bool
|
||||
}
|
||||
|
||||
func (h *runSkippedHook) Levels() []log.Level {
|
||||
return []log.Level{log.InfoLevel}
|
||||
}
|
||||
|
||||
func (h *runSkippedHook) Fire(entry *log.Entry) error {
|
||||
if v, ok := entry.Data["stepResult"]; ok {
|
||||
h.found = (v == model.StepStatusSkipped)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestRunSkipped(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
|
||||
tjfi := TestJobFileInfo{
|
||||
workdir: workdir,
|
||||
workflowPath: "skip",
|
||||
eventName: "push",
|
||||
errorMessage: "",
|
||||
platforms: platforms,
|
||||
}
|
||||
|
||||
h := &runSkippedHook{}
|
||||
ctx := common.WithLoggerHook(context.Background(), h)
|
||||
|
||||
jobLoggerLevel := log.InfoLevel
|
||||
tjfi.runTest(ctx, t, &Config{ContainerArchitecture: "linux/arm64", JobLoggerLevel: &jobLoggerLevel})
|
||||
|
||||
assert.True(t, h.found)
|
||||
}
|
||||
|
||||
type maskJobLoggerFactory struct {
|
||||
Output bytes.Buffer
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue