1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

fix: do not fail the job when if: false (#172)

- log job result as info not as debug
- add test

---

v6.4.0 regression introduced in 4880b091a2

It did not fail a test because the [original fix](https://code.forgejo.org/forgejo/act/pulls/67/files)  has tests only for the case where a step is skipped, not when a job is skipped.

Closes forgejo/runner#660

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/172
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:
Earl Warren 2025-07-07 12:11:57 +00:00 committed by earl-warren
parent 21f71e5cdc
commit 7eb547faa5
4 changed files with 36 additions and 20 deletions

View file

@ -520,7 +520,8 @@ func TestRunDifferentArchitecture(t *testing.T) {
}
type runSkippedHook struct {
found bool
resultKey string
found bool
}
func (h *runSkippedHook) Levels() []log.Level {
@ -528,8 +529,8 @@ func (h *runSkippedHook) Levels() []log.Level {
}
func (h *runSkippedHook) Fire(entry *log.Entry) error {
if v, ok := entry.Data["stepResult"]; ok {
h.found = (v == model.StepStatusSkipped)
if result, ok := entry.Data[h.resultKey]; ok {
h.found = (fmt.Sprintf("%s", result) == "skipped")
}
return nil
}
@ -539,21 +540,25 @@ func TestRunSkipped(t *testing.T) {
t.Skip("skipping integration test")
}
tjfi := TestJobFileInfo{
workdir: workdir,
workflowPath: "skip",
eventName: "push",
errorMessage: "",
platforms: platforms,
for _, what := range []string{"step", "job"} {
t.Run(what, func(t *testing.T) {
tjfi := TestJobFileInfo{
workdir: workdir,
workflowPath: "skip" + what,
eventName: "push",
errorMessage: "",
platforms: platforms,
}
h := &runSkippedHook{resultKey: what + "Result"}
ctx := common.WithLoggerHook(context.Background(), h)
jobLoggerLevel := log.InfoLevel
tjfi.runTest(ctx, t, &Config{ContainerArchitecture: "linux/arm64", JobLoggerLevel: &jobLoggerLevel})
assert.True(t, h.found)
})
}
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 {