Skip to content

Commit

Permalink
Merge pull request #6 from buildkite-plugins/set-gobin
Browse files Browse the repository at this point in the history
Make sure $GOBIN is set
  • Loading branch information
toolmantim authored May 4, 2018
2 parents e60716e + fbab3fd commit ac49f92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion hooks/pre-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ if [[ -n "${BUILDKITE_PLUGIN_GOLANG_IMPORT:-}" ]]; then
export BUILDKITE_BUILD_CHECKOUT_PATH="$GOPATH/src/$BUILDKITE_PLUGIN_GOLANG_IMPORT"
echo "BUILDKITE_BUILD_CHECKOUT_PATH=$BUILDKITE_BUILD_CHECKOUT_PATH"

# Make sure go get/install binaries are installed in the right place
export GOBIN="$GOPATH/bin"
echo "GOBIN=$GOBIN"

# Add golang bin commands to path
export PATH="$PATH:$GOPATH/bin"
export PATH="$PATH:$GOBIN"
echo PATH="$PATH"
else
echo "+++ :golang: No 'import' option specified"
Expand Down
15 changes: 10 additions & 5 deletions tests/pre-checkout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@ export BUILDKITE_PLUGIN_GOLANG_IMPORT=my-dir
export BUILDKITE_BUILD_CHECKOUT_PATH="/builds/my-pipeline"
export BUILDKITE_PIPELINE_SLUG="my-pipeline"

@test "sets the GOPATH" {
@test "sets \$GOPATH" {
run $PWD/hooks/pre-checkout

assert_success
assert_output --partial "GOPATH=/builds/.golang/my-pipeline"
}

@test "sets the BUILDKITE_BUILD_CHECKOUT_PATH" {
@test "sets \$BUILDKITE_BUILD_CHECKOUT_PATH" {
run $PWD/hooks/pre-checkout

assert_success
assert_output --partial "BUILDKITE_BUILD_CHECKOUT_PATH=/builds/.golang/my-pipeline/src/my-dir"
}

@test "adds GOPATH/bin to PATH" {
export PATH=/bin
@test "adds \$GOPATH/bin to \$PATH" {
run $PWD/hooks/pre-checkout

assert_success
assert_output --partial "PATH=$PATH:/builds/.golang/my-pipeline/bin"
}

@test "sets \$GOBIN" {
run $PWD/hooks/pre-checkout

assert_success
assert_output --partial "PATH=/bin:/builds/.golang/my-pipeline/bin"
assert_output --partial "GOBIN=/builds/.golang/my-pipeline/bin"
}

0 comments on commit ac49f92

Please sign in to comment.