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 committed May 31, 2023
1 parent cbb8578 commit 760369a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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.Outf(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 @@ -1360,15 +1360,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: &buff,
Stderr: io.Discard,
}
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 760369a

Please sign in to comment.