Merge pull request 'fix: log skipped job and step result as info instead of debug' (#67) from earl-warren/act:wip-runner-test into main
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/67 Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
commit
d89433fe3d
5 changed files with 52 additions and 5 deletions
|
|
@ -619,17 +619,17 @@ func shouldRunPostStep(step actionStep) common.Conditional {
|
|||
stepResult := stepResults[step.getStepModel().ID]
|
||||
|
||||
if stepResult == nil {
|
||||
log.WithField("stepResult", model.StepStatusSkipped).Debugf("skipping post step for '%s'; step was not executed", step.getStepModel())
|
||||
log.WithField("stepResult", model.StepStatusSkipped).Infof("skipping post step for '%s'; step was not executed", step.getStepModel())
|
||||
return false
|
||||
}
|
||||
|
||||
if stepResult.Conclusion == model.StepStatusSkipped {
|
||||
log.WithField("stepResult", model.StepStatusSkipped).Debugf("skipping post step for '%s'; main step was skipped", step.getStepModel())
|
||||
log.WithField("stepResult", model.StepStatusSkipped).Infof("skipping post step for '%s'; main step was skipped", step.getStepModel())
|
||||
return false
|
||||
}
|
||||
|
||||
if step.getActionModel() == nil {
|
||||
log.WithField("stepResult", model.StepStatusSkipped).Debugf("skipping post step for '%s': no action model available", step.getStepModel())
|
||||
log.WithField("stepResult", model.StepStatusSkipped).Infof("skipping post step for '%s': no action model available", step.getStepModel())
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -911,7 +911,7 @@ func (rc *RunContext) isEnabled(ctx context.Context) (bool, error) {
|
|||
}
|
||||
|
||||
if !runJob {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
|
|||
if !runStep {
|
||||
stepResult.Conclusion = model.StepStatusSkipped
|
||||
stepResult.Outcome = model.StepStatusSkipped
|
||||
logger.WithField("stepResult", stepResult.Outcome).Debugf("Skipping step '%s' due to '%s'", stepModel, ifExpression)
|
||||
logger.WithField("stepResult", stepResult.Outcome).Infof("Skipping step '%s' due to '%s'", stepModel, ifExpression)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
9
act/runner/testdata/skip/skip.yml
vendored
Normal file
9
act/runner/testdata/skip/skip.yml
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
name: skip
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- if: false
|
||||
run: echo nothing
|
||||
Loading…
Add table
Add a link
Reference in a new issue