-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle toolbox tasks in makefile inclide (#131)
* prefix for toolbox * refactor * include file * tests
- Loading branch information
Showing
19 changed files
with
341 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## toolbox - start | ||
## Current working directory | ||
TB_LOCALDIR ?= $(shell which cygpath > /dev/null 2>&1 && cygpath -m $$(pwd) || pwd) | ||
## Location to install dependencies to | ||
TB_LOCALBIN ?= $(TB_LOCALDIR)/bin | ||
$(TB_LOCALBIN): | ||
mkdir -p $(TB_LOCALBIN) | ||
|
||
## Tool Binaries | ||
TB_DEEPCOPY_GEN ?= $(TB_LOCALBIN)/deepcopy-gen | ||
TB_GINKGO ?= $(TB_LOCALBIN)/ginkgo | ||
TB_GOLANGCI_LINT ?= $(TB_LOCALBIN)/golangci-lint | ||
TB_GORELEASER ?= $(TB_LOCALBIN)/goreleaser | ||
TB_OAPI_CODEGEN ?= $(TB_LOCALBIN)/oapi-codegen | ||
TB_SEMVER ?= $(TB_LOCALBIN)/semver | ||
|
||
## Tool Versions | ||
# renovate: packageName=k8s.io/code-generator/cmd/deepcopy-gen | ||
TB_DEEPCOPY_GEN_VERSION ?= v0.31.1 | ||
# renovate: packageName=github.com/golangci/golangci-lint/cmd/golangci-lint | ||
TB_GOLANGCI_LINT_VERSION ?= v1.61.0 | ||
# renovate: packageName=github.com/goreleaser/goreleaser/v2 | ||
TB_GORELEASER_VERSION ?= v2.3.2 | ||
# renovate: packageName=github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen | ||
TB_OAPI_CODEGEN_VERSION ?= v2.4.1 | ||
# renovate: packageName=github.com/bakito/semver | ||
TB_SEMVER_VERSION ?= v1.1.3 | ||
|
||
## Tool Installer | ||
.PHONY: tb.deepcopy-gen | ||
tb.deepcopy-gen: $(TB_DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary. | ||
$(TB_DEEPCOPY_GEN): $(TB_LOCALBIN) | ||
test -s $(TB_LOCALBIN)/deepcopy-gen || GOBIN=$(TB_LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(TB_DEEPCOPY_GEN_VERSION) | ||
.PHONY: tb.ginkgo | ||
tb.ginkgo: $(TB_GINKGO) ## Download ginkgo locally if necessary. | ||
$(TB_GINKGO): $(TB_LOCALBIN) | ||
test -s $(TB_LOCALBIN)/ginkgo || GOBIN=$(TB_LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo | ||
.PHONY: tb.golangci-lint | ||
tb.golangci-lint: $(TB_GOLANGCI_LINT) ## Download golangci-lint locally if necessary. | ||
$(TB_GOLANGCI_LINT): $(TB_LOCALBIN) | ||
test -s $(TB_LOCALBIN)/golangci-lint || GOBIN=$(TB_LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(TB_GOLANGCI_LINT_VERSION) | ||
.PHONY: tb.goreleaser | ||
tb.goreleaser: $(TB_GORELEASER) ## Download goreleaser locally if necessary. | ||
$(TB_GORELEASER): $(TB_LOCALBIN) | ||
test -s $(TB_LOCALBIN)/goreleaser || GOBIN=$(TB_LOCALBIN) go install github.com/goreleaser/goreleaser/v2@$(TB_GORELEASER_VERSION) | ||
.PHONY: tb.oapi-codegen | ||
tb.oapi-codegen: $(TB_OAPI_CODEGEN) ## Download oapi-codegen locally if necessary. | ||
$(TB_OAPI_CODEGEN): $(TB_LOCALBIN) | ||
test -s $(TB_LOCALBIN)/oapi-codegen || GOBIN=$(TB_LOCALBIN) go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@$(TB_OAPI_CODEGEN_VERSION) | ||
.PHONY: tb.semver | ||
tb.semver: $(TB_SEMVER) ## Download semver locally if necessary. | ||
$(TB_SEMVER): $(TB_LOCALBIN) | ||
test -s $(TB_LOCALBIN)/semver || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/semver@$(TB_SEMVER_VERSION) | ||
|
||
## Update Tools | ||
.PHONY: tb.update | ||
tb.update: | ||
@rm -f \ | ||
$(TB_LOCALBIN)/deepcopy-gen \ | ||
$(TB_LOCALBIN)/ginkgo \ | ||
$(TB_LOCALBIN)/golangci-lint \ | ||
$(TB_LOCALBIN)/goreleaser \ | ||
$(TB_LOCALBIN)/oapi-codegen \ | ||
$(TB_LOCALBIN)/semver | ||
toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \ | ||
k8s.io/code-generator/cmd/deepcopy-gen@github.com/kubernetes/code-generator \ | ||
github.com/golangci/golangci-lint/cmd/golangci-lint \ | ||
github.com/goreleaser/goreleaser/v2 \ | ||
github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen \ | ||
github.com/bakito/semver | ||
## toolbox - end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,22 @@ | ||
# Include toolbox tasks | ||
include ./.toolbox.mk | ||
|
||
# Run go golanci-lint | ||
lint: golangci-lint | ||
$(GOLANGCI_LINT) run --fix | ||
lint: tb.golangci-lint | ||
$(TB_GOLANGCI_LINT) run --fix | ||
|
||
# Run go mod tidy | ||
tidy: | ||
go mod tidy | ||
|
||
# Run tests | ||
test: ginkgo tidy lint | ||
$(GINKGO) -r --cover --coverprofile=coverage.out | ||
test: tb.ginkgo tidy lint | ||
$(TB_GINKGO) -r --cover --coverprofile=coverage.out | ||
|
||
release: goreleaser semver | ||
@version=$$($(SEMVER)); \ | ||
release: tb.goreleaser tb.semver | ||
@version=$$($(TB_SEMVER)); \ | ||
git tag -s $$version -m"Release $$version" | ||
$(GORELEASER) --clean | ||
|
||
test-release: goreleaser | ||
$(GORELEASER) --skip=publish --snapshot --clean | ||
|
||
## toolbox - start | ||
## Current working directory | ||
LOCALDIR ?= $(shell which cygpath > /dev/null 2>&1 && cygpath -m $$(pwd) || pwd) | ||
## Location to install dependencies to | ||
LOCALBIN ?= $(LOCALDIR)/bin | ||
$(LOCALBIN): | ||
mkdir -p $(LOCALBIN) | ||
|
||
## Tool Binaries | ||
DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen | ||
GINKGO ?= $(LOCALBIN)/ginkgo | ||
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint | ||
GORELEASER ?= $(LOCALBIN)/goreleaser | ||
SEMVER ?= $(LOCALBIN)/semver | ||
|
||
## Tool Versions | ||
# renovate: packageName=k8s.io/code-generator/cmd/deepcopy-gen | ||
DEEPCOPY_GEN_VERSION ?= v0.31.1 | ||
# renovate: packageName=github.com/golangci/golangci-lint/cmd/golangci-lint | ||
GOLANGCI_LINT_VERSION ?= v1.61.0 | ||
# renovate: packageName=github.com/goreleaser/goreleaser/v2 | ||
GORELEASER_VERSION ?= v2.3.2 | ||
# renovate: packageName=github.com/bakito/semver | ||
SEMVER_VERSION ?= v1.1.3 | ||
|
||
## Tool Installer | ||
.PHONY: deepcopy-gen | ||
deepcopy-gen: $(DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary. | ||
$(DEEPCOPY_GEN): $(LOCALBIN) | ||
test -s $(LOCALBIN)/deepcopy-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION) | ||
.PHONY: ginkgo | ||
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary. | ||
$(GINKGO): $(LOCALBIN) | ||
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo | ||
.PHONY: golangci-lint | ||
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. | ||
$(GOLANGCI_LINT): $(LOCALBIN) | ||
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) | ||
.PHONY: goreleaser | ||
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary. | ||
$(GORELEASER): $(LOCALBIN) | ||
test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser/v2@$(GORELEASER_VERSION) | ||
.PHONY: semver | ||
semver: $(SEMVER) ## Download semver locally if necessary. | ||
$(SEMVER): $(LOCALBIN) | ||
test -s $(LOCALBIN)/semver || GOBIN=$(LOCALBIN) go install github.com/bakito/semver@$(SEMVER_VERSION) | ||
$(TB_GORELEASER) --clean | ||
|
||
## Update Tools | ||
.PHONY: update-toolbox-tools | ||
update-toolbox-tools: | ||
@rm -f \ | ||
$(LOCALBIN)/deepcopy-gen \ | ||
$(LOCALBIN)/ginkgo \ | ||
$(LOCALBIN)/golangci-lint \ | ||
$(LOCALBIN)/goreleaser \ | ||
$(LOCALBIN)/semver | ||
toolbox makefile --renovate -f $(LOCALDIR)/Makefile \ | ||
k8s.io/code-generator/cmd/deepcopy-gen@github.com/kubernetes/code-generator \ | ||
github.com/golangci/golangci-lint/cmd/golangci-lint \ | ||
github.com/goreleaser/goreleaser/v2 \ | ||
github.com/bakito/semver | ||
## toolbox - end | ||
test-release: tb.goreleaser | ||
$(TB_GORELEASER) --skip=publish --snapshot --clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.