diff --git a/examples/command_file.sh b/examples/command_file.sh new file mode 100644 index 0000000..f6a321a --- /dev/null +++ b/examples/command_file.sh @@ -0,0 +1,3 @@ +# This file is read from command_file.yaml +# Go's text/teplate +echo "{{.Task.Name}}" diff --git a/examples/command_file.yaml b/examples/command_file.yaml new file mode 100644 index 0000000..2ccae2e --- /dev/null +++ b/examples/command_file.yaml @@ -0,0 +1,7 @@ +--- +phases: +- name: main + tasks: + - name: read command from a file + command: + command_file: command_file.sh diff --git a/examples/main_test.go b/examples/main_test.go index 3120420..25be4f4 100644 --- a/examples/main_test.go +++ b/examples/main_test.go @@ -16,6 +16,10 @@ func TestBuildflow(t *testing.T) { //nolint:funlen title: "hello world", file: "hello_world.yaml", }, + { + title: "read command from a file (task.command_file)", + file: "command_file.yaml", + }, { title: "run tasks in parallel", file: "parallel.yaml", @@ -25,8 +29,8 @@ func TestBuildflow(t *testing.T) { //nolint:funlen file: "task_dependency.yaml", }, { - title: "task.when is true", - file: "task_when_true.yaml", + title: "task.when", + file: "task_when.yaml", }, { title: "read_file", diff --git a/examples/task_when.tengo b/examples/task_when.tengo new file mode 100644 index 0000000..69ce2ee --- /dev/null +++ b/examples/task_when.tengo @@ -0,0 +1,5 @@ +// Tengo script +// Define the variable "result" and this value should be true or false. +result := func(task) { + return task.Name == "when" +}(Task) diff --git a/examples/task_when.yaml b/examples/task_when.yaml new file mode 100644 index 0000000..b2df9ba --- /dev/null +++ b/examples/task_when.yaml @@ -0,0 +1,21 @@ +--- +phases: +- name: main + tasks: + - name: "when true" + command: + command: echo "when is always true" + when: true + - name: when + command: + command: echo "use Tengo script in when" + when: | + // Tengo script + // Define the variable "result" and this value should be true or false. + result := func(task) { + return task.Name == "when" + }(Task) + - name: read task.when from a file + command: + command: echo "hello" + when_file: task_when.tengo diff --git a/examples/task_when_true.yaml b/examples/task_when_true.yaml deleted file mode 100644 index a62bcb4..0000000 --- a/examples/task_when_true.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -phases: -- name: main - tasks: - - name: "when true" - command: - command: ":" - when: true