mirror of
https://github.com/external-secrets/external-secrets.git
synced 2024-12-14 11:57:59 +00:00
Install tools implicitly (#2527)
Signed-off-by: shuheiktgw <s-kitagawa@mercari.com>
This commit is contained in:
parent
59bf53e7a3
commit
5955cbe759
2 changed files with 36 additions and 31 deletions
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
|
@ -106,11 +106,8 @@ jobs:
|
||||||
path: ${{ steps.go.outputs.mod-cache }}
|
path: ${{ steps.go.outputs.mod-cache }}
|
||||||
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
|
||||||
# Check DIff also runs Reviewable which needs golangci-lint installed
|
|
||||||
- name: Check Diff
|
- name: Check Diff
|
||||||
run: |
|
run: |
|
||||||
wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s ${{ env.GOLANGCI_VERSION }}
|
|
||||||
export PATH=$PATH:./bin
|
|
||||||
make check-diff
|
make check-diff
|
||||||
|
|
||||||
unit-tests:
|
unit-tests:
|
||||||
|
@ -148,16 +145,11 @@ jobs:
|
||||||
path: ${{ steps.go.outputs.mod-cache }}
|
path: ${{ steps.go.outputs.mod-cache }}
|
||||||
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-mod-${{ github.sha }}-${{ hashFiles('**/go.sum') }}
|
||||||
|
|
||||||
- name: Add setup-envtest
|
|
||||||
run: |
|
|
||||||
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
|
|
||||||
setup-envtest use ${{env.KUBERNETES_VERSION}} -p env --os $(go env GOOS) --arch $(go env GOARCH)
|
|
||||||
|
|
||||||
- name: Cache envtest binaries
|
- name: Cache envtest binaries
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: /home/runner/.local/share/kubebuilder-envtest/
|
path: bin/k8s
|
||||||
key: ${{ runner.os }}-kubebuilder-${{env.KUBERNETES_VERSION}}
|
key: ${{ runner.os }}-envtest-${{env.KUBERNETES_VERSION}}
|
||||||
|
|
||||||
- name: Run Unit Tests
|
- name: Run Unit Tests
|
||||||
run: |
|
run: |
|
||||||
|
|
55
Makefile
55
Makefile
|
@ -35,8 +35,6 @@ else
|
||||||
GOBIN=$(shell go env GOBIN)
|
GOBIN=$(shell go env GOBIN)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
KUBERNETES_VERSION := '1.24.x'
|
|
||||||
|
|
||||||
# check if there are any existing `git tag` values
|
# check if there are any existing `git tag` values
|
||||||
ifeq ($(shell git tag),)
|
ifeq ($(shell git tag),)
|
||||||
# no tags found - default to initial tag `v0.0.0`
|
# no tags found - default to initial tag `v0.0.0`
|
||||||
|
@ -93,10 +91,9 @@ update-deps:
|
||||||
# Golang
|
# Golang
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: export KUBEBUILDER_ASSETS := $(shell setup-envtest use $(KUBERNETES_VERSION) -p path --os $(shell go env GOOS) --arch $(shell go env GOARCH))
|
test: generate envtest ## Run tests
|
||||||
test: generate ## Run tests
|
|
||||||
@$(INFO) go test unit-tests
|
@$(INFO) go test unit-tests
|
||||||
go test -race -v $(shell go list ./... | grep -v e2e) -coverprofile cover.out
|
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(KUBERNETES_VERSION) -p path --bin-dir $(LOCALBIN))" go test -race -v $(shell go list ./... | grep -v e2e) -coverprofile cover.out
|
||||||
@$(OK) go test unit-tests
|
@$(OK) go test unit-tests
|
||||||
|
|
||||||
.PHONY: test.e2e
|
.PHONY: test.e2e
|
||||||
|
@ -121,30 +118,18 @@ build-%: generate ## Build binary for the specified arch
|
||||||
go build -o '$(OUTPUT_DIR)/external-secrets-linux-$*' main.go
|
go build -o '$(OUTPUT_DIR)/external-secrets-linux-$*' main.go
|
||||||
@$(OK) go build $*
|
@$(OK) go build $*
|
||||||
|
|
||||||
lint.check: ## Check install of golanci-lint
|
lint: golangci-lint ## Run golangci-lint
|
||||||
@if ! golangci-lint --version > /dev/null 2>&1; then \
|
@if ! $(GOLANGCI_LINT) run; then \
|
||||||
echo -e "\033[0;33mgolangci-lint is not installed: run \`\033[0;32mmake lint.install\033[0m\033[0;33m\` or install it from https://golangci-lint.run\033[0m"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
lint.install: ## Install golangci-lint to the go bin dir
|
|
||||||
@if ! golangci-lint --version > /dev/null 2>&1; then \
|
|
||||||
echo "Installing golangci-lint"; \
|
|
||||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.49.0; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
lint: lint.check ## Run golangci-lint
|
|
||||||
@if ! golangci-lint run; then \
|
|
||||||
echo -e "\033[0;33mgolangci-lint failed: some checks can be fixed with \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \
|
echo -e "\033[0;33mgolangci-lint failed: some checks can be fixed with \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
@$(OK) Finished linting
|
@$(OK) Finished linting
|
||||||
|
|
||||||
fmt: lint.check ## Ensure consistent code style
|
fmt: golangci-lint ## Ensure consistent code style
|
||||||
@go mod tidy
|
@go mod tidy
|
||||||
@cd e2e/ && go mod tidy
|
@cd e2e/ && go mod tidy
|
||||||
@go fmt ./...
|
@go fmt ./...
|
||||||
@golangci-lint run --fix
|
@$(GOLANGCI_LINT) run --fix
|
||||||
@$(OK) Ensured consistent code style
|
@$(OK) Ensured consistent code style
|
||||||
|
|
||||||
generate: ## Generate code and crds
|
generate: ## Generate code and crds
|
||||||
|
@ -304,3 +289,31 @@ clean: ## Clean bins
|
||||||
@$(INFO) clean
|
@$(INFO) clean
|
||||||
@rm -f $(OUTPUT_DIR)/external-secrets-linux-*
|
@rm -f $(OUTPUT_DIR)/external-secrets-linux-*
|
||||||
@$(OK) go build $*
|
@$(OK) go build $*
|
||||||
|
|
||||||
|
# ====================================================================================
|
||||||
|
# Build Dependencies
|
||||||
|
|
||||||
|
## Location to install dependencies to
|
||||||
|
LOCALBIN ?= $(shell pwd)/bin
|
||||||
|
$(LOCALBIN):
|
||||||
|
mkdir -p $(LOCALBIN)
|
||||||
|
|
||||||
|
## Tool Binaries
|
||||||
|
ENVTEST ?= $(LOCALBIN)/setup-envtest
|
||||||
|
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
|
||||||
|
|
||||||
|
## Tool Versions
|
||||||
|
GOLANGCI_VERSION := 1.52.2
|
||||||
|
KUBERNETES_VERSION := 1.24.x
|
||||||
|
|
||||||
|
.PHONY: envtest
|
||||||
|
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
|
||||||
|
$(ENVTEST): $(LOCALBIN)
|
||||||
|
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
|
||||||
|
|
||||||
|
.PHONY: golangci-lint
|
||||||
|
.PHONY: $(GOLANGCI_LINT)
|
||||||
|
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
|
||||||
|
$(GOLANGCI_LINT): $(LOCALBIN)
|
||||||
|
test -s $(LOCALBIN)/golangci-lint && $(LOCALBIN)/golangci-lint version --format short | grep -q $(GOLANGCI_VERSION) || \
|
||||||
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) v$(GOLANGCI_VERSION)
|
||||||
|
|
Loading…
Reference in a new issue