Compare commits

..

7 Commits

Author SHA1 Message Date
Pete Davison
57c094f415 v3.37.2 2024-05-12 19:36:09 +00:00
Pete Davison
2f4876b71c chore: changelog for #1649 2024-05-12 19:33:39 +00:00
Pete Davison
725f929778 fix: included variable merging (#1649) 2024-05-12 20:32:09 +01:00
Pete Davison
8266b28b48 chore: changelog for #1648 2024-05-12 19:27:39 +00:00
Pete Davison
f5c7472f64 fix: nil schema panic (#1648) 2024-05-12 20:25:54 +01:00
Pete Davison
ced3e7a579 fix: var_subkey schema 2024-05-10 16:41:02 +00:00
Orel Lazri
36dd71b122 fix(docs): add references to experiments links (#1644) 2024-05-09 21:30:20 +00:00
15 changed files with 110 additions and 12 deletions

View File

@@ -1,5 +1,11 @@
# Changelog
## v3.37.2 - 2024-05-12
- Fixed a bug where an empty Taskfile would cause a panic (#1648 by @pd93).
- Fixed a bug where includes Taskfile variable were not being merged correctly
(#1643, #1649 by @pd93).
## v3.37.1 - 2024-05-09
- Fix bug where non-string values (numbers, bools) added to `env:` weren't been

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@go-task/cli",
"version": "3.37.1",
"version": "3.37.2",
"lockfileVersion": 2,
"requires": true,
"packages": {

View File

@@ -1,6 +1,6 @@
{
"name": "@go-task/cli",
"version": "3.37.1",
"version": "3.37.2",
"description": "A task runner / simpler Make alternative written in Go",
"scripts": {
"postinstall": "go-npm install",

View File

@@ -95,6 +95,15 @@ func TestEmptyTask(t *testing.T) {
require.NoError(t, e.Run(context.Background(), &ast.Call{Task: "default"}))
}
func TestEmptyTaskfile(t *testing.T) {
e := &task.Executor{
Dir: "testdata/empty_taskfile",
Stdout: io.Discard,
Stderr: io.Discard,
}
require.Error(t, e.Setup(), "e.Setup()")
}
func TestEnv(t *testing.T) {
tt := fileContentTest{
Dir: "testdata/env",
@@ -1228,6 +1237,34 @@ func TestIncludesInterpolation(t *testing.T) {
}
}
func TestIncludedTaskfileVarMerging(t *testing.T) {
const dir = "testdata/included_taskfile_var_merging"
tests := []struct {
name string
task string
expectedOutput string
}{
{"foo", "foo:pwd", "included_taskfile_var_merging/foo\n"},
{"bar", "bar:pwd", "included_taskfile_var_merging/bar\n"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var buff bytes.Buffer
e := task.Executor{
Dir: dir,
Stdout: &buff,
Stderr: &buff,
Silent: true,
}
require.NoError(t, e.Setup())
err := e.Run(context.Background(), &ast.Call{Task: test.task})
require.NoError(t, err)
assert.Contains(t, buff.String(), test.expectedOutput)
})
}
}
func TestInternalTask(t *testing.T) {
const dir = "testdata/internal_task"
tests := []struct {

View File

@@ -90,7 +90,7 @@ func (t1 *Tasks) Merge(t2 Tasks, include *Include, includedTaskfileVars *Vars) {
task.IncludeVars = &Vars{}
}
task.IncludeVars.Merge(include.Vars, nil)
task.IncludedTaskfileVars = includedTaskfileVars
task.IncludedTaskfileVars = includedTaskfileVars.DeepCopy()
}
// Add the task to the merged taskfile

View File

@@ -263,23 +263,28 @@ func (r *Reader) readNode(node Node) (*ast.Taskfile, error) {
}
}
var t ast.Taskfile
if err := yaml.Unmarshal(b, &t); err != nil {
var tf ast.Taskfile
if err := yaml.Unmarshal(b, &tf); err != nil {
return nil, &errors.TaskfileInvalidError{URI: filepathext.TryAbsToRel(node.Location()), Err: err}
}
// Check that the Taskfile is set and has a schema version
if tf.Version == nil {
return nil, &errors.TaskfileVersionCheckError{URI: node.Location()}
}
// Set the taskfile/task's locations
t.Location = node.Location()
for _, task := range t.Tasks.Values() {
tf.Location = node.Location()
for _, task := range tf.Tasks.Values() {
// If the task is not defined, create a new one
if task == nil {
task = &ast.Task{}
}
// Set the location of the taskfile for each task
if task.Location.Taskfile == "" {
task.Location.Taskfile = t.Location
task.Location.Taskfile = tf.Location
}
}
return &t, nil
return &tf, nil
}

0
testdata/empty_taskfile/Taskfile.yml vendored Normal file
View File

View File

@@ -0,0 +1,12 @@
version: "3"
includes:
foo:
taskfile: ./foo/Taskfile.yaml
bar:
taskfile: ./bar/Taskfile.yaml
tasks:
stub:
cmds:
- echo 0

View File

@@ -0,0 +1,11 @@
version: "3"
vars:
DIR: bar
tasks:
pwd:
dir: ./{{ .DIR }}
cmds:
- echo "{{ .DIR }}"
- pwd

View File

@@ -0,0 +1,11 @@
version: "3"
vars:
DIR: foo
tasks:
pwd:
dir: ./{{ .DIR }}
cmds:
- echo "{{ .DIR }}"
- pwd

View File

@@ -5,6 +5,12 @@ sidebar_position: 14
# Changelog
## v3.37.2 - 2024-05-12
- Fixed a bug where an empty Taskfile would cause a panic (#1648 by @pd93).
- Fixed a bug where includes Taskfile variable were not being merged correctly
(#1643, #1649 by @pd93).
## v3.37.1 - 2024-05-09
- Fix bug where non-string values (numbers, bools) added to `env:` weren't been

View File

@@ -148,6 +148,8 @@ If you have questions, feel free to ask them in the `#help` forum channel on our
---
{/* prettier-ignore-start */}
[experiments]: /experiments
[experiments-workflow]: /experiments#workflow
[task]: https://github.com/go-task/task
[vscode-task]: https://github.com/go-task/vscode-task
[go]: https://go.dev

View File

@@ -285,9 +285,9 @@
"yaml": {
"type": "string",
"description": "The value will parsed as a YAML string and stored in the variable"
},
"additionalProperties": false
}
}
},
"additionalProperties": false
},
"task_call": {
"type": "object",

View File

@@ -5,6 +5,12 @@ sidebar_position: 14
# Changelog
## v3.37.2 - 2024-05-12
- Fixed a bug where an empty Taskfile would cause a panic (#1648 by @pd93).
- Fixed a bug where includes Taskfile variable were not being merged correctly
(#1643, #1649 by @pd93).
## v3.37.1 - 2024-05-09
- Fix bug where non-string values (numbers, bools) added to `env:` weren't been

View File

@@ -148,6 +148,8 @@ If you have questions, feel free to ask them in the `#help` forum channel on our
---
{/* prettier-ignore-start */}
[experiments]: /experiments
[experiments-workflow]: /experiments#workflow
[task]: https://github.com/go-task/task
[vscode-task]: https://github.com/go-task/vscode-task
[go]: https://go.dev