mirror of
https://github.com/go-task/task.git
synced 2026-07-07 14:09:11 +00:00
✨ feat(output): add gitlab output mode (#2806)
Adds a new `gitlab` output style that wraps each task's output in GitLab CI collapsible section markers. Section IDs are generated automatically so that start and end markers always match and stay unique per invocation — even when the same task runs multiple times in one job. Options: `collapsed` (maps to GitLab's native `[collapsed=true]`) and `error_only` (Task-level behavior, identical to `group.error_only`). Also introduces `output-ci-auto` (taskrc + TASK_OUTPUT_CI_AUTO env var) that auto-selects a CI-aware output style when a supported CI runner is detected (currently `GITLAB_CI=true` → gitlab) and no output style is explicitly configured. Keeps the Taskfile neutral so local devs are not forced into CI-shaped output. Refs #2806.
This commit is contained in:
@@ -306,4 +306,27 @@ remote:
|
||||
assert.Equal(t, &cacheExpiry, base.Remote.CacheExpiry)
|
||||
assert.Equal(t, []string{"github.com", "gitlab.com"}, base.Remote.TrustedHosts)
|
||||
})
|
||||
|
||||
t.Run("output-ci-auto merge", func(t *testing.T) { //nolint:paralleltest // parent test cannot run in parallel
|
||||
trueVal := true
|
||||
falseVal := false
|
||||
|
||||
t.Run("other overrides nil base", func(t *testing.T) { //nolint:paralleltest
|
||||
base := &ast.TaskRC{}
|
||||
base.Merge(&ast.TaskRC{OutputCIAuto: &trueVal})
|
||||
assert.Equal(t, &trueVal, base.OutputCIAuto)
|
||||
})
|
||||
|
||||
t.Run("other overrides base", func(t *testing.T) { //nolint:paralleltest
|
||||
base := &ast.TaskRC{OutputCIAuto: &falseVal}
|
||||
base.Merge(&ast.TaskRC{OutputCIAuto: &trueVal})
|
||||
assert.Equal(t, &trueVal, base.OutputCIAuto)
|
||||
})
|
||||
|
||||
t.Run("nil other does not override base", func(t *testing.T) { //nolint:paralleltest
|
||||
base := &ast.TaskRC{OutputCIAuto: &trueVal}
|
||||
base.Merge(&ast.TaskRC{})
|
||||
assert.Equal(t, &trueVal, base.OutputCIAuto)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user