diff --git a/.bingo/.gitignore b/.bingo/.gitignore deleted file mode 100644 index 92f50667..00000000 --- a/.bingo/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ - -# Ignore everything -* - -# But not these files: -!.gitignore -!*.mod -!README.md -!Variables.mk - -*tmp.mod diff --git a/.bingo/README.md b/.bingo/README.md deleted file mode 100755 index d6361df5..00000000 --- a/.bingo/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Binary dependencies - -This directory supports tools written in go, but used in `make`. Tools like `goimports` are built -on-demand, and their dependencies do not affect the main project [go.mod](../go.mod). - -Unlike `go run`, binaries here are versioned. Ex `~/go/bin/licenser-v0.6.0` not `~/go/bin/licenser` - -The contents here were generated by [bingo](https://github.com/bwplotka/bingo) but have no runtime -dependency on it in any way. - -Integration in [Makefile](../Makefile) requires inclusion of the [Variables.mk](Variables.mk), then -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` -* you must export GOBIN if your GOPATH includes multiple entries (helps Windows) diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk deleted file mode 100644 index 1797a900..00000000 --- a/.bingo/Variables.mk +++ /dev/null @@ -1,51 +0,0 @@ -# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.5.1. DO NOT EDIT. -# All tools are designed to be build inside $GOBIN. -BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -GOPATH ?= $(shell go env GOPATH) -# We assume GOPATH has a single entry and those who don't must override GOBIN -# While substituting path separators is easy, element separators is tricky due to c:\ in Windows. -GOBIN ?= $(subst \,/,${GOPATH})/bin -GO ?= $(shell which go) - -# Below generated variables ensure that every time a tool under each variable is invoked, the correct version -# will be used; reinstalling only if needed. -# For example for goimports variable: -# -# In your main Makefile (for non array binaries): -# -#include .bingo/Variables.mk # Assuming -dir was set to .bingo . -# -#command: $(GOIMPORTS) -# @echo "Running goimports" -# @$(GOIMPORTS) -# -GOIMPORTS := $(GOBIN)/goimports-v0.1.5 -$(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.5" - @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=goimports.mod -o=$(GOBIN)/goimports-v0.1.5 "golang.org/x/tools/cmd/goimports" - -GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.42.0 -$(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.42.0" - @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.42.0 "github.com/golangci/golangci-lint/cmd/golangci-lint" - -GORELEASER := $(GOBIN)/goreleaser-v0.174.2 -$(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.174.2" - @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=goreleaser.mod -o=$(GOBIN)/goreleaser-v0.174.2 "github.com/goreleaser/goreleaser" - -HUGO := $(GOBIN)/hugo-v0.86.1 -$(HUGO): $(BINGO_DIR)/hugo.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)/hugo-v0.86.1" - @cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=hugo.mod -o=$(GOBIN)/hugo-v0.86.1 -tags=extended "github.com/gohugoio/hugo" - -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" - diff --git a/.bingo/go.mod b/.bingo/go.mod deleted file mode 100644 index 610249af..00000000 --- a/.bingo/go.mod +++ /dev/null @@ -1 +0,0 @@ -module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. \ No newline at end of file diff --git a/.bingo/goimports.mod b/.bingo/goimports.mod deleted file mode 100644 index b7cd5d78..00000000 --- a/.bingo/goimports.mod +++ /dev/null @@ -1,5 +0,0 @@ -module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT - -go 1.17 - -require golang.org/x/tools v0.1.5 // cmd/goimports diff --git a/.bingo/golangci-lint.mod b/.bingo/golangci-lint.mod deleted file mode 100644 index 891e90eb..00000000 --- a/.bingo/golangci-lint.mod +++ /dev/null @@ -1,5 +0,0 @@ -module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT - -go 1.17 - -require github.com/golangci/golangci-lint v1.42.0 // cmd/golangci-lint diff --git a/.bingo/goreleaser.mod b/.bingo/goreleaser.mod deleted file mode 100644 index 05e5d644..00000000 --- a/.bingo/goreleaser.mod +++ /dev/null @@ -1,5 +0,0 @@ -module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT - -go 1.17 - -require github.com/goreleaser/goreleaser v0.175.0 diff --git a/.bingo/hugo.mod b/.bingo/hugo.mod deleted file mode 100644 index b089d424..00000000 --- a/.bingo/hugo.mod +++ /dev/null @@ -1,5 +0,0 @@ -module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT - -go 1.17 - -require github.com/gohugoio/hugo v0.87.0 diff --git a/.bingo/licenser.mod b/.bingo/licenser.mod deleted file mode 100644 index 728ca55b..00000000 --- a/.bingo/licenser.mod +++ /dev/null @@ -1,5 +0,0 @@ -module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT - -go 1.17 - -require github.com/liamawhite/licenser v0.6.0 diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index 5dae0fc4..ff47c451 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -64,9 +64,8 @@ jobs: with: path: | # TODO: go build cache if we care, noting it is OS-specific ~/go/pkg/mod - ~/go/bin/*-v* - # '.bingo/*.sum' files generate inconsistently when building `~/go/bin/*-v*`. We key '.bingo/*.mod' instead. - key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', '.bingo/*.mod') }} + # Makefile contains go run statements which affect the build cache + key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', 'Makefile') }} restore-keys: test-${{ runner.os }}-${{ env.GO_VERSION }}-go- - name: "Cache Envoy binaries" @@ -128,9 +127,8 @@ jobs: with: path: | # TODO: go build cache if we care, noting it is OS-specific ~/go/pkg/mod - ~/go/bin/*-v* - # '.bingo/*.sum' files generate inconsistently when building `~/go/bin/*-v*`. We key '.bingo/*.mod' instead. - key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', '.bingo/*.mod') }} + # Makefile contains go run statements which affect the build cache + key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', 'Makefile') }} restore-keys: test-${{ runner.os }}-${{ env.GO_VERSION }}-go- - name: "Cache Envoy binaries" diff --git a/.github/workflows/msi.yaml b/.github/workflows/msi.yaml index b5230557..32b6874a 100644 --- a/.github/workflows/msi.yaml +++ b/.github/workflows/msi.yaml @@ -72,9 +72,8 @@ jobs: with: path: | # TODO: go build cache if we care, noting it is OS-specific ~/go/pkg/mod - ~/go/bin/*-v* - # '.bingo/*.sum' files generate inconsistently when building `~/go/bin/*-v*`. We key '.bingo/*.mod' instead. - key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', '.bingo/*.mod') }} + # Makefile contains go run statements which affect the build cache + key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', 'Makefile') }} restore-keys: test-${{ runner.os }}-${{ env.GO_VERSION }}-go- - name: "Build Windows Installer (MSI)" diff --git a/Makefile b/Makefile index 98a110b6..e139e02c 100644 --- a/Makefile +++ b/Makefile @@ -15,23 +15,26 @@ # Make sure we pick up any local overrides. -include .makerc -# bingo manages go binaries needed for building the project -include .bingo/Variables.mk +goimports := golang.org/x/tools/cmd/goimports@v0.1.5 +golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.0 +goreleaser := github.com/goreleaser/goreleaser@v0.175.0 +hugo := github.com/gohugoio/hugo@v0.87.0 +licenser := github.com/liamawhite/licenser@v0.6.0 ##@ Binary distribution .PHONY: release -release: $(GORELEASER) +release: @echo "--- release ---" - @$(GORELEASER) release --rm-dist + @go run $(goreleaser) release --rm-dist GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) BIN := dist/func-e_$(GOOS)_$(GOARCH) -bin $(BIN): $(GORELEASER) +bin $(BIN): @echo "--- bin ---" # skip post hooks on bin so that e2e tests don't need to have osslsigncode installed - @$(GORELEASER) build --snapshot --single-target --skip-post-hooks --rm-dist + @go run $(goreleaser) build --snapshot --single-target --skip-post-hooks --rm-dist # Requires `wixl` from msitools https://wiki.gnome.org/msitools (or `brew install msitools`) # If Windows, you can download from here https://github.com/wixtoolset/wix3/releases @@ -43,9 +46,9 @@ MSI_VERSION ?= 0.0.1 # Right now, the only arch we support is amd64 because Envoy doesn't yet support arm64 on Windows # https://github.com/envoyproxy/envoy/issues/17572 # Once that occurs, we will need to set -arch arm64 and bundle accordingly. -$(WIN_BIN_EXE): $(GORELEASER) +$(WIN_BIN_EXE): @echo "--- win-bin ---" - @GOOS=windows GOARCH=amd64 $(GORELEASER) build --snapshot --single-target --rm-dist + @GOOS=windows GOARCH=amd64 @go run $(goreleaser) build --snapshot --single-target --rm-dist # Default is self-signed while production should be a Digicert signing key # @@ -91,10 +94,10 @@ endif ##@ Test website .PHONY: site -site: $(HUGO) +site: @echo "--- site ---" @git submodule update - @cd site && $(HUGO) server --disableFastRender -D + @cd site && go run $(hugo) server --disableFastRender -D ##@ Unit and End-to-End tests @@ -123,23 +126,23 @@ coverage: @go tool cover -func coverage.txt .PHONY: lint -lint: $(GOLANGCI_LINT) $(LICENSER) $(GORELEASER) .golangci.yml .goreleaser.yaml ## Run the linters +lint: .golangci.yml .goreleaser.yaml ## Run the linters @echo "--- lint ---" - @$(LICENSER) verify -r . - @$(GOLANGCI_LINT) run --timeout 5m --config .golangci.yml ./... - @$(GORELEASER) check -q + @go run $(licenser) verify -r . + @go run $(golangci_lint) run --timeout 5m --config .golangci.yml ./... + @go run $(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 +format: ## Format all Go code @echo "--- format ---" - @$(LICENSER) apply -r "Tetrate" + @go run $(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/func-e $$f; \ + go run $(goimports) -w -local github.com/tetratelabs/func-e $$f; \ done # Enforce go version matches what's in go.mod when running `make check` assuming the following: @@ -167,8 +170,8 @@ check: ## CI blocks merge until this passes. If this fails, run "make check" lo fi .PHONY: clean -clean: $(GOLANGCI_LINT) ## Clean all binaries +clean: ## Clean all binaries @echo "--- $@ ---" @rm -rf dist coverage.txt @go clean -testcache - @$(GOLANGCI_LINT) cache clean + @go run $(golangci_lint) cache clean