Skip to content

Commit

Permalink
quote more bwplotka/bingo#26
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
Adrian Cole committed Jun 7, 2021
1 parent 5ba6be4 commit 06a9b47
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions .bingo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ reference as a variable like `$(GOIMPORTS)`.

This differs slightly from the defaults of the Bingo project:
* ENV variable support is not included as this project only uses `make`
* Quotes more in `Variables.mk` for windows per https://github.com/bwplotka/bingo/issues/26
10 changes: 5 additions & 5 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ GO ?= $(shell which go)
#
#command: $(GOIMPORTS)
# @echo "Running goimports"
# @$(GOIMPORTS) <flags/args..>
# @"$(GOIMPORTS)" <flags/args..>
#
GOIMPORTS := $(GOBIN)/goimports-v0.1.2
$(GOIMPORTS): $(BINGO_DIR)/goimports.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/goimports-v0.1.2"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.1.2 "golang.org/x/tools/cmd/goimports"
@cd "$(BINGO_DIR)" && "$(GO)" build -mod=mod -modfile=goimports.mod -o="$(GOBIN)/goimports-v0.1.2" "golang.org/x/tools/cmd/goimports"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.40.1
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v1.40.1"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.40.1 "github.com/golangci/golangci-lint/cmd/golangci-lint"
@cd "$(BINGO_DIR)" && "$(GO)" build -mod=mod -modfile=golangci-lint.mod -o="$(GOBIN)/golangci-lint-v1.40.1" "github.com/golangci/golangci-lint/cmd/golangci-lint"

GORELEASER := $(GOBIN)/goreleaser-v0.166.0
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/goreleaser-v0.166.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=goreleaser.mod -o=$(GOBIN)/goreleaser-v0.166.0 "github.com/goreleaser/goreleaser"
@cd "$(BINGO_DIR)" && "$(GO)" build -mod=mod -modfile=goreleaser.mod -o="$(GOBIN)/goreleaser-v0.166.0" "github.com/goreleaser/goreleaser"

LICENSER := $(GOBIN)/licenser-v0.6.0
$(LICENSER): $(BINGO_DIR)/licenser.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/licenser-v0.6.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=licenser.mod -o=$(GOBIN)/licenser-v0.6.0 "github.com/liamawhite/licenser"
@cd "$(BINGO_DIR)" && "$(GO)" build -mod=mod -modfile=licenser.mod -o="$(GOBIN)/licenser-v0.6.0" "github.com/liamawhite/licenser"

33 changes: 17 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ include .bingo/Variables.mk

.PHONY: release
release: $(GORELEASER)
@echo "--- release ---"
@$(GORELEASER) release --rm-dist
@echo "--- $@ ---"
@"$(GORELEASER)" release --rm-dist

GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
BIN := dist/getenvoy_$(GOOS)_$(GOARCH)
bin $(BIN): $(GORELEASER)
@echo "--- bin ---"
@$(GORELEASER) build --snapshot --rm-dist
@echo "--- $@ ---"
@"$(GORELEASER)" build --snapshot --rm-dist

##@ Unit, Site and End-to-End tests

TEST_PACKAGES ?= $(shell go list ./... | grep -v -e github.com/tetratelabs/getenvoy/e2e -e github.com/tetratelabs/getenvoy/site)
.PHONY: test
test:
@echo "--- test ---"
@echo "--- $@ ---"
@go test $(TEST_PACKAGES)

# Site tests check the contents of the site directory

.PHONY: test.site
test.site:
@echo "--- test.site ---"
@echo "--- $@ ---"
@go test -v ./site

# End-to-end (e2e) tests run against a compiled binary.
Expand All @@ -56,36 +56,36 @@ test.site:
E2E_GETENVOY_BINARY ?= $(BIN)
.PHONY: e2e
e2e: $(E2E_GETENVOY_BINARY)
@echo "--- e2e ---"
@echo "--- $@ ---"
@go test -parallel 1 -v -failfast ./e2e

##@ Code quality and integrity

COVERAGE_PACKAGES ?= $(shell echo $(TEST_PACKAGES)| tr -s " " ",")
.PHONY: coverage
coverage:
@echo "--- coverage ---"
@echo "--- $@ ---"
@go test -coverprofile=coverage.txt -covermode=atomic --coverpkg $(COVERAGE_PACKAGES) $(TEST_PACKAGES)
@go tool cover -func coverage.txt

.PHONY: lint
lint: $(GOLANGCI_LINT) $(LICENSER) $(GORELEASER) .golangci.yml .goreleaser.yaml ## Run the linters
@echo "--- lint ---"
@$(LICENSER) verify -r .
@$(GOLANGCI_LINT) run --timeout 5m --config .golangci.yml ./...
@$(GORELEASER) check -q
@echo "--- $@ ---"
@"$(LICENSER)" verify -r .
@"$(GOLANGCI_LINT)" run --timeout 5m --config .golangci.yml ./...
@"$(GORELEASER)" check -q

# The goimports tool does not arrange imports in 3 blocks if there are already more than three blocks.
# To avoid that, before running it, we collapse all imports in one block, then run the formatter.
.PHONY: format
format: $(GOIMPORTS) ## Format all Go code
@echo "--- format ---"
@$(LICENSER) apply -r "Tetrate"
@echo "--- $@ ---"
@"$(LICENSER)" apply -r "Tetrate"
@find . -type f -name '*.go' | xargs gofmt -s -w
@for f in `find . -name '*.go'`; do \
awk '/^import \($$/,/^\)$$/{if($$0=="")next}{print}' $$f > /tmp/fmt; \
mv /tmp/fmt $$f; \
$(GOIMPORTS) -w -local github.com/tetratelabs/getenvoy $$f; \
"$(GOIMPORTS)" -w -local github.com/tetratelabs/getenvoy $$f; \
done

# Enforce go version matches what's in go.mod when running `make check` assuming the following:
Expand All @@ -97,6 +97,7 @@ GO_VERSION := $(shell go version)
.PHONY: check
check: ## CI blocks merge until this passes. If this fails, run "make check" locally and commit the difference.
# case statement because /bin/sh cannot do prefix comparison, awk is awkward and assuming /bin/bash is brittle
@echo "--- $@ ---"
@case "$(GO_VERSION)" in $(EXPECTED_GO_VERSION_PREFIX)* ) ;; * ) \
echo "Expected 'go version' to start with $(EXPECTED_GO_VERSION_PREFIX), but it didn't: $(GO_VERSION)"; \
exit 1; \
Expand All @@ -115,4 +116,4 @@ clean: $(GOLANGCI_LINT) ## Clean all binaries
@echo "--- $@ ---"
@rm -rf dist coverage.txt
@go clean -testcache
@$(GOLANGCI_LINT) cache clean
@"$(GOLANGCI_LINT)" cache clean

0 comments on commit 06a9b47

Please sign in to comment.