Skip to content

Commit

Permalink
feat: add a deprecation warning when running Taskfiles with a v2 schema
Browse files Browse the repository at this point in the history
  • Loading branch information
pd93 authored and andreynering committed Jun 3, 2023
1 parent 1a86c2c commit eb95c63
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## Unreleased

- Only rewrite checksum files in `.task` if the checksum has changed
(#1185, #1194 by @deviantintegral).
- Only rewrite checksum files in `.task` if the checksum has changed (#1185,
#1194 by @deviantintegral).
- Deprecated `version: 2` schema. This will be removed in the next major release
(#1197, #1198, #1199 by @pd93).

## v3.25.0 - 2023-05-22

Expand All @@ -16,7 +18,8 @@
- Fix some errors being unintendedly supressed (#1134 by @clintmod).
- Fix a nil pointer error when `version` is omitted from a Taskfile (#1148,
#1149 by @pd93).
- Fix duplicate error message when a task does not exists (#1141, #1144 by @pd93).
- Fix duplicate error message when a task does not exists (#1141, #1144 by
@pd93).

## v3.24.0 - 2023-04-15

Expand Down
6 changes: 5 additions & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ func (e *Executor) doVersionChecks() error {
*v = *e.Taskfile.Version

if v.LessThan(taskfile.V2) {
return fmt.Errorf(`task: Taskfile versions prior to v2 are not supported anymore`)
return fmt.Errorf(`task: version 1 schemas are no longer supported`)
}

if v.LessThan(taskfile.V3) {
e.Logger.Errf(logger.Yellow, "task: version 2 schemas are deprecated and will be removed in a future release\nSee https://github.com/go-task/task/issues/1197 for more details\n")
}

// consider as equal to the greater version if round
Expand Down
16 changes: 14 additions & 2 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1371,15 +1371,27 @@ func TestDynamicVariablesShouldRunOnTheTaskDir(t *testing.T) {
tt.Run(t)
}

func TestDisplaysErrorOnUnsupportedVersion(t *testing.T) {
func TestDisplaysErrorOnVersion1Schema(t *testing.T) {
e := task.Executor{
Dir: "testdata/version/v1",
Stdout: io.Discard,
Stderr: io.Discard,
}
err := e.Setup()
require.Error(t, err)
assert.Equal(t, "task: Taskfile versions prior to v2 are not supported anymore", err.Error())
assert.Equal(t, "task: version 1 schemas are no longer supported", err.Error())
}

func TestDisplaysWarningOnVersion2Schema(t *testing.T) {
var buff bytes.Buffer
e := task.Executor{
Dir: "testdata/version/v2",
Stdout: io.Discard,
Stderr: &buff,
}
err := e.Setup()
require.NoError(t, err)
assert.Equal(t, "task: version 2 schemas are deprecated and will be removed in a future release\nSee https://github.com/go-task/task/issues/1197 for more details\n", buff.String())
}

func TestShortTaskNotation(t *testing.T) {
Expand Down

0 comments on commit eb95c63

Please sign in to comment.