-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e4dd87
commit 0f9afcd
Showing
12 changed files
with
1,411 additions
and
154 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,7 @@ | ||
# Automatically sets up your devbox environment whenever you cd into this | ||
# directory via our direnv integration: | ||
|
||
eval "$(devbox generate direnv --print-envrc)" | ||
|
||
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/ | ||
# for more details |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
linters: | ||
enable: | ||
- errcheck | ||
- gofmt | ||
- gofumpt | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- nolintlint | ||
- staticcheck | ||
- unused | ||
linters-settings: | ||
nolintlint: | ||
require-explanation: true | ||
require-specific: true | ||
run: | ||
concurrency: 4 | ||
timeout: 5m |
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,7 @@ | ||
extends: default | ||
|
||
rules: | ||
indentation: disable | ||
document-start: disable | ||
comments: disable | ||
line-length: disable |
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,7 +1,4 @@ | ||
SHELL := /bin/bash | ||
GOCMD=go | ||
GOTEST=$(GOCMD) test | ||
GOVET=$(GOCMD) vet | ||
BINARY_NAME=nutanixclient | ||
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true | ||
|
||
|
@@ -20,50 +17,21 @@ build: ## Build your project and put the output binary in bin/ | |
mkdir -p bin | ||
$(GOCMD) build -o bin/$(BINARY_NAME) . | ||
|
||
# go-get-tool will 'go install' any package $2 and install it to $1. | ||
# originally copied from kubebuilder | ||
define go-get-tool | ||
@[ -f $(1) ] || { \ | ||
set -e ;\ | ||
BIN_PATH=$$(realpath $$(dirname $(1))) ;\ | ||
PKG_BIN_NAME=$$(echo "$(2)" | sed 's,^.*/\(.*\)@v.*$$,\1,') ;\ | ||
BIN_NAME=$$(basename $(1)) ;\ | ||
echo "Install dir $$BIN_PATH" ;\ | ||
echo "Downloading $(2)" ;\ | ||
GOBIN=$$BIN_PATH go install $(2) ;\ | ||
[[ $$PKG_BIN_NAME == $$BIN_NAME ]] || mv -f $$BIN_PATH/$$PKG_BIN_NAME $$BIN_PATH/$$BIN_NAME ;\ | ||
} | ||
endef | ||
|
||
TOOLS_BIN_DIR := hack/tools/bin | ||
|
||
$(TOOLS_BIN_DIR): | ||
mkdir -p $(TOOLS_BIN_DIR) | ||
|
||
CONTROLLER_GEN_BIN := controller-gen | ||
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN) | ||
# CRD_OPTIONS define options to add to the CONTROLLER_GEN | ||
CRD_OPTIONS ?= "crd:crdVersions=v1" | ||
|
||
$(CONTROLLER_GEN): $(TOOLS_BIN_DIR) | ||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
||
KEPLOY_VER := v0.7.12 | ||
KEPLOY_BIN := server-$(KEPLOY_VER) | ||
KEPLOY := $(TOOLS_BIN_DIR)/$(KEPLOY_BIN) | ||
KEPLOY_PKG := go.keploy.io/server/cmd/server | ||
|
||
.PHONY: $(KEPLOY) | ||
$(KEPLOY): $(TOOLS_BIN_DIR) | ||
$(call go-get-tool,$(KEPLOY),$(KEPLOY_PKG)@$(KEPLOY_VER)) | ||
|
||
.PHONY: run-keploy | ||
run-keploy: $(KEPLOY) | ||
$(KEPLOY) run & | ||
run-keploy: | ||
server run & | ||
|
||
.PHONY: stop-keploy | ||
stop-keploy: | ||
@-pkill "$(KEPLOY_BIN)" | ||
@-pkill "server" | ||
|
||
generate: $(CONTROLLER_GEN) ## Generate zz_generated.deepcopy.go | ||
$(CONTROLLER_GEN) paths="./..." object:headerFile="hack/boilerplate.go.txt" | ||
|
@@ -75,18 +43,15 @@ clean: ## Remove build related file | |
## Test: | ||
test: run-keploy ## Run the tests of the project | ||
ifeq ($(EXPORT_RESULT), true) | ||
go install github.com/jstemmer/go-junit-report | ||
$(eval OUTPUT_OPTIONS = | tee /dev/tty | go-junit-report -set-exit-code > junit-report.xml) | ||
endif | ||
$(GOTEST) -v -race ./... $(OUTPUT_OPTIONS) | ||
go test -v -race ./... $(OUTPUT_OPTIONS) | ||
@$(MAKE) stop-keploy | ||
|
||
coverage: run-keploy ## Run the tests of the project and export the coverage | ||
$(GOTEST) -cover -covermode=count -coverprofile=profile.cov ./... | ||
$(GOCMD) tool cover -func profile.cov | ||
go test -cover -covermode=count -coverprofile=profile.cov ./... | ||
go tool cover -func profile.cov | ||
ifeq ($(EXPORT_RESULT), true) | ||
go install github.com/AlekSi/gocov-xml | ||
go install github.com/axw/gocov/gocov | ||
gocov convert profile.cov | gocov-xml > coverage.xml | ||
endif | ||
@$(MAKE) stop-keploy | ||
|
@@ -96,18 +61,17 @@ lint: lint-go lint-yaml lint-kubebuilder ## Run all available linters | |
|
||
lint-go: ## Use golintci-lint on your project | ||
$(eval OUTPUT_OPTIONS = $(shell [ "${EXPORT_RESULT}" == "true" ] && echo "--out-format checkstyle ./... | tee /dev/tty > checkstyle-report.xml" || echo "" )) | ||
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:latest-alpine golangci-lint run --enable gofmt --fix --enable gofumpt $(OUTPUT_OPTIONS) | ||
golangci-lint run -v | ||
|
||
lint-yaml: ## Use yamllint on the yaml file of your projects | ||
ifeq ($(EXPORT_RESULT), true) | ||
go install github.com/thomaspoignant/yamllint-checkstyle | ||
$(eval OUTPUT_OPTIONS = | tee /dev/tty | yamllint-checkstyle > yamllint-checkstyle.xml) | ||
endif | ||
docker run --rm -it -v $(shell pwd):/data cytopia/yamllint -c yamllint-config.yaml -f parsable $(shell git ls-files '*.yml' '*.yaml') $(OUTPUT_OPTIONS) | ||
yamllint -c .yamllint --no-warnings -f parsable $(shell git ls-files '*.yml' '*.yaml') $(OUTPUT_OPTIONS) | ||
|
||
.PHONY: lint-kubebuilder | ||
lint-kubebuilder: $(CONTROLLER_GEN) ## Lint Kubebuilder annotations by generating objects and checking if it is successful | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=. | ||
lint-kubebuilder: ## Lint Kubebuilder annotations by generating objects and checking if it is successful | ||
controller-gen $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=. | ||
|
||
## Help: | ||
help: ## Show this help. | ||
|
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,22 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.1/.schema/devbox.schema.json", | ||
"packages": [ | ||
"bash@latest", | ||
"coreutils@latest", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"path:./hack/flakes#go-apidiff", | ||
"path:./hack/flakes#go-mod-upgrade", | ||
"path:./hack/flakes#go-junit-report", | ||
"path:./hack/flakes#gocov", | ||
"path:./hack/flakes#gocov-xml", | ||
"path:./hack/flakes#golangci-lint", | ||
"path:./hack/flakes#yamllint-checkstyle", | ||
"path:./hack/flakes#setup-envtest", | ||
"path:./hack/flakes#keploy" | ||
] | ||
} |
Oops, something went wrong.