Skip to content

Commit

Permalink
chore: simplify tools installation and management with mise
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer04 committed Oct 25, 2024
1 parent 9ce405a commit acf6726
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 206 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ generators/
Dockerfile*
test/
keps/
third_party/
*.md
6 changes: 0 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ updates:
- k8s.io/klog/*
- k8s.io/utils
- k8s.io/kube-openapi
- package-ecosystem: gomod
directory: /third_party/
schedule:
interval: daily
labels:
- dependencies
- package-ecosystem: github-actions
directory: /
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: third_party/go.mod
go-version-file: go.mod

- uses: jdx/mise-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: setup golang
uses: actions/setup-go@v5
with:
go-version-file: third_party/go.mod
go-version-file: go.mod
- uses: jdx/mise-action@v2
with:
install: false
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ railgun
*~

# Delve Debugger Output
__debug_bin
__debug_bin*

# tmp files
client-gen-tmp/*
Expand Down
4 changes: 3 additions & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[env]

MISE_DATA_DIR='bin/'

[settings]
experimental = true # To enable installation of Go tools from source with mise.
2 changes: 2 additions & 0 deletions .tools_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ gojunit-report: "2.1.0"
gotestsum: "1.12.0"
# renovate: datasource=github-releases depName=dominikh/go-tools
staticcheck: "2024.1.1"
# renovate: datasource=github-releases depName=go-delve/delve
delve: "1.23.1"
40 changes: 13 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ endif
# Configuration - Golang
# ------------------------------------------------------------------------------

export GO111MODULE=on

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

ifeq (Darwin,$(shell uname -s))
LDFLAGS_COMMON ?= -extldflags=-Wl,-ld_classic
endif
Expand All @@ -49,11 +40,6 @@ LDFLAGS_METADATA ?= \

PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

.PHONY: _download_tool
_download_tool:
(cd third_party && go mod tidy && \
GOBIN=$(PROJECT_DIR)/bin go generate -tags=third_party ./$(TOOL).go )

TOOLS_VERSIONS_FILE = .tools_versions.yaml

MISE := $(shell which mise)
Expand Down Expand Up @@ -109,15 +95,14 @@ GOTESTSUM_VERSION = $(shell yq -ojson -r '.gotestsum' < $(TOOLS_VERSIONS_FILE))
GOTESTSUM = $(PROJECT_DIR)/bin/installs/gotestsum/$(GOTESTSUM_VERSION)/bin/gotestsum
.PHONY: gotestsum
gotestsum: ## Download gotestsum locally if necessary.
@$(MAKE) mise-plugin-install DEP=gotestsum URL=https://github.com/pmalek/mise-gotestsum.git
@$(MAKE) mise-install DEP_VER=gotestsum
@$(MAKE) mise-plugin-install DEP=gotestsum
@$(MAKE) mise-install DEP_VER=gotestsum@$(GOTESTSUM_VERSION)

CRD_REF_DOCS_VERSION = $(shell yq -ojson -r '.crd-ref-docs' < $(TOOLS_VERSIONS_FILE))
CRD_REF_DOCS = $(PROJECT_DIR)/bin/crd-ref-docs
CRD_REF_DOCS = $(PROJECT_DIR)/bin/installs/go-github-com-elastic-crd-ref-docs/$(CRD_REF_DOCS_VERSION)/bin/crd-ref-docs
.PHONY: crd-ref-docs
crd-ref-docs: ## Download crd-ref-docs locally if necessary.
GOBIN=$(PROJECT_DIR)/bin go install -v \
github.com/elastic/crd-ref-docs@v$(CRD_REF_DOCS_VERSION)
$(MAKE) mise-install DEP_VER=go:github.com/elastic/crd-ref-docs@$(CRD_REF_DOCS_VERSION)

SKAFFOLD_VERSION = $(shell yq -ojson -r '.skaffold' < $(TOOLS_VERSIONS_FILE))
SKAFFOLD = $(PROJECT_DIR)/bin/installs/skaffold/$(SKAFFOLD_VERSION)/bin/skaffold
Expand All @@ -133,23 +118,24 @@ yq: mise # Download yq locally if necessary.
@$(MAKE) mise-plugin-install DEP=yq
@$(MAKE) mise-install DEP_VER=yq@$(YQ_VERSION)

DLV = $(PROJECT_DIR)/bin/dlv
DELVE_VERSION = $(shell yq -ojson -r '.delve' < $(TOOLS_VERSIONS_FILE))
DLV = $(PROJECT_DIR)/bin/installs/go-github-com-go-delve-delve-cmd-dlv/$(DELVE_VERSION)/bin/dlv
.PHONY: dlv
dlv: ## Download dlv locally if necessary.
@$(MAKE) _download_tool TOOL=dlv
$(MAKE) mise-install DEP_VER=go:github.com/go-delve/delve/cmd/dlv@$(DELVE_VERSION)

SETUP_ENVTEST_VERSION = $(shell yq -ojson -r '.setup-envtest' < $(TOOLS_VERSIONS_FILE))
SETUP_ENVTEST = $(PROJECT_DIR)/bin/installs/setup-envtest/$(SETUP_ENVTEST_VERSION)/bin/setup-envtest
.PHONY: setup-envtest
setup-envtest: mise ## Download setup-envtest locally if necessary.
@$(MAKE) mise-plugin-install DEP=setup-envtest URL=https://github.com/pmalek/mise-setup-envtest.git
@$(MISE) install setup-envtest@$(SETUP_ENVTEST_VERSION)
@$(MAKE) mise-plugin-install DEP=setup-envtest
@$(MAKE) mise-install DEP_VER=setup-envtest@$(SETUP_ENVTEST_VERSION)

STATICCHECK_VERSION = $(shell yq -ojson -r '.staticcheck' < $(TOOLS_VERSIONS_FILE))
STATICCHECK = $(PROJECT_DIR)/bin/installs/staticcheck/$(STATICCHECK_VERSION)/bin/staticcheck
.PHONY: staticcheck.download
staticcheck.download: ## Download staticcheck locally if necessary.
@$(MAKE) mise-plugin-install DEP=staticcheck URL=https://github.com/pbr0ck3r/asdf-staticcheck.git
@$(MAKE) mise-plugin-install DEP=staticcheck
@$(MISE) install staticcheck@$(STATICCHECK_VERSION)

GOJUNIT_REPORT_VERSION = $(shell yq -ojson -r '.gojunit-report' < $(TOOLS_VERSIONS_FILE))
Expand Down Expand Up @@ -209,7 +195,7 @@ fmt:
go fmt ./...

.PHONY: lint
lint: verify.tidy golangci-lint staticcheck
lint: verify.tidy golangci-lint staticcheck

.PHONY: golangci-lint
golangci-lint: golangci-lint.download
Expand Down Expand Up @@ -647,7 +633,7 @@ _ensure-namespace:
@kubectl create ns $(KONG_NAMESPACE) 2>/dev/null || true

.PHONY: debug
debug: install _ensure-namespace
debug: dlv install _ensure-namespace
$(DLV) debug ./internal/cmd/main.go -- \
--anonymous-reports=false \
--kong-admin-url $(KONG_ADMIN_URL) \
Expand All @@ -667,7 +653,7 @@ debug: install _ensure-namespace
# specific substitution paths can be isolated to this project only and not shared
# across projects under $HOME or common XDG_CONFIG_HOME.
.PHONY: debug.connect
debug.connect:
debug.connect: dlv
XDG_CONFIG_HOME="$(PROJECT_DIR)/.config" $(DLV) connect localhost:40000

SKAFFOLD_DEBUG_PROFILE ?= debug_multi_gw
Expand Down
9 changes: 0 additions & 9 deletions third_party/dlv.go

This file was deleted.

41 changes: 0 additions & 41 deletions third_party/go.mod

This file was deleted.

111 changes: 0 additions & 111 deletions third_party/go.sum

This file was deleted.

7 changes: 0 additions & 7 deletions third_party/looppointer.go

This file was deleted.

0 comments on commit acf6726

Please sign in to comment.