summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorearl-warren <earl-warren@noreply.code.forgejo.org>2024-11-21 14:25:45 +0100
committerearl-warren <earl-warren@noreply.code.forgejo.org>2024-11-21 14:25:45 +0100
commit338259cef2ee29afff55b17e72086798232c787e (patch)
tree5d79081f23c39885d84672442f3893d2ac003600
parentMerge pull request 'ci: use `go.mod` to install go' (#66) from ci/use-go-mod ... (diff)
parentfix: log skipped job and step result as info instead of debug (diff)
downloadforgejo-act-338259cef2ee29afff55b17e72086798232c787e.tar.xz
forgejo-act-338259cef2ee29afff55b17e72086798232c787e.zip
Merge pull request 'fix: log skipped job and step result as info instead of debug' (#67) from earl-warren/act:wip-runner-test into mainv1.22.2
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/67 Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
-rw-r--r--.forgejo/workflows/test.yml25
-rw-r--r--pkg/runner/action.go6
-rw-r--r--pkg/runner/run_context.go2
-rw-r--r--pkg/runner/runner_test.go38
-rw-r--r--pkg/runner/step.go2
-rw-r--r--pkg/runner/testdata/skip/skip.yml9
6 files changed, 73 insertions, 9 deletions
diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml
index a985814..5498dac 100644
--- a/.forgejo/workflows/test.yml
+++ b/.forgejo/workflows/test.yml
@@ -11,8 +11,7 @@ env:
GOCACHE: /go_cache
jobs:
- lint:
- name: check and test
+ unit:
runs-on: docker
container:
image: 'code.forgejo.org/oci/node:20-bookworm'
@@ -48,6 +47,24 @@ jobs:
run: go build -v ./...
- name: build without docker
run: go build -tags WITHOUT_DOCKER -v ./...
- - name: test
+ - name: unit test
run: go test -v ./pkg/jobparser ./pkg/model ./pkg/exprparser
- # TODO test more packages
+
+ integration:
+ runs-on: lxc-bookworm
+ needs: [unit]
+ steps:
+ - uses: https://code.forgejo.org/actions/checkout@v4
+
+ - uses: https://code.forgejo.org/actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+
+ - name: apt install docker.io
+ run: |
+ export DEBIAN_FRONTEND=noninteractive
+ apt-get update -qq
+ apt-get -q install -qq -y docker.io
+
+ - name: integration test
+ run: go test -run=TestRunSkipped -v ./pkg/runner
diff --git a/pkg/runner/action.go b/pkg/runner/action.go
index 416e5e4..fd52c0b 100644
--- a/pkg/runner/action.go
+++ b/pkg/runner/action.go
@@ -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
}
diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go
index 8ecdb2b..6aaf2d8 100644
--- a/pkg/runner/run_context.go
+++ b/pkg/runner/run_context.go
@@ -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
}
diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go
index 70e9634..ecb5ce5 100644
--- a/pkg/runner/runner_test.go
+++ b/pkg/runner/runner_test.go
@@ -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
}
diff --git a/pkg/runner/step.go b/pkg/runner/step.go
index c67b5b0..ec3cfe2 100644
--- a/pkg/runner/step.go
+++ b/pkg/runner/step.go
@@ -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
}
diff --git a/pkg/runner/testdata/skip/skip.yml b/pkg/runner/testdata/skip/skip.yml
new file mode 100644
index 0000000..7f6d303
--- /dev/null
+++ b/pkg/runner/testdata/skip/skip.yml
@@ -0,0 +1,9 @@
+name: skip
+on: push
+
+jobs:
+ check:
+ runs-on: ubuntu-latest
+ steps:
+ - if: false
+ run: echo nothing