Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Jun 10, 2019
1 parent ad044c9 commit 4477cee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,39 @@ TEST_FLAGS ?=

.PHONY: setup
setup: ## Install dev tools
@echo ">> installing dev tools"
@if [ ! -f $(GOPATH)/bin/golangci-lint ]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.12.5; \
fi

.PHONY: test
test: ## Run all the tests
@echo ">> running tests"
go test $(TEST_OPTS) -v -covermode=atomic -count=1 -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=30s $(TEST_FLAGS)

.PHONY: cover
cover: test ## Run all the tests and opens the coverage report
@echo ">> generating test coverage"
go tool cover -html=coverage.txt

.PHONY: fmt
fmt: ## Run gofmt and goimports on all go files
@echo ">> running gofmt"
@find . -name '*.go' -not -wholename './rpc/*' -not -wholename './ui/*' -not -wholename './swagger/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done

.PHONY: lint
lint: ## Run all the linters
@echo ">> running golangci-lint"
golangci-lint run

.PHONY: clean
clean: ## Remove built binaries
@echo ">> running go clean"
go clean -i $(SOURCE_FILES)

.PHONY: proto
proto: ## Build protobufs
@echo ">> generating protobufs"
protoc -I/usr/local/include -I. \
-I $(GOPATH)/src \
-I $(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
Expand All @@ -47,23 +54,36 @@ proto: ## Build protobufs

.PHONY: assets
assets: ## Build the ui and run go generate
@echo ">> generating assets"
@cd ./ui; yarn install && yarn run build; cd ..
go generate ./...

.PHONY: check_assets
check_assets: assets
@echo ">> checking that assets are up-to-date"
@if ! (cd ./ui && git diff --exit-code); then \
echo "Run 'make assets' and commit the changes to fix the error."; \
exit 1; \
fi

.PHONY: build
build: ## Build a local copy
@echo ">> building a local copy"
go build -o ./bin/$(PROJECT) ./cmd/$(PROJECT)/.

.PHONY: dev
dev: ## Build and run in development mode
@echo ">> building and running in development mode"
go run ./cmd/$(PROJECT)/. --config ./config/local.yml

.PHONY: snapshot
snapshot: ## Build a snapshot version
@echo ">> building a snapshot version"
@./build/release/snapshot

.PHONY: release
release: ## Build and publish a release
@echo ">> building and publishing a release"
@./build/release/release

.PHONY: help
Expand Down
3 changes: 0 additions & 3 deletions build/release/release
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ cd "$(dirname "$0")/../.." || exit
read -r -p "Are you sure? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "==> Building and releasing with goreleaser"

docker run --rm --privileged \
-v "$PWD":/flipt \
-v /var/run/docker.sock:/var/run/docker.sock \
Expand All @@ -20,6 +18,5 @@ then
-e DOCKER_PASSWORD \
goreleaser/goreleaser:"$GORELEASER_VERSION"-cgo --rm-dist

echo "==> Publishing docs"
mkdocs gh-deploy
fi
2 changes: 0 additions & 2 deletions build/release/snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ GORELEASER_VERSION=v0.106

cd "$(dirname "$0")/../.." || exit

echo "==> Building snapshot with goreleaser"

docker run --rm --privileged \
-v "$PWD":/flipt \
-v /var/run/docker.sock:/var/run/docker.sock \
Expand Down

0 comments on commit 4477cee

Please sign in to comment.