diff --git a/ci/build-golang-pipeline.yml b/ci/build-golang-pipeline.yml new file mode 100755 index 0000000..307e5ee --- /dev/null +++ b/ci/build-golang-pipeline.yml @@ -0,0 +1,27 @@ + +resources: + +- name: go_script + type: git + source: + uri: https://github.com/mchirico/go_script.git + branch: next + +############################################################################### + +jobs: + +- name: unit + plan: + - get: go_script + trigger: true + - task: unit + file: go_script/ci/unit-task.yml + +- name: build + plan: + - get: go_script + trigger: true + passed: [unit] + - task: build + file: go_script/ci/build-task.yml diff --git a/ci/build-task.yml b/ci/build-task.yml new file mode 100644 index 0000000..fd3c1e5 --- /dev/null +++ b/ci/build-task.yml @@ -0,0 +1,17 @@ + +platform: linux + +image_resource: + type: registry-image + source: {repository: golang} + +inputs: +- name: go_script + path: gopath/src/gopath/src/github.com/mchirico/go_script + +caches: +- path: depspath/ +- path: gopath/pkg/ + +run: + path: gopath/src/gopath/src/github.com/mchirico/go_script/ci/build.sh diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000..d2436f9 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e -u -x + +export GOPATH=$PWD/depspath:$PWD/gopath +export PATH=$PWD/depspath/bin:$PWD/gopath/bin:$PATH + +cd gopath/src/gopath/src/github.com/mchirico/go_script + +#cd cmd/cake + +echo +echo "Fetching dependencies..." +go get -v + +echo +echo "Building..." +go build -v + +echo +echo "Smoke test..." +#./cake diff --git a/ci/run_ci.sh b/ci/run_ci.sh new file mode 100755 index 0000000..4f796f9 --- /dev/null +++ b/ci/run_ci.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -eu + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +export fly_target=${fly_target:-mce} +echo "Concourse API target ${fly_target}" +echo "Tutorial $(basename $DIR)" + +pushd $DIR + fly -t ${fly_target} set-pipeline -p go_script-pipeline -c build-golang-pipeline.yml -n + fly -t ${fly_target} unpause-pipeline -p go_script-pipeline +# fly -t ${fly_target} trigger-job -w -j tutorial-pipeline/job-hello-world +popd + +echo -e "\n\n Common commands:" +echo -e "**************************************\n\n" +echo -e "\n" +echo -e " fly -t mce watch --job go_script-pipeline/unit" +echo -e " fly -t mce builds|grep 'go_script-pipeline'" +echo -e " fly -t mce destroy-pipeline -p go_script-pipeline -n" +echo -e " fly -t mce workers -d " +echo -e "\n" +echo -e "\n" + diff --git a/ci/unit-task.yml b/ci/unit-task.yml new file mode 100644 index 0000000..7cae57d --- /dev/null +++ b/ci/unit-task.yml @@ -0,0 +1,16 @@ +platform: linux + +image_resource: + type: registry-image + source: {repository: golang} + +inputs: +- name: go_script + path: gopath/src/gopath/src/github.com/mchirico/go_script + +caches: +- path: depspath/ +- path: gopath/pkg/ + +run: + path: gopath/src/gopath/src/github.com/mchirico/go_script/ci/unit.sh diff --git a/ci/unit.sh b/ci/unit.sh new file mode 100755 index 0000000..13d9182 --- /dev/null +++ b/ci/unit.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e -u -x + +export GOPATH=$PWD/depspath:$PWD/gopath +export PATH=$PWD/depspath/bin:$PWD/gopath/bin:$PATH + +cd gopath/src/gopath/src/github.com/mchirico/go_script + +echo +echo "Fetching dependencies..." +go get -v -t ./... + +echo +echo "Running tests..." +go test -v -race ./...