Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes bingo for go run #350

Merged
merged 6 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .bingo/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions .bingo/README.md

This file was deleted.

51 changes: 0 additions & 51 deletions .bingo/Variables.mk

This file was deleted.

1 change: 0 additions & 1 deletion .bingo/go.mod

This file was deleted.

5 changes: 0 additions & 5 deletions .bingo/goimports.mod

This file was deleted.

5 changes: 0 additions & 5 deletions .bingo/golangci-lint.mod

This file was deleted.

5 changes: 0 additions & 5 deletions .bingo/goreleaser.mod

This file was deleted.

5 changes: 0 additions & 5 deletions .bingo/hugo.mod

This file was deleted.

5 changes: 0 additions & 5 deletions .bingo/licenser.mod

This file was deleted.

10 changes: 4 additions & 6 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/msi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ jobs:
with:
path: | # TODO: go build cache if we care, noting it is OS-specific
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will sort out the build cache in a different PR as it requires handling Os-specifics!

~/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)"
Expand Down
41 changes: 22 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
golangci_lint := github.com/golangci/golangci-lint/cmd/[email protected]
goreleaser := github.com/goreleaser/[email protected]
hugo := github.com/gohugoio/[email protected]
licenser := github.com/liamawhite/[email protected]

##@ 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
Expand All @@ -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
#
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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; \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing this in a loop is as time consuming as trying to parse wtf ^^ was trying to do

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:
Expand Down Expand Up @@ -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