From 3df72c7d5d99bc3864707ff17e58fadcb04e9210 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Thu, 15 Oct 2020 17:58:36 +0900 Subject: [PATCH 1/3] docs: add an example --- examples/main_test.go | 4 ++-- examples/task_when.yaml | 17 +++++++++++++++++ examples/task_when_true.yaml | 8 -------- 3 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 examples/task_when.yaml delete mode 100644 examples/task_when_true.yaml diff --git a/examples/main_test.go b/examples/main_test.go index 3120420..a24462a 100644 --- a/examples/main_test.go +++ b/examples/main_test.go @@ -25,8 +25,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.yaml b/examples/task_when.yaml new file mode 100644 index 0000000..f16f6b4 --- /dev/null +++ b/examples/task_when.yaml @@ -0,0 +1,17 @@ +--- +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) 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 From fa492446f7f66d8137955eae1670a46d077704ab Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Thu, 15 Oct 2020 18:47:49 +0900 Subject: [PATCH 2/3] docs: add an example --- examples/task_when.tengo | 5 +++++ examples/task_when.yaml | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 examples/task_when.tengo 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 index f16f6b4..b2df9ba 100644 --- a/examples/task_when.yaml +++ b/examples/task_when.yaml @@ -15,3 +15,7 @@ phases: result := func(task) { return task.Name == "when" }(Task) + - name: read task.when from a file + command: + command: echo "hello" + when_file: task_when.tengo From 5bc3261ce6702c9d03d318d2acdf3ebc11026e63 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Thu, 15 Oct 2020 18:53:53 +0900 Subject: [PATCH 3/3] docs: add an example --- examples/command_file.sh | 3 +++ examples/command_file.yaml | 7 +++++++ examples/main_test.go | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 examples/command_file.sh create mode 100644 examples/command_file.yaml 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 a24462a..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",