add check for gopkgs to run dep ensure on changes (#268)

* add check for gopkgs to run dep ensure on changes

also remove windows line endings on .travis.yml again

* clean up script
This commit is contained in:
Rob j Loranger
2018-07-14 11:48:09 -07:00
committed by Michal Pristas
parent e6355881cc
commit 6ebc8f0c85
2 changed files with 59 additions and 37 deletions
+38 -37
View File
@@ -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
+21
View File
@@ -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