diff --git a/.travis.yml b/.travis.yml index 406b8626..d983e468 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,37 +1,38 @@ -services: - - mongodb - - postgresql - - redis-server -language: go -install: false -go: - - "1.10.x" -env: - global: - - PATH=${PATH}:./bin - - POP_PATH=$PWD/cmd/proxy - - GO_ENV=test_postgres - - MINIO_ACCESS_KEY=minio - - MINIO_SECRET_KEY=minio123 - - ATHENS_MONGO_STORAGE_URL=mongodb://127.0.0.1:27017 - - CODE_COV=1 -script: - - test -z $(gofmt -s -l $GO_FILES | tee /dev/stderr) # Fail if a .go file hasn't been formatted with gofmt - - golint -set_exit_status $(go list ./... | grep -v '/mocks') # Linter - - go test -race -coverprofile cover.out -covermode atomic ./... # Run all the tests with the race detector and code coverage enabled -before_script: - - mkdir bin - - GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/ - - go get github.com/golang/lint/golint - - wget "https://dl.minio.io/server/minio/release/linux-amd64/minio" - - chmod +x minio && nohup ./minio server . & - - ./scripts/get_buffalo.sh - - go get -u -v golang.org/x/vgo - - buffalo db create - - buffalo db migrate up -after_success: - - if [ "${CODE_COV}" == "1" ]; then - curl -s https://codecov.io/bash -o codecov && bash codecov -X fix; - else - echo codecov not enabled; - fi +services: + - mongodb + - postgresql + - redis-server +language: go +install: false +go: + - "1.10.x" +env: + global: + - PATH=${PATH}:./bin + - POP_PATH=$PWD/cmd/proxy + - GO_ENV=test_postgres + - MINIO_ACCESS_KEY=minio + - MINIO_SECRET_KEY=minio123 + - ATHENS_MONGO_STORAGE_URL=mongodb://127.0.0.1:27017 + - CODE_COV=1 +script: + - test -z $(gofmt -s -l $GO_FILES | tee /dev/stderr) # Fail if a .go file hasn't been formatted with gofmt + - golint -set_exit_status $(go list ./... | grep -v '/mocks') # Linter + - ./scripts/check_deps.sh # Check for Gopkg.* in PR and run dep ensure -dry-run on changes + - go test -race -coverprofile cover.out -covermode atomic ./... # Run all the tests with the race detector and code coverage enabled +before_script: + - mkdir bin + - GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/ + - go get github.com/golang/lint/golint + - wget "https://dl.minio.io/server/minio/release/linux-amd64/minio" + - chmod +x minio && nohup ./minio server . & + - ./scripts/get_buffalo.sh + - go get -u -v golang.org/x/vgo + - buffalo db create + - buffalo db migrate up +after_success: + - if [ "${CODE_COV}" == "1" ]; then + curl -s https://codecov.io/bash -o codecov && bash codecov -X fix; + else + echo codecov not enabled; + fi diff --git a/scripts/check_deps.sh b/scripts/check_deps.sh new file mode 100755 index 00000000..96f139f2 --- /dev/null +++ b/scripts/check_deps.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# check_deps.sh +# this script checks for changes to the files Gopkg.lock and Gopkg.toml +# or more specificaly anything matching Gopkg.* +# +# this is intended to be used in your CI tests +# +# on encountering any changes for these files the script runs dep ensure +# with the -dry-run option to check for any conflicts in versions or digests +# which on any exit code > 0 would suggest that action should be taken +# before a pull request can be merged. + +ChangedFiles=`git diff --name-only master` + +# in the casse that ChangedFiles contains Gopkg run dep ensure +case "$ChangedFiles" in + *Gopkg*) + dep ensure -dry-run + ;; +esac