forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using gvm & shell test file to manage circleci go environment
- Loading branch information
Showing
2 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# | ||
# This is the InfluxDB CircleCI test script. Using this script allows total control | ||
# the environment in which the build and test is run, and matches the official | ||
# build process for InfluxDB. | ||
|
||
BUILD_DIR=$HOME/telegraf-build | ||
GO_VERSION=go1.4.2 | ||
|
||
# Executes the given statement, and exits if the command returns a non-zero code. | ||
function exit_if_fail { | ||
command=$@ | ||
echo "Executing '$command'" | ||
$command | ||
rc=$? | ||
if [ $rc -ne 0 ]; then | ||
echo "'$command' returned $rc." | ||
exit $rc | ||
fi | ||
} | ||
|
||
source $HOME/.gvm/scripts/gvm | ||
exit_if_fail gvm use $GO_VERSION | ||
|
||
# Set up the build directory, and then GOPATH. | ||
exit_if_fail mkdir $BUILD_DIR | ||
export GOPATH=$BUILD_DIR | ||
exit_if_fail mkdir -p $GOPATH/src/github.com/influxdb | ||
|
||
# Dump some test config to the log. | ||
echo "Test configuration" | ||
echo "========================================" | ||
echo "\$HOME: $HOME" | ||
echo "\$GOPATH: $GOPATH" | ||
echo "\$CIRCLE_BRANCH: $CIRCLE_BRANCH" | ||
|
||
# Move the checked-out source to a better location. | ||
exit_if_fail mv $HOME/telegraf $GOPATH/src/github.com/influxdb | ||
exit_if_fail cd $GOPATH/src/github.com/influxdb/telegraf | ||
exit_if_fail git branch --set-upstream-to=origin/$CIRCLE_BRANCH $CIRCLE_BRANCH | ||
|
||
# Install the code. | ||
exit_if_fail cd $GOPATH/src/github.com/influxdb/telegraf | ||
exit_if_fail go get -t -d -v ./... | ||
exit_if_fail git checkout $CIRCLE_BRANCH # 'go get' switches to master. Who knew? Switch back. | ||
exit_if_fail go build -v ./... | ||
|
||
# Run the tests. | ||
exit_if_fail [ `git ls-files | grep '.go$' | xargs gofmt -l 2>&1 | wc -l` -eq 0 ] | ||
exit_if_fail go tool vet --composites=false . | ||
exit_if_fail make test-short | ||
|
||
exit $rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,11 @@ | ||
dependencies: | ||
post: | ||
# install golint | ||
- go get github.com/golang/lint/golint | ||
# install binaries | ||
- go install ./... | ||
machine: | ||
pre: | ||
- bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) | ||
- source $HOME/.gvm/scripts/gvm; gvm install go1.4.2 --binary | ||
|
||
dependencies: | ||
override: | ||
- echo "Dummy override, so no Circle dependencies execute" | ||
test: | ||
pre: | ||
# Vet go code for any potential errors | ||
- go vet ./... | ||
# Verify that all files are properly go formatted | ||
- "[ `git ls-files | grep '.go$' | xargs gofmt -l 2>&1 | wc -l` -eq 0 ]" | ||
# Only docker-compose up kafka, the other services are already running | ||
# see: https://circleci.com/docs/environment#databases | ||
# - docker-compose up -d kafka | ||
override: | ||
# Enforce that testutil, cmd, and main directory are fully linted | ||
- golint . | ||
- golint testutil/... | ||
- golint cmd/... | ||
# Run short unit tests | ||
- make test-short | ||
# TODO run full unit test suite | ||
override: | ||
- bash circle-test.sh |