Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

docs: add examples #78

Merged
merged 3 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/command_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is read from command_file.yaml
# Go's text/teplate
echo "{{.Task.Name}}"
7 changes: 7 additions & 0 deletions examples/command_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
phases:
- name: main
tasks:
- name: read command from a file
command:
command_file: command_file.sh
8 changes: 6 additions & 2 deletions examples/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions examples/task_when.tengo
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 21 additions & 0 deletions examples/task_when.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions examples/task_when_true.yaml

This file was deleted.