2023-05-02 03:13:37 +00:00
|
|
|
# See: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
|
|
|
|
# For a list of valid GOOS and GOARCH values
|
|
|
|
# Note: these can be overriden on the command line e.g. `make PLATFORM=<platform> ARCH=<arch>`
|
|
|
|
PLATFORM=$(shell go env GOOS)
|
|
|
|
ARCH=$(shell go env GOARCH)
|
|
|
|
|
|
|
|
# build target, can be one of "production", "testing", "development"
|
|
|
|
ENV=development
|
|
|
|
WEBPACK_CONFIG=webpack/webpack.$(ENV).js
|
2023-05-05 02:35:32 +00:00
|
|
|
TAG=latest
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-05 02:35:32 +00:00
|
|
|
SWAG=go run github.com/swaggo/swag/cmd/swag@v1.8.11
|
|
|
|
GOTESTSUM=go run gotest.tools/gotestsum@latest
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
# Don't change anything below this line unless you know what you're doing
|
2023-05-05 02:35:32 +00:00
|
|
|
.DEFAULT_GOAL := help
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
|
2023-05-05 02:35:32 +00:00
|
|
|
##@ Building
|
|
|
|
.PHONY: init-dist build-storybook build build-client build-server build-image devops
|
2023-05-02 03:13:37 +00:00
|
|
|
init-dist:
|
2023-05-03 05:13:28 +00:00
|
|
|
@mkdir -p dist
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-03 05:13:28 +00:00
|
|
|
build: build-server build-client ## Build the server and client
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-03 05:13:28 +00:00
|
|
|
build-client: init-dist client-deps ## Build the client
|
|
|
|
export NODE_ENV=$(ENV) && yarn build --config $(WEBPACK_CONFIG)
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-03 05:13:28 +00:00
|
|
|
build-server: init-dist ## Build the server binary
|
|
|
|
./build/build_binary.sh "$(PLATFORM)" "$(ARCH)"
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
build-image: build ## Build the Portainer image locally
|
2023-05-03 05:13:28 +00:00
|
|
|
docker buildx build --load -t portainerci/portainer:$(TAG) -f build/linux/Dockerfile .
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
devops: clean init-dist server-deps build-client ## Build the server binary for CI
|
2023-05-02 03:13:37 +00:00
|
|
|
echo "Building the devops binary..."
|
|
|
|
@./build/build_binary_azuredevops.sh "$(PLATFORM)" "$(ARCH)"
|
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
build-storybook:
|
|
|
|
yarn storybook:build
|
|
|
|
|
|
|
|
##@ Build dependencies
|
|
|
|
.PHONY: deps server-deps client-deps tidy
|
|
|
|
deps-all: server-deps client-deps ## Download all client and server build dependancies
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
server-deps: ## Download dependant server binaries
|
2023-05-02 03:13:37 +00:00
|
|
|
@./build/download_binaries.sh $(PLATFORM) $(ARCH)
|
|
|
|
|
|
|
|
client-deps: ## Install client dependencies
|
|
|
|
yarn
|
|
|
|
|
2023-05-05 02:35:32 +00:00
|
|
|
tidy: ## Tidy up the go.mod file
|
|
|
|
cd api && go mod tidy
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-05 02:35:32 +00:00
|
|
|
|
|
|
|
##@ Cleanup
|
|
|
|
.PHONY: clean
|
2023-05-02 03:13:37 +00:00
|
|
|
clean: ## Remove all build and download artifacts
|
|
|
|
@echo "Clearing the dist directory..."
|
|
|
|
@rm -rf dist/*
|
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
|
2023-05-02 03:13:37 +00:00
|
|
|
##@ Testing
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: test test-client test-server
|
|
|
|
test: test-server test-client ## Run all tests
|
2023-05-02 03:13:37 +00:00
|
|
|
|
|
|
|
test-client: ## Run client tests
|
|
|
|
yarn test
|
|
|
|
|
|
|
|
test-server: ## Run server tests
|
2023-05-05 02:35:32 +00:00
|
|
|
cd api && $(GOTESTSUM) --format pkgname-and-test-fails --format-hide-empty-pkg --hide-summary skipped -- -cover ./...
|
2023-05-02 03:13:37 +00:00
|
|
|
|
|
|
|
##@ Dev
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: dev dev-client dev-server
|
|
|
|
dev: ## Run both the client and server in development mode
|
|
|
|
make dev-server
|
|
|
|
make dev-client
|
2023-05-02 03:13:37 +00:00
|
|
|
|
2023-05-03 05:13:28 +00:00
|
|
|
dev-client: ## Run the client in development mode
|
|
|
|
yarn dev
|
|
|
|
|
2023-05-05 02:35:32 +00:00
|
|
|
dev-server: ## Run the server in development mode
|
2023-05-02 03:13:37 +00:00
|
|
|
@./dev/run_container.sh
|
|
|
|
|
|
|
|
|
|
|
|
##@ Format
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: format format-client format-server
|
|
|
|
|
|
|
|
format: format-client format-server ## Format all code
|
2023-05-02 03:13:37 +00:00
|
|
|
|
|
|
|
format-client: ## Format client code
|
|
|
|
yarn format
|
|
|
|
|
|
|
|
format-server: ## Format server code
|
|
|
|
cd api && go fmt ./...
|
|
|
|
|
|
|
|
##@ Lint
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: lint lint-client lint-server
|
2023-05-03 05:13:28 +00:00
|
|
|
lint: lint-client lint-server ## Lint all code
|
|
|
|
|
2023-05-02 03:13:37 +00:00
|
|
|
lint-client: ## Lint client code
|
|
|
|
yarn lint
|
|
|
|
|
|
|
|
lint-server: ## Lint server code
|
|
|
|
cd api && go vet ./...
|
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
|
2023-05-02 03:13:37 +00:00
|
|
|
##@ Extension
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: dev-extension
|
2023-05-02 03:13:37 +00:00
|
|
|
dev-extension: build-server build-client ## Run the extension in development mode
|
|
|
|
make local -f build/docker-extension/Makefile
|
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
|
2023-05-02 03:13:37 +00:00
|
|
|
##@ Docs
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: docs-build docs-validate docs-clean docs-validate-clean
|
|
|
|
docs-build: ## Build docs
|
|
|
|
cd api && $(SWAG) init -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./
|
2023-05-02 03:13:37 +00:00
|
|
|
|
|
|
|
docs-validate: docs-build ## Validate docs
|
|
|
|
yarn swagger2openapi --warnOnly api/docs/swagger.yaml -o api/docs/openapi.yaml
|
|
|
|
yarn swagger-cli validate api/docs/openapi.yaml
|
|
|
|
|
|
|
|
docs-clean: ## Clean docs
|
|
|
|
rm -rf api/docs
|
|
|
|
|
|
|
|
docs-validate-clean: docs-validate docs-clean ## Validate and clean docs
|
|
|
|
|
2023-05-09 03:19:38 +00:00
|
|
|
|
2023-05-02 03:13:37 +00:00
|
|
|
##@ Helpers
|
2023-05-05 02:35:32 +00:00
|
|
|
.PHONY: help
|
2023-05-02 03:13:37 +00:00
|
|
|
help: ## Display this help
|
2023-05-05 02:35:32 +00:00
|
|
|
@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)
|