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

Commit

Permalink
Merge pull request #75 from suzuki-shunsuke/docs/add-examples
Browse files Browse the repository at this point in the history
docs: add examples
  • Loading branch information
suzuki-shunsuke authored Oct 15, 2020
2 parents 6842a8e + 0a595de commit ddbadfa
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .cmdx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ tasks:
description: buildflow run for test
usage: buildflow run for test
script: "go run ./cmd/buildflow run"
- name: test-example
short: te
description: test examples
usage: test examples
script: "bash scripts/test-example.sh"
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
bash ci/test.sh buildflow
- name: test examples
run: |
bash ci/test-example.sh
bash scripts/test-example.sh
- name: remove changes
# Sometimes it is failed to release by goreleaser due to changes of go.sum
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin/*
.git-rm-branch.yml
.buildflow.yaml
.envrc
examples/foo.txt
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ phases:
Please see [examples](https://github.com/suzuki-shunsuke/buildflow/tree/master/examples).
On the directory, there are some examples of configuration files.
We can execute the build with them.
For example,
```
$ buildflow run -c examples/hello_world.yaml
```

### Configuration variables

- PR: [Response body of GitHub API: Get a pull request](https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#get-a-pull-request)
Expand Down
11 changes: 0 additions & 11 deletions ci/test-example.sh

This file was deleted.

8 changes: 8 additions & 0 deletions examples/import_phases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
phases:
- name: main
tasks:
- name: hello
command:
command: echo hello
- import: phases.yaml
8 changes: 8 additions & 0 deletions examples/import_tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
phases:
- name: main
tasks:
- name: hello
command:
command: echo hello
- import: tasks.yaml
14 changes: 13 additions & 1 deletion examples/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"gotest.tools/v3/icmd"
)

func TestBuildflow(t *testing.T) {
func TestBuildflow(t *testing.T) { //nolint:funlen
data := []struct {
title string
file string
Expand All @@ -32,10 +32,22 @@ func TestBuildflow(t *testing.T) {
title: "read_file",
file: "read_file.yaml",
},
{
title: "write_file",
file: "write_file.yaml",
},
{
title: "command's standard input",
file: "stdin.yaml",
},
{
title: "import phases from a file",
file: "import_phases.yaml",
},
{
title: "import tasks from a file",
file: "import_tasks.yaml",
},
{
title: "buildflow run fails as expected",
file: "fail.yaml",
Expand Down
12 changes: 12 additions & 0 deletions examples/phases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# This file is imported from import_phases.yaml
- name: main 2
tasks:
- name: hello
command:
command: echo "main 2"
- name: main
tasks:
- name: main 3
command:
command: echo "main 3"
8 changes: 8 additions & 0 deletions examples/tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# This file is imported from import_tasks.yaml
- name: foo
command:
command: echo foo
- name: bar
command:
command: echo bar
10 changes: 10 additions & 0 deletions examples/write_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
phases:
- name: main
tasks:
- name: foo
write_file:
path: foo.txt
template: |
# This file is generated by write_file.yaml
hello {{.Task.Name}}
13 changes: 13 additions & 0 deletions scripts/test-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -eu

cd "$(dirname "$0")/.."

tempdir=$(mktemp -d)
go build -o "$tempdir/buildflow" ./cmd/buildflow
export PATH="$tempdir:$PATH"
cd examples
# command -v buildflow
go test -race -covermode=atomic ./...
rm -R "$tempdir"

0 comments on commit ddbadfa

Please sign in to comment.