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:
parent
21f71e5cdc
commit
7eb547faa5
4 changed files with 36 additions and 20 deletions
|
@ -914,7 +914,7 @@ func (rc *RunContext) isEnabled(ctx context.Context) (bool, error) {
|
|||
|
||||
if !runJob {
|
||||
rc.result("skipped")
|
||||
l.WithField("jobResult", "skipped").Debugf("Skipping job '%s' due to '%s'", job.Name, job.If.Value)
|
||||
l.WithField("jobResult", "skipped").Infof("Skipping job '%s' due to '%s'", job.Name, job.If.Value)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -520,6 +520,7 @@ func TestRunDifferentArchitecture(t *testing.T) {
|
|||
}
|
||||
|
||||
type runSkippedHook struct {
|
||||
resultKey string
|
||||
found bool
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
for _, what := range []string{"step", "job"} {
|
||||
t.Run(what, func(t *testing.T) {
|
||||
tjfi := TestJobFileInfo{
|
||||
workdir: workdir,
|
||||
workflowPath: "skip",
|
||||
workflowPath: "skip" + what,
|
||||
eventName: "push",
|
||||
errorMessage: "",
|
||||
platforms: platforms,
|
||||
}
|
||||
|
||||
h := &runSkippedHook{}
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type maskJobLoggerFactory struct {
|
||||
|
|
11
act/runner/testdata/skipjob/skipjob.yml
vendored
Normal file
11
act/runner/testdata/skipjob/skipjob.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
name: skipjob
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
checkjob:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: false
|
||||
|
||||
steps:
|
||||
- run: echo nothing
|
|
@ -1,8 +1,8 @@
|
|||
name: skip
|
||||
name: skipstep
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
check:
|
||||
checkstep:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- if: false
|
Loading…
Add table
Add a link
Reference in a new issue