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

Commit

Permalink
test: add examples of buildflow configuration and tests of them
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Oct 14, 2020
1 parent aeca98c commit 8fe0bf6
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
bash ci/test.sh buildflow
- name: test examples
run: |
bash ci/test-example.sh
- name: remove changes
# Sometimes it is failed to release by goreleaser due to changes of go.sum
Expand Down
11 changes: 11 additions & 0 deletions ci/test-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -eu

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

go build -o dist/buildflow ./cmd/buildflow
export PATH="$PWD/dist:$PATH"
cd examples
go test -race -covermode=atomic ./...
rm -R ../dist
5 changes: 5 additions & 0 deletions examples/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module examples

go 1.15

require gotest.tools/v3 v3.0.3
16 changes: 16 additions & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gotest.tools v1.4.0 h1:BjtEgfuw8Qyd+jPvQz8CfoxiO/UjFEidWinwEXZiWv0=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
7 changes: 7 additions & 0 deletions examples/hello_world.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
phases:
- name: main
tasks:
- name: hello
command:
command: echo hello
23 changes: 23 additions & 0 deletions examples/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package examples_test

import (
"testing"

"gotest.tools/v3/icmd"
)

func TestHelloWorld(t *testing.T) {
result := icmd.RunCmd(icmd.Command("buildflow", "run", "-c", "hello_world.yaml"))
result.Assert(t, icmd.Expected{
ExitCode: 0,
Err: "",
})
}

func TestParallel(t *testing.T) {
result := icmd.RunCmd(icmd.Command("buildflow", "run", "-c", "parallel.yaml"))
result.Assert(t, icmd.Expected{
ExitCode: 0,
Err: "",
})
}
12 changes: 12 additions & 0 deletions examples/parallel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
phases:
- name: main
tasks:
- name: foo
command:
command: |
echo foo
- name: bar
command:
command: |
echo bar

0 comments on commit 8fe0bf6

Please sign in to comment.