feat(makefile): improvements to the makefile and use gotestsum [EE-5439] (#8906)

* makefile improvements. use gotestsum

* increase timeout
pull/8908/head
Matt Hook 2023-05-05 14:35:32 +12:00 committed by GitHub
parent cfed481d6e
commit f092b85f55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 30 deletions

View File

@ -12,4 +12,4 @@ jobs:
CONFLICT_LABEL_NAME: 'has conflicts' CONFLICT_LABEL_NAME: 'has conflicts'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAX_RETRIES: 5 MAX_RETRIES: 5
WAIT_MS: 5000 WAIT_MS: 10000

View File

@ -4,19 +4,20 @@
PLATFORM=$(shell go env GOOS) PLATFORM=$(shell go env GOOS)
ARCH=$(shell go env GOARCH) ARCH=$(shell go env GOARCH)
TAG=latest
SWAG_VERSION=v1.8.11
# build target, can be one of "production", "testing", "development" # build target, can be one of "production", "testing", "development"
ENV=development ENV=development
WEBPACK_CONFIG=webpack/webpack.$(ENV).js WEBPACK_CONFIG=webpack/webpack.$(ENV).js
TAG=latest
SWAG=go run github.com/swaggo/swag/cmd/swag@v1.8.11
GOTESTSUM=go run gotest.tools/gotestsum@latest
# Don't change anything below unless you know what you're doing
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
.PHONY: help build-storybook build-client devops download-binaries tidy clean client-deps
##@ Building ##@ Building
.PHONY: init-dist build-storybook build build-client build-server build-image devops
init-dist: init-dist:
@mkdir -p dist @mkdir -p dist
@ -31,7 +32,7 @@ build-client: init-dist client-deps ## Build the client
build-server: init-dist ## Build the server binary build-server: init-dist ## Build the server binary
./build/build_binary.sh "$(PLATFORM)" "$(ARCH)" ./build/build_binary.sh "$(PLATFORM)" "$(ARCH)"
build-image: build ## Build the Portainer image build-image: deps build ## Build the Portainer image locally
docker buildx build --load -t portainerci/portainer:$(TAG) -f build/linux/Dockerfile . docker buildx build --load -t portainerci/portainer:$(TAG) -f build/linux/Dockerfile .
devops: clean init-dist download-binaries build-client ## Build the server binary for CI devops: clean init-dist download-binaries build-client ## Build the server binary for CI
@ -39,42 +40,52 @@ devops: clean init-dist download-binaries build-client ## Build the server binar
@./build/build_binary_azuredevops.sh "$(PLATFORM)" "$(ARCH)" @./build/build_binary_azuredevops.sh "$(PLATFORM)" "$(ARCH)"
##@ Dependencies ##@ Dependencies
.PHONY: deps download-binaries client-deps tidy
deps: download-binaries client-deps ## Download all build and client dependancies
download-binaries: ## Download dependant binaries download-binaries: ## Download dependant binaries
@./build/download_binaries.sh $(PLATFORM) $(ARCH) @./build/download_binaries.sh $(PLATFORM) $(ARCH)
tidy: ## Tidy up the go.mod file
cd api && go mod tidy
client-deps: ## Install client dependencies client-deps: ## Install client dependencies
yarn yarn
##@ Cleanup tidy: ## Tidy up the go.mod file
cd api && go mod tidy
##@ Cleanup
.PHONY: clean
clean: ## Remove all build and download artifacts clean: ## Remove all build and download artifacts
@echo "Clearing the dist directory..." @echo "Clearing the dist directory..."
@rm -rf dist/* @rm -rf dist/*
##@ Testing ##@ Testing
.PHONY: test test-client test-server
test: test-server test-client ## Run all tests
test-client: ## Run client tests test-client: ## Run client tests
yarn test yarn test
test-server: ## Run server tests test-server: ## Run server tests
cd api && go test -v ./... cd api && $(GOTESTSUM) --format pkgname-and-test-fails --format-hide-empty-pkg --hide-summary skipped -- -cover ./...
test: test-client test-server ## Run all tests
##@ Dev ##@ Dev
.PHONY: dev dev-client dev-server
dev: ## Run both the client and server in development mode
make dev-server
make dev-client
dev-client: ## Run the client in development mode dev-client: ## Run the client in development mode
yarn dev yarn dev
dev-server: build-image ## Run the server in development mode dev-server: ## Run the server in development mode
@./dev/run_container.sh @./dev/run_container.sh
##@ Format ##@ Format
.PHONY: format format-client format-server
format: format-client format-server ## Format all code
format-client: ## Format client code format-client: ## Format client code
yarn format yarn format
@ -82,10 +93,8 @@ format-client: ## Format client code
format-server: ## Format server code format-server: ## Format server code
cd api && go fmt ./... cd api && go fmt ./...
format: format-client format-server ## Format all code
##@ Lint ##@ Lint
.PHONY: lint lint-client lint-server
lint: lint-client lint-server ## Lint all code lint: lint-client lint-server ## Lint all code
lint-client: ## Lint client code lint-client: ## Lint client code
@ -95,17 +104,14 @@ lint-server: ## Lint server code
cd api && go vet ./... cd api && go vet ./...
##@ Extension ##@ Extension
.PHONY: dev-extension
dev-extension: build-server build-client ## Run the extension in development mode dev-extension: build-server build-client ## Run the extension in development mode
make local -f build/docker-extension/Makefile make local -f build/docker-extension/Makefile
##@ Docs ##@ Docs
.PHONY: docs-build docs-validate docs-clean docs-validate-clean
docs-deps: ## Install docs dependencies docs-build: ## Build docs
go install github.com/swaggo/swag/cmd/swag@$(SWAG_VERSION) cd api && $(SWAG) init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./
docs-build: docs-deps ## Build docs
cd api && swag init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./
docs-validate: docs-build ## Validate docs docs-validate: docs-build ## Validate docs
yarn swagger2openapi --warnOnly api/docs/swagger.yaml -o api/docs/openapi.yaml yarn swagger2openapi --warnOnly api/docs/swagger.yaml -o api/docs/openapi.yaml
@ -117,6 +123,6 @@ docs-clean: ## Clean docs
docs-validate-clean: docs-validate docs-clean ## Validate and clean docs docs-validate-clean: docs-validate docs-clean ## Validate and clean docs
##@ Helpers ##@ Helpers
.PHONY: help
help: ## Display this help help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) @awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

View File

@ -18,7 +18,7 @@ func TestGet(t *testing.T) {
return return
} }
result := Get(data, "data.yesterday", "sunrise") result := Get(data, "data.yesterday", "sunrise")
fmt.Printf("result: %s", result) fmt.Printf("result: %s\n", result)
expected := "06:19" expected := "06:19"
assert.Equal(t, expected, result) assert.Equal(t, expected, result)
}) })
@ -31,7 +31,7 @@ func TestGet(t *testing.T) {
return return
} }
result := Get(data, "data.yesterday", "sunrise") result := Get(data, "data.yesterday", "sunrise")
fmt.Printf("result: %s", result) fmt.Printf("result: %s\n", result)
expected := "" expected := ""
assert.Equal(t, expected, result) assert.Equal(t, expected, result)
}) })