Skip to content

Commit a78dd95

Browse files
committed
fix: gofmt + keep executor's cancellable ctx for task commands (staticcheck SA4009)
1 parent 9b371fb commit a78dd95

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

actions/features_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
func TestEnabledFeaturesForProject(t *testing.T) {
1313
cfg := &config.GitteConfig{
1414
FeatureGates: map[string]config.FeatureGate{
15-
"feat-on": {}, // empty scope → applies to all projects
16-
"feat-off": {}, // disabled in state
15+
"feat-on": {}, // empty scope → applies to all projects
16+
"feat-off": {}, // disabled in state
1717
"feat-scoped-out": {Scope: config.FeatureScope{Projects: []string{"other"}}}, // enabled but scoped to a different project
1818
},
1919
}

actions/runner.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ func runGroupTask(
288288
reg *telemetry.SpanRegistry,
289289
) (err error) {
290290
actionCtx := tracker.ActionContext(telemetry.ActionOf(taskName))
291-
ctx, span := telemetry.Tracer().Start(actionCtx, "action.run "+taskName)
291+
// Parent the task span under the action span, but keep running under the
292+
// executor's incoming (cancellable) context so cancellation still propagates
293+
// to the command — attach the span to ctx rather than replacing ctx.
294+
_, span := telemetry.Tracer().Start(actionCtx, "action.run "+taskName)
295+
ctx = trace.ContextWithSpan(ctx, span)
292296
reg.Set(taskName, span.SpanContext())
293297
setActionAttrs(span, taskName, projName, strings.Join(cmds, " "))
294298
if feats := enabledFeaturesForProject(cfg, st, projName, proj); len(feats) > 0 {

telemetry/action_tracker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestActionTracker_RecordsTaskErrorOnActionSpan(t *testing.T) {
100100
tr.OnStart("a:build:sn")
101101
tr.OnStart("b:build:sn")
102102
tr.OnFinish("a:build:sn", errors.New("build failed")) // one task fails
103-
tr.OnFinish("b:build:sn", nil) // last finishes -> span ends
103+
tr.OnFinish("b:build:sn", nil) // last finishes -> span ends
104104

105105
spans := exp.GetSpans()
106106
var build *tracetest.SpanStub

telemetry/logs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/cego/gitte/executor"
99
"go.opentelemetry.io/otel/log"
1010
"go.opentelemetry.io/otel/log/global"
11-
"go.opentelemetry.io/otel/trace"
1211
sdklog "go.opentelemetry.io/otel/sdk/log"
12+
"go.opentelemetry.io/otel/trace"
1313
)
1414

1515
func TestSpanRegistry_SetGetDelete(t *testing.T) {

telemetry/telemetry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
otlplog "go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
2222
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
2323
otellog "go.opentelemetry.io/otel/log/global"
24-
"go.opentelemetry.io/otel/sdk/resource"
2524
sdklog "go.opentelemetry.io/otel/sdk/log"
25+
"go.opentelemetry.io/otel/sdk/resource"
2626
sdktrace "go.opentelemetry.io/otel/sdk/trace"
2727
"go.opentelemetry.io/otel/trace"
2828
)

0 commit comments

Comments
 (0)