Skip to content

Commit

Permalink
Make it easier to run all the same commands that Travis does (gomods#362
Browse files Browse the repository at this point in the history
)

* Make it easier to run all the same commands that Travis does

* Add target to install dev tools

* Dirty a temp directory instead of the repo root

* Explain our new make targets

* Set a TMPDIR on travis

* Fix comment
  • Loading branch information
carolynvs authored and Rob j Loranger committed Jul 30, 2018
1 parent afa8314 commit 21cd723
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 14 deletions.
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,15 @@ env:
- ATHENS_MONGO_STORAGE_URL=mongodb://127.0.0.1:27017
- CODE_COV=1
- GO_BINARY_PATH=vgo
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
- TMPDIR=/tmp/
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
- go get github.com/golang/dep/cmd/dep
- make setup-dev-env
- 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
script:
- make verify test-unit
after_success:
- if [ "${CODE_COV}" == "1" ]; then
curl -s https://codecov.io/bash -o codecov && bash codecov -X fix;
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Hurray! We are glad that you want to contribute to our project! 👍

## Verify your work
Run `make verify` to run all the same validations that our CI process runs, such
as checking that the standard go formatting is applied, linting, etc.

## Unit Tests
Run `make test-unit` to run the unit tests.
5 changes: 5 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ this framework to make it as straightforward as possible to get your development
You'll need Buffalo [v0.12.4](https://github.com/gobuffalo/buffalo/releases/tag/v0.12.4) or later to get started on Athens,
so be sure to download the CLI and put it into your `PATH`.

See our [Contributing Guide](CONTRIBUTING.md) for tips on how to submit a pull request when you are ready.

# Initial Development Environment Setup
Athens relies on having a few tools installed locally. Run `make setup-dev-env` to install them.

# Services that Athens Needs

Both the proxy and the registry rely on several services (i.e. databases, etc...) to function
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ run: build
docs:
cd docs && hugo

.PHONY: setup-dev-env
setup-dev-env:
./scripts/get_dev_tools.sh

.PHONY: verify
verify:
./scripts/check_gofmt.sh
./scripts/check_golint.sh
./scripts/check_deps.sh

.PHONY: test
test:
cd cmd/proxy && buffalo test
cd cmd/olympus && buffalo test

.PHONY: test-unit
test-unit:
./scripts/test_unit.sh

.PHONY: olympus-docker
olympus-docker:
docker build -t gopackages/olympus -f cmd/olympus/Dockerfile .
Expand Down
1 change: 1 addition & 0 deletions scripts/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# 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.
set -xeuo pipefail

ChangedFiles=`git diff --name-only master`

Expand Down
8 changes: 8 additions & 0 deletions scripts/check_gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# check_gofmt.sh
# Fail if a .go file hasn't been formatted with gofmt
set -euo pipefail

GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/
test -z $(gofmt -s -l $GO_FILES | tee /dev/stderr)
7 changes: 7 additions & 0 deletions scripts/check_golint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# check_golint.sh
# Run the linter on everything except generated code
set -euo pipefail

golint -set_exit_status $(go list ./... | grep -v '/mocks')
9 changes: 6 additions & 3 deletions scripts/get_buffalo.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash

set -xeuo pipefail

TAR_GZ="buffalo_0.12.3_linux_amd64.tar.gz"
BUFFALO_URL="https://github.com/gobuffalo/buffalo/releases/download/v0.12.3/${TAR_GZ}"
BUFFALO_TARGET_BIN="./bin/buffalo"

curl -L -o ${TAR_GZ} ${BUFFALO_URL}
tar -xvf ${TAR_GZ}
mv buffalo-no-sqlite ${BUFFALO_TARGET_BIN}
curl -L -o ${TMPDIR}${TAR_GZ} ${BUFFALO_URL}
tar -xzf ${TMPDIR}${TAR_GZ} -C ${TMPDIR}
mkdir -p $(dirname ${BUFFALO_TARGET_BIN})
mv ${TMPDIR}/buffalo-no-sqlite ${BUFFALO_TARGET_BIN}
chmod +x ${BUFFALO_TARGET_BIN}
10 changes: 10 additions & 0 deletions scripts/get_dev_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# install_dev_deps.sh
# Ensure that the tools needed to build locally are present
set -xeuo pipefail

go get github.com/golang/lint/golint
go get github.com/golang/dep/cmd/dep
go get -u -v golang.org/x/vgo
./scripts/get_buffalo.sh
7 changes: 7 additions & 0 deletions scripts/test_unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# test_unit.sh
# Run the unit tests with the race detector and code coverage enabled
set -xeuo pipefail

go test -race -coverprofile cover.out -covermode atomic ./...

0 comments on commit 21cd723

Please sign in to comment.