mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 14:29:19 +08:00
feat: optimize scripts and makefiles
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for common tasks
|
||||
#
|
||||
|
||||
SHELL := /bin/bash
|
||||
GO:=go
|
||||
DIRS=$(shell ls)
|
||||
DEBUG ?= 0
|
||||
GIT_TAG := $(shell git describe --exact-match --tags --abbrev=0 2> /dev/null || echo untagged)
|
||||
GIT_COMMIT ?= $(shell git rev-parse --short HEAD || echo "0.0.0")
|
||||
BUILD_DATE ?=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') # Blank error: date '+%FT %T %z':"buildDate":"2023-03-31T 20:05:43 +0800"
|
||||
|
||||
# include the common makefile
|
||||
COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
|
||||
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
|
||||
# ROOT_DIR: root directory of the code base
|
||||
ifeq ($(origin ROOT_DIR),undefined)
|
||||
ROOT_DIR := $(abspath $(shell cd $(COMMON_SELF_DIR)/../.. && pwd -P))
|
||||
endif
|
||||
|
||||
# OUTPUT_DIR: The directory where the build output is stored.
|
||||
ifeq ($(origin OUTPUT_DIR),undefined)
|
||||
OUTPUT_DIR := $(ROOT_DIR)/_output
|
||||
$(shell mkdir -p $(OUTPUT_DIR))
|
||||
endif
|
||||
|
||||
# BIN_DIR: Directory where executable files are stored.
|
||||
ifeq ($(origin BIN_DIR),undefined)
|
||||
BIN_DIR := $(OUTPUT_DIR)/bin
|
||||
$(shell mkdir -p $(BIN_DIR))
|
||||
endif
|
||||
|
||||
# TOOLS_DIR: The directory where tools are stored for build and testing.
|
||||
ifeq ($(origin TOOLS_DIR),undefined)
|
||||
TOOLS_DIR := $(OUTPUT_DIR)/tools
|
||||
$(shell mkdir -p $(TOOLS_DIR))
|
||||
endif
|
||||
|
||||
# TMP_DIR: directory where temporary files are stored.
|
||||
ifeq ($(origin TMP_DIR),undefined)
|
||||
TMP_DIR := $(OUTPUT_DIR)/tmp
|
||||
$(shell mkdir -p $(TMP_DIR))
|
||||
endif
|
||||
|
||||
ifeq ($(origin VERSION), undefined)
|
||||
# VERSION := $(shell git describe --abbrev=0 --dirty --always --tags | sed 's/-/./g') #v2.3.3.dirty
|
||||
VERSION := $(shell git describe --tags --always --match="v*" --dirty | sed 's/-/./g') #v2.3.3.631.g00abdc9b.dirty
|
||||
# v2.3.3: git tag
|
||||
endif
|
||||
|
||||
# Check if the tree is dirty. default to dirty(maybe u should commit?)
|
||||
GIT_TREE_STATE:="dirty"
|
||||
ifeq (, $(shell git status --porcelain 2>/dev/null))
|
||||
GIT_TREE_STATE="clean"
|
||||
endif
|
||||
GIT_COMMIT:=$(shell git rev-parse HEAD)
|
||||
|
||||
# Minimum test coverage
|
||||
# can u use make cover COVERAGE=90
|
||||
ifeq ($(origin COVERAGE),undefined)
|
||||
COVERAGE := 60
|
||||
endif
|
||||
|
||||
# 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
|
||||
|
||||
# The OS must be linux when building docker images
|
||||
PLATFORMS ?= linux_amd64 linux_arm64
|
||||
# The OS can be linux/windows/darwin when building binaries
|
||||
# PLATFORMS ?= darwin_amd64 windows_amd64 linux_amd64 linux_arm64
|
||||
|
||||
# only support linux
|
||||
GOOS=linux
|
||||
|
||||
# set a specific PLATFORM, defaults to the host platform
|
||||
ifeq ($(origin PLATFORM), undefined)
|
||||
ifeq ($(origin GOARCH), undefined)
|
||||
GOARCH := $(shell go env GOARCH)
|
||||
endif
|
||||
ifeq ($(origin GOARCH), undefined)
|
||||
GOARCH := $(shell go env GOARCH)
|
||||
endif
|
||||
PLATFORM := $(GOOS)_$(GOARCH)
|
||||
# Use linux as the default OS when building images
|
||||
IMAGE_PLAT := linux_$(GOARCH)
|
||||
else
|
||||
# such as: PLATFORM = linux_amd64
|
||||
GOOS := $(word 1, $(subst _, ,$(PLATFORM)))
|
||||
GOARCH := $(word 2, $(subst _, ,$(PLATFORM)))
|
||||
IMAGE_PLAT := $(PLATFORM)
|
||||
endif
|
||||
|
||||
# Linux command settings
|
||||
# TODO: Whether you need to join utils?
|
||||
FIND := find . ! -path './utils/*' ! -path './vendor/*'
|
||||
XARGS := xargs -r
|
||||
|
||||
# Linux command settings-CODE DIRS Copyright
|
||||
CODE_DIRS := $(ROOT_DIR)/pkg $(ROOT_DIR)/cmd $(ROOT_DIR)/config $(ROOT_DIR)/db $(ROOT_DIR)/deploy $(ROOT_DIR)/deploy_k8s $(ROOT_DIR)/docker-compose_cfg $(ROOT_DIR)/internal $(ROOT_DIR)/scripts $(ROOT_DIR)/test
|
||||
FINDS := find $(CODE_DIRS)
|
||||
|
||||
# Makefile settings: Select different behaviors by determining whether V option is set
|
||||
ifndef V
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
# Copy githook scripts when execute makefile
|
||||
# TODO! GIT_FILE_SIZE_LIMIT=42000000 git commit -m "This commit is allowed file sizes up to 42MB"
|
||||
COPY_GITHOOK:=$(shell cp -f scripts/githooks/* .git/hooks/; chmod +x .git/hooks/*)
|
||||
|
||||
# COMMA: Concatenate multiple strings to form a list of strings
|
||||
COMMA := ,
|
||||
# SPACE: Used to separate strings
|
||||
SPACE :=
|
||||
# SPACE: Replace multiple consecutive Spaces with a single space
|
||||
SPACE +=
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for common tasks
|
||||
|
||||
# Help information for the makefile package
|
||||
define makehelp
|
||||
@printf "\n\033[1mUsage: make <TARGETS> <OPTIONS> ...\033[0m\n\n\\033[1mTargets:\\033[0m\n\n"
|
||||
@sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-28s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /'
|
||||
@printf "\n\033[1m$$USAGE_OPTIONS\033[0m\n"
|
||||
endef
|
||||
|
||||
# Here are some examples of builds
|
||||
define MAKEFILE_EXAMPLE
|
||||
# make build BINS=imctl Only a single imctl binary is built.
|
||||
# make -j (nproc) all Run tidy gen add-copyright format lint cover build concurrently.
|
||||
# make gen Generate all necessary files.
|
||||
# make linux.arm64 imctl is compiled on arm64 platform.
|
||||
# make verify-copyright Verify the license headers for all files.
|
||||
# make install-deepcopy-gen Install deepcopy-gen tools if the license is missing.
|
||||
# make build BINS=imctl V=1 DEBUG=1 Build debug binaries for only imctl.
|
||||
# make multiarch PLATFORMS="linux_arm64 linux_amd64" V=1 Build binaries for both platforms.
|
||||
endef
|
||||
export MAKEFILE_EXAMPLE
|
||||
|
||||
# Define all help functions @printf "\n\033[1mCurrent imctl version information: $(shell imctl version):\033[0m\n\n"
|
||||
define makeallhelp
|
||||
@printf "\n\033[1mMake example:\033[0m\n\n"
|
||||
$(call MAKEFILE_EXAMPLE)
|
||||
@printf "\n\033[1mAriables:\033[0m\n\n"
|
||||
@echo " DEBUG: $(DEBUG)"
|
||||
@echo " BINS: $(BINS)"
|
||||
@echo " PLATFORMS: $(PLATFORMS)"
|
||||
@echo " V: $(V)"
|
||||
endef
|
||||
|
||||
# Help information for other makefile packages
|
||||
CUT_OFF?="---------------------------------------------------------------------------------"
|
||||
HELP_NAME:=$(shell basename $(MAKEFILE_LIST))
|
||||
define smallhelp
|
||||
@sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-35s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /'
|
||||
@echo $(CUT_OFF)
|
||||
endef
|
||||
@@ -0,0 +1,57 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# ==============================================================================
|
||||
# wget https://github.com/google/addlicense/releases/download/v1.0.0/addlicense_1.0.0_Linux_x86_64.tar.gz
|
||||
# Makefile helper functions for copyright
|
||||
#
|
||||
|
||||
LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/LICENSE_TEMPLATES
|
||||
|
||||
## copyright.verify: Validate boilerplate headers for assign files
|
||||
.PHONY: copyright.verify
|
||||
copyright.verify: tools.verify.addlicense
|
||||
@echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory"
|
||||
@$(TOOLS_DIR)/addlicense -v -check -ignore **/test/** -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
||||
@echo "===========> End of boilerplate headers check..."
|
||||
|
||||
## copyright.add: Add the boilerplate headers for all files
|
||||
.PHONY: copyright.add
|
||||
copyright.add: tools.verify.addlicense
|
||||
@echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files"
|
||||
@$(TOOLS_DIR)/addlicense -y $(shell date +"%Y") -v -c "OpenIM." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
||||
@echo "===========> End the copyright is added..."
|
||||
|
||||
# Addlicense Flags:
|
||||
# -c string
|
||||
# copyright holder (default "Google LLC")
|
||||
# -check
|
||||
# check only mode: verify presence of license headers and exit with non-zero code if missing
|
||||
# -f string
|
||||
# license file
|
||||
# -ignore value
|
||||
# file patterns to ignore, for example: -ignore **/*.go -ignore vendor/**
|
||||
# -l string
|
||||
# license type: apache, bsd, mit, mpl (default "apache")
|
||||
# -s Include SPDX identifier in license header. Set -s=only to only include SPDX identifier.
|
||||
# -skip value
|
||||
# [deprecated: see -ignore] file extensions to skip, for example: -skip rb -skip go
|
||||
# -v verbose mode: print the name of the files that are modified or were skipped
|
||||
# -y string
|
||||
# copyright year(s) (default "2023")
|
||||
|
||||
## copyright.help: Show copyright help
|
||||
.PHONY: copyright.help
|
||||
copyright.help: scripts/make-rules/copyright.mk
|
||||
$(call smallhelp)
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for dependencies
|
||||
#
|
||||
|
||||
.PHONY: dependencies.run
|
||||
dependencies.run: dependencies.packages dependencies.tools
|
||||
|
||||
.PHONY: dependencies.packages
|
||||
dependencies.packages:
|
||||
@$(GO) mod tidy
|
||||
|
||||
.PHONY: dependencies.tools
|
||||
dependencies.tools: dependencies.tools.blocker dependencies.tools.critical
|
||||
|
||||
.PHONY: dependencies.tools.blocker
|
||||
dependencies.tools.blocker: go.build.verify $(addprefix tools.verify., $(BLOCKER_TOOLS))
|
||||
|
||||
.PHONY: dependencies.tools.critical
|
||||
dependencies.tools.critical: $(addprefix tools.verify., $(CRITICAL_TOOLS))
|
||||
|
||||
.PHONY: dependencies.tools.trivial
|
||||
dependencies.tools.trivial: $(addprefix tools.verify., $(TRIVIAL_TOOLS))
|
||||
|
||||
## dependencies.help: Print help for dependencies targets
|
||||
.PHONY: dependencies.help
|
||||
dependencies.help: scripts/make-rules/dependencies.mk
|
||||
$(call smallhelp)
|
||||
@@ -0,0 +1,82 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for generate necessary files and docs
|
||||
# https://cloud.redhat.com/blog/kubernetes-deep-dive-code-generation-customresources
|
||||
# ! The stock of code generated by `make gen` should be idempotent
|
||||
#
|
||||
# Questions about go mod instead of go path: https://github.com/kubernetes/kubernetes/issues/117181
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for generate necessary files
|
||||
#
|
||||
|
||||
.PHONY: gen.run
|
||||
#gen.run: gen.errcode gen.docgo
|
||||
gen.run: gen.clean gen.errcode gen.docgo.doc
|
||||
|
||||
.PHONY: gen.errcode
|
||||
gen.errcode: gen.errcode.code gen.errcode.doc
|
||||
|
||||
.PHONY: gen.errcode.code
|
||||
gen.errcode.code: tools.verify.codegen
|
||||
@echo "===========> Generating iam error code go source files"
|
||||
@codegen -type=int ${ROOT_DIR}/internal/pkg/code
|
||||
|
||||
.PHONY: gen.errcode.doc
|
||||
gen.errcode.doc: tools.verify.codegen
|
||||
@echo "===========> Generating error code markdown documentation"
|
||||
@codegen -type=int -doc \
|
||||
-output ${ROOT_DIR}/docs/guide/zh-CN/api/error_code_generated.md ${ROOT_DIR}/internal/pkg/code
|
||||
|
||||
.PHONY: gen.ca.%
|
||||
gen.ca.%:
|
||||
$(eval CA := $(word 1,$(subst ., ,$*)))
|
||||
@echo "===========> Generating CA files for $(CA)"
|
||||
@${ROOT_DIR}/scripts/gencerts.sh generate-iam-cert $(OUTPUT_DIR)/cert $(CA)
|
||||
|
||||
.PHONY: gen.ca
|
||||
gen.ca: $(addprefix gen.ca., $(CERTIFICATES))
|
||||
|
||||
.PHONY: gen.docgo.doc
|
||||
gen.docgo.doc:
|
||||
@echo "===========> Generating missing doc.go for go packages"
|
||||
@${ROOT_DIR}/scripts/gendoc.sh
|
||||
|
||||
.PHONY: gen.docgo.check
|
||||
gen.docgo.check: gen.docgo.doc
|
||||
@n="$$(git ls-files --others '*/doc.go' | wc -l)"; \
|
||||
if test "$$n" -gt 0; then \
|
||||
git ls-files --others '*/doc.go' | sed -e 's/^/ /'; \
|
||||
echo "$@: untracked doc.go file(s) exist in working directory" >&2 ; \
|
||||
false ; \
|
||||
fi
|
||||
|
||||
.PHONY: gen.docgo.add
|
||||
gen.docgo.add:
|
||||
@git ls-files --others '*/doc.go' | $(XARGS) -- git add
|
||||
|
||||
.PHONY: gen.defaultconfigs
|
||||
gen.defaultconfigs:
|
||||
@${ROOT_DIR}/scripts/gen_default_config.sh
|
||||
|
||||
.PHONY: gen.clean
|
||||
gen.clean:
|
||||
@rm -rf ./api/client/{clientset,informers,listers}
|
||||
@$(FIND) -type f -name '*_generated.go' -delete
|
||||
|
||||
## gen.help: show help for gen
|
||||
.PHONY: gen.help
|
||||
gen.help: scripts/make-rules/gen.mk
|
||||
$(call smallhelp)
|
||||
@@ -0,0 +1,195 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Build management helpers. These functions help to set, save and load the
|
||||
#
|
||||
|
||||
GO := go
|
||||
GO_SUPPORTED_VERSIONS ?= |1.15|1.16|1.17|1.18|1.19|1.20|
|
||||
|
||||
GO_LDFLAGS += -X $(VERSION_PACKAGE).gitVersion=$(GIT_TAG) \
|
||||
-X $(VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) \
|
||||
-X $(VERSION_PACKAGE).gitTreeState=$(GIT_TREE_STATE) \
|
||||
-X $(VERSION_PACKAGE).buildDate=$(BUILD_DATE) \
|
||||
-s -w # -s -w deletes debugging information and symbol tables
|
||||
ifeq ($(DEBUG), 1)
|
||||
GO_BUILD_FLAGS += -gcflags "all=-N -l"
|
||||
GO_LDFLAGS=
|
||||
endif
|
||||
|
||||
GO_BUILD_FLAGS += -ldflags "$(GO_LDFLAGS)"
|
||||
|
||||
ifeq ($(GOOS),windows)
|
||||
GO_OUT_EXT := .exe
|
||||
endif
|
||||
|
||||
ifeq ($(ROOT_PACKAGE),)
|
||||
$(error the variable ROOT_PACKAGE must be set prior to including golang.mk, ->/Makefile)
|
||||
endif
|
||||
|
||||
GOPATH ?= $(shell go env GOPATH)
|
||||
ifeq ($(origin GOBIN), undefined)
|
||||
GOBIN := $(GOPATH)/bin
|
||||
endif
|
||||
|
||||
# COMMANDS is Specify all files under ${ROOT_DIR}/cmd/ except those ending in.md
|
||||
COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/*))
|
||||
ifeq (${COMMANDS},)
|
||||
$(error Could not determine COMMANDS, set ROOT_DIR or run in source dir)
|
||||
endif
|
||||
|
||||
# BINS is the name of each file in ${COMMANDS}, excluding the directory path
|
||||
# If there are no files in ${COMMANDS}, or if all files end in.md, ${BINS} will be empty
|
||||
BINS ?= $(foreach cmd,${COMMANDS},$(notdir ${cmd}))
|
||||
ifeq (${BINS},)
|
||||
$(error Could not determine BINS, set ROOT_DIR or run in source dir)
|
||||
endif
|
||||
|
||||
ifeq (${COMMANDS},)
|
||||
$(error Could not determine COMMANDS, set ROOT_DIR or run in source dir)
|
||||
endif
|
||||
ifeq (${BINS},)
|
||||
$(error Could not determine BINS, set ROOT_DIR or run in source dir)
|
||||
endif
|
||||
|
||||
# TODO: EXCLUDE_TESTS variable, which contains the name of the package to be excluded from the test
|
||||
EXCLUDE_TESTS=github.com/OpenIMSDK/Open-IM-Server/test github.com/OpenIMSDK/Open-IM-Server/pkg/log github.com/OpenIMSDK/Open-IM-Server/db github.com/OpenIMSDK/Open-IM-Server/scripts github.com/OpenIMSDK/Open-IM-Server/deploy_k8s github.com/OpenIMSDK/Open-IM-Server/deploy github.com/OpenIMSDK/Open-IM-Server/config
|
||||
|
||||
# ==============================================================================
|
||||
# ❯ tree -L 1 cmd
|
||||
# cmd
|
||||
# ├── openim-sdk-core/ - main.go
|
||||
# ├── open_im_api
|
||||
# ├── open_im_cms_api
|
||||
# ├── open_im_cron_task
|
||||
# ├── open_im_demo
|
||||
# ├── open_im_msg_gateway
|
||||
# ├── open_im_msg_transfer
|
||||
# ├── open_im_push
|
||||
# ├── rpc/open_im_admin_cms/ - main.go
|
||||
# └── test/ - main.go
|
||||
# COMMAND=openim
|
||||
# PLATFORM=linux_amd64
|
||||
# OS=linux
|
||||
# ARCH=amd64
|
||||
# BINS=open_im_api open_im_cms_api open_im_cron_task open_im_demo open_im_msg_gateway open_im_msg_transfer open_im_push
|
||||
# BIN_DIR=/root/workspaces/OpenIM/_output/bin
|
||||
# ==============================================================================
|
||||
|
||||
## go.build: Build binaries
|
||||
.PHONY: go.build
|
||||
go.build: go.build.verify $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS)))
|
||||
@echo "===========> Building binary $(BINS) $(VERSION) for $(PLATFORM)"
|
||||
|
||||
## go.build.verify: Verify that a suitable version of Go exists
|
||||
.PHONY: go.build.verify
|
||||
go.build.verify:
|
||||
ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' && echo 0 || echo 1), 0)
|
||||
$(error unsupported go version. Please make install one of the following supported version: '$(GO_SUPPORTED_VERSIONS)')
|
||||
endif
|
||||
|
||||
.PHONY: go.build.%
|
||||
go.build.%:
|
||||
$(eval COMMAND := $(word 2,$(subst ., ,$*)))
|
||||
$(eval PLATFORM := $(word 1,$(subst ., ,$*)))
|
||||
$(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
|
||||
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
|
||||
@echo "=====> COMMAND=$(COMMAND)"
|
||||
@echo "=====> PLATFORM=$(PLATFORM)"
|
||||
@echo "=====> BIN_DIR=$(BIN_DIR)"
|
||||
@echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS)_$(ARCH)"
|
||||
@mkdir -p $(BIN_DIR)/platforms/$(OS)/$(ARCH)
|
||||
@if [ "$(COMMAND)" == "openim-sdk-core" ]; then \
|
||||
echo "===========> DEBUG: Compilation is not yet supported $(COMMAND)"; \
|
||||
elif [ "$(COMMAND)" == "rpc" ]; then \
|
||||
for d in $(wildcard $(ROOT_DIR)/cmd/rpc/*/); do \
|
||||
cd $$d && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o\
|
||||
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$$(basename $$d)$(GO_OUT_EXT) .; \
|
||||
done; \
|
||||
else \
|
||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o \
|
||||
$(BIN_DIR)/platforms/$(OS)/$(ARCH)/$(COMMAND)$(GO_OUT_EXT) $(ROOT_DIR)/cmd/$(COMMAND)/main.go; \
|
||||
fi
|
||||
|
||||
## go.multiarch: Build multi-arch binaries
|
||||
.PHONY: go.build.multiarch
|
||||
go.build.multiarch: go.build.verify $(foreach p,$(PLATFORMS),$(addprefix go.build., $(addprefix $(p)., $(BINS))))
|
||||
|
||||
## go.lint: Run golangci to lint source codes
|
||||
.PHONY: go.lint
|
||||
go.lint: tools.verify.golangci-lint
|
||||
@echo "===========> Run golangci to lint source codes"
|
||||
@$(BIN_DIR)/golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/...
|
||||
|
||||
## go.test: Run unit test
|
||||
.PHONY: go.test
|
||||
go.test:
|
||||
@$(GO) test ./...
|
||||
|
||||
# ## go.test.junit-report: Run unit test
|
||||
# .PHONY: go.test.junit-report
|
||||
# go.test.junit-report: tools.verify.go-junit-report
|
||||
# @echo "===========> Run unit test > $(TMP_DIR)/report.xml"
|
||||
# @$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 $(GO_BUILD_FLAGS) ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(TMP_DIR)/report.xml
|
||||
# @sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
|
||||
# @echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
|
||||
# @$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html
|
||||
|
||||
## go.test.junit-report: Run unit test
|
||||
.PHONY: go.test.junit-report
|
||||
go.test.junit-report: tools.verify.go-junit-report
|
||||
@echo "===========> Run unit test > $(TMP_DIR)/report.xml"
|
||||
@$(GO) test -v -coverprofile=$(TMP_DIR)/coverage.out 2>&1 ./... | $(TOOLS_DIR)/go-junit-report -set-exit-code > $(OUTPUT_DIR)/report.xml
|
||||
@sed -i '/mock_.*.go/d' $(TMP_DIR)/coverage.out
|
||||
@echo "===========> Test coverage of Go code is reported to $(TMP_DIR)/coverage.html by generating HTML"
|
||||
@$(GO) tool cover -html=$(TMP_DIR)/coverage.out -o $(TMP_DIR)/coverage.html
|
||||
|
||||
## go.test.cover: Run unit test with coverage
|
||||
.PHONY: go.test.cover
|
||||
go.test.cover: go.test.junit-report
|
||||
@touch $(TMP_DIR)/coverage.out
|
||||
@$(GO) tool cover -func=$(TMP_DIR)/coverage.out | \
|
||||
awk -v target=$(COVERAGE) -f $(ROOT_DIR)/scripts/coverage.awk
|
||||
|
||||
## go.format: Run unit test and format codes
|
||||
.PHONY: go.format
|
||||
go.format: tools.verify.golines tools.verify.goimports
|
||||
@echo "===========> Formating codes"
|
||||
@$(FIND) -type f -name '*.go' | $(XARGS) gofmt -s -w
|
||||
@$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/goimports -w -local $(ROOT_PACKAGE)
|
||||
@$(FIND) -type f -name '*.go' | $(XARGS) $(TOOLS_DIR)/golines -w --max-len=120 --reformat-tags --shorten-comments --ignore-generated .
|
||||
@$(GO) mod edit -fmt
|
||||
|
||||
## imports: task to automatically handle import packages in Go files using goimports tool
|
||||
.PHONY: go.imports
|
||||
go.imports: tools.verify.goimports
|
||||
@$(TOOLS_DIR)/goimports -l -w $(SRC)
|
||||
|
||||
## go.updates: Check for updates to go.mod dependencies
|
||||
.PHONY: go.updates
|
||||
go.updates: tools.verify.go-mod-outdated
|
||||
@$(GO) list -u -m -json all | go-mod-outdated -update -direct
|
||||
|
||||
## go.clean: Clean all builds directories and files
|
||||
.PHONY: go.clean
|
||||
go.clean:
|
||||
@echo "===========> Cleaning all builds TMP_DIR($(TMP_DIR)) AND BIN_DIR($(BIN_DIR))"
|
||||
@-rm -vrf $(TMP_DIR) $(BIN_DIR)
|
||||
@echo "===========> End clean..."
|
||||
|
||||
## copyright.help: Show copyright help
|
||||
.PHONY: go.help
|
||||
go.help: scripts/make-rules/golang.mk
|
||||
$(call smallhelp)
|
||||
@@ -0,0 +1,155 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for docker image
|
||||
# TODO: For the time being only used for compilation, it can be arm or amd, please do not delete it, it can be extended with new functions
|
||||
# ==============================================================================
|
||||
# Path: scripts/make-rules/image.mk
|
||||
# docker registry: registry.example.com/namespace/image:tag as: registry.hub.docker.com/cubxxw/<image-name>:<tag>
|
||||
#
|
||||
|
||||
DOCKER := docker
|
||||
DOCKER_SUPPORTED_API_VERSION ?= 1.32|1.40|1.41
|
||||
|
||||
REGISTRY_PREFIX ?= cubxxw
|
||||
BASE_IMAGE = centos:centos8
|
||||
|
||||
EXTRA_ARGS ?= --no-cache
|
||||
_DOCKER_BUILD_EXTRA_ARGS :=
|
||||
|
||||
ifdef HTTP_PROXY
|
||||
_DOCKER_BUILD_EXTRA_ARGS += --build-arg HTTP_PROXY=${HTTP_PROXY}
|
||||
endif
|
||||
|
||||
ifneq ($(EXTRA_ARGS), )
|
||||
_DOCKER_BUILD_EXTRA_ARGS += $(EXTRA_ARGS)
|
||||
endif
|
||||
|
||||
# Determine image files by looking into build/docker/*/Dockerfile
|
||||
IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/build/docker/*)
|
||||
# Determine images names by stripping out the dir names
|
||||
IMAGES ?= $(filter-out tools,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
|
||||
|
||||
# ifeq (${IMAGES},)
|
||||
# $(error Could not determine IMAGES, set ROOT_DIR or run in source dir)
|
||||
# endif
|
||||
|
||||
# ==============================================================================
|
||||
# Image targets
|
||||
# ==============================================================================
|
||||
|
||||
## image.verify: Verify docker version
|
||||
.PHONY: image.verify
|
||||
image.verify:
|
||||
$(eval API_VERSION := $(shell $(DOCKER) version | grep -E 'API version: {1,6}[0-9]' | head -n1 | awk '{print $$3} END { if (NR==0) print 0}' ))
|
||||
$(eval PASS := $(shell echo "$(API_VERSION) > $(DOCKER_SUPPORTED_API_VERSION)" | bc))
|
||||
@if [ $(PASS) -ne 1 ]; then \
|
||||
$(DOCKER) -v ;\
|
||||
echo "Unsupported docker version. Docker API version should be greater than $(DOCKER_SUPPORTED_API_VERSION)"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
## image.daemon.verify: Verify docker daemon experimental features
|
||||
.PHONY: image.daemon.verify
|
||||
image.daemon.verify:
|
||||
$(eval PASS := $(shell $(DOCKER) version | grep -q -E 'Experimental: {1,5}true' && echo 1 || echo 0))
|
||||
@if [ $(PASS) -ne 1 ]; then \
|
||||
echo "Experimental features of Docker daemon is not enabled. Please add \"experimental\": true in '/etc/docker/daemon.json' and then restart Docker daemon."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
## image.build: Build docker images
|
||||
.PHONY: image.build
|
||||
image.build: image.verify go.build.verify $(addprefix image.build., $(addprefix $(IMAGE_PLAT)., $(IMAGES)))
|
||||
|
||||
## image.build.multiarch: Build docker images for all platforms
|
||||
.PHONY: image.build.multiarch
|
||||
image.build.multiarch: image.verify go.build.verify $(foreach p,$(PLATFORMS),$(addprefix image.build., $(addprefix $(p)., $(IMAGES))))
|
||||
|
||||
## image.build.%: Build docker image for a specific platform
|
||||
.PHONY: image.build.%
|
||||
image.build.%: go.build.%
|
||||
$(eval IMAGE := $(COMMAND))
|
||||
$(eval IMAGE_PLAT := $(subst _,/,$(PLATFORM)))
|
||||
@echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)"
|
||||
@mkdir -p $(TMP_DIR)/$(IMAGE)
|
||||
@cat $(ROOT_DIR)/build/docker/$(IMAGE)/Dockerfile\
|
||||
| sed "s#BASE_IMAGE#$(BASE_IMAGE)#g" >$(TMP_DIR)/$(IMAGE)/Dockerfile
|
||||
@cp $(OUTPUT_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)/
|
||||
@DST_DIR=$(TMP_DIR)/$(IMAGE) $(ROOT_DIR)/build/docker/$(IMAGE)/build.sh 2>/dev/null || true
|
||||
$(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE))
|
||||
@if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \
|
||||
$(MAKE) image.daemon.verify ;\
|
||||
$(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) ; \
|
||||
else \
|
||||
$(DOCKER) build $(BUILD_SUFFIX) ; \
|
||||
fi
|
||||
@rm -rf $(TMP_DIR)/$(IMAGE)
|
||||
|
||||
## image.push: Push docker images
|
||||
.PHONY: image.push
|
||||
image.push: image.verify go.build.verify $(addprefix image.push., $(addprefix $(IMAGE_PLAT)., $(IMAGES)))
|
||||
|
||||
## image.push.multiarch: Push docker images for all platforms
|
||||
.PHONY: image.push.multiarch
|
||||
image.push.multiarch: image.verify go.build.verify $(foreach p,$(PLATFORMS),$(addprefix image.push., $(addprefix $(p)., $(IMAGES))))
|
||||
|
||||
## image.push.%: Push docker image for a specific platform
|
||||
.PHONY: image.push.%
|
||||
image.push.%: image.build.%
|
||||
@echo "===========> Pushing image $(IMAGE) $(VERSION) to $(REGISTRY_PREFIX)"
|
||||
$(DOCKER) push $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION)
|
||||
|
||||
## image.manifest.push: Push manifest list for multi-arch images
|
||||
.PHONY: image.manifest.push
|
||||
image.manifest.push: export DOCKER_CLI_EXPERIMENTAL := enabled
|
||||
image.manifest.push: image.verify go.build.verify \
|
||||
$(addprefix image.manifest.push., $(addprefix $(IMAGE_PLAT)., $(IMAGES)))
|
||||
|
||||
## image.manifest.push.%: Push manifest list for multi-arch images for a specific platform
|
||||
.PHONY: image.manifest.push.%
|
||||
image.manifest.push.%: image.push.% image.manifest.remove.%
|
||||
@echo "===========> Pushing manifest $(IMAGE) $(VERSION) to $(REGISTRY_PREFIX) and then remove the local manifest list"
|
||||
@$(DOCKER) manifest create $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION) \
|
||||
$(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION)
|
||||
@$(DOCKER) manifest annotate $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION) \
|
||||
$(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) \
|
||||
--os $(OS) --arch ${ARCH}
|
||||
@$(DOCKER) manifest push --purge $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION)
|
||||
|
||||
# Docker cli has a bug: https://github.com/docker/cli/issues/954
|
||||
# If you find your manifests were not updated,
|
||||
# Please manually delete them in $HOME/.docker/manifests/
|
||||
# and re-run.
|
||||
## image.manifest.remove.%: Remove local manifest list
|
||||
.PHONY: image.manifest.remove.%
|
||||
image.manifest.remove.%:
|
||||
@rm -rf ${HOME}/.docker/manifests/docker.io_$(REGISTRY_PREFIX)_$(IMAGE)-$(VERSION)
|
||||
|
||||
## image.manifest.push.multiarch: Push manifest list for multi-arch images for all platforms
|
||||
.PHONY: image.manifest.push.multiarch
|
||||
image.manifest.push.multiarch: image.push.multiarch $(addprefix image.manifest.push.multiarch., $(IMAGES))
|
||||
|
||||
## image.manifest.push.multiarch.%: Push manifest list for multi-arch images for all platforms for a specific image
|
||||
.PHONY: image.manifest.push.multiarch.%
|
||||
image.manifest.push.multiarch.%:
|
||||
@echo "===========> Pushing manifest $* $(VERSION) to $(REGISTRY_PREFIX) and then remove the local manifest list"
|
||||
REGISTRY_PREFIX=$(REGISTRY_PREFIX) PLATFROMS="$(PLATFORMS)" IMAGE=$* VERSION=$(VERSION) DOCKER_CLI_EXPERIMENTAL=enabled \
|
||||
$(ROOT_DIR)/build/lib/create-manifest.sh
|
||||
|
||||
## image.help: Print help for image targets
|
||||
.PHONY: image.help
|
||||
image.help: scripts/make-rules/image.mk
|
||||
$(call smallhelp)
|
||||
@@ -0,0 +1,42 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for release
|
||||
# Versions are used after merging
|
||||
#
|
||||
|
||||
## release: release the project
|
||||
.PHONY: release.run
|
||||
release.run: release.verify release.ensure-tag
|
||||
@scripts/release.sh
|
||||
|
||||
## release.verify: Check if a tool is installed and install it
|
||||
.PHONY: release.verify
|
||||
release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd
|
||||
|
||||
## release.tag: release the project
|
||||
.PHONY: release.tag
|
||||
release.tag: tools.verify.gsemver release.ensure-tag
|
||||
@git push origin `git describe --tags --abbrev=0`
|
||||
|
||||
## release.ensure-tag: ensure tag
|
||||
.PHONY: release.ensure-tag
|
||||
release.ensure-tag: tools.verify.gsemver
|
||||
@scripts/ensure_tag.sh
|
||||
|
||||
## release.help: Display help information about the release package
|
||||
.PHONY: release.help
|
||||
release.help: scripts/make-rules/release.mk
|
||||
$(call smallhelp)
|
||||
@@ -0,0 +1,222 @@
|
||||
# Copyright © 2023 OpenIMSDK.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ==============================================================================
|
||||
# Makefile helper functions for tools(https://github.com/avelino/awesome-go) -> DIR: {TOOT_DIR}/tools | (go >= 1.19)
|
||||
# Why download to the tools directory, thinking we might often switch Go versions using gvm.
|
||||
#
|
||||
|
||||
# openim build use BUILD_TOOLS
|
||||
BUILD_TOOLS ?= golangci-lint goimports addlicense deepcopy-gen conversion-gen ginkgo go-junit-report go-gitlint
|
||||
# Code analysis tools
|
||||
ANALYSIS_TOOLS = golangci-lint goimports golines go-callvis kube-score
|
||||
# Code generation tools
|
||||
GENERATION_TOOLS = deepcopy-gen conversion-gen protoc-gen-go cfssl rts codegen
|
||||
# Testing tools
|
||||
TEST_TOOLS = ginkgo go-junit-report gotests
|
||||
# tenxun cos tools
|
||||
COS_TOOLS = coscli coscmd
|
||||
# Version control tools
|
||||
VERSION_CONTROL_TOOLS = addlicense go-gitlint git-chglog github-release gsemver
|
||||
# Utility tools
|
||||
UTILITY_TOOLS = go-mod-outdated mockgen gothanks richgo kubeconform
|
||||
# All tools
|
||||
ALL_TOOLS ?= $(ANALYSIS_TOOLS) $(GENERATION_TOOLS) $(TEST_TOOLS) $(VERSION_CONTROL_TOOLS) $(UTILITY_TOOLS) $(COS_TOOLS)
|
||||
|
||||
## tools.install: Install a must tools
|
||||
.PHONY: tools.install
|
||||
tools.install: $(addprefix tools.verify., $(BUILD_TOOLS))
|
||||
|
||||
## tools.install-all: Install all tools
|
||||
.PHONY: tools.install-all
|
||||
tools.install-all: $(addprefix tools.install-all., $(ALL_TOOLS))
|
||||
|
||||
## tools.install.%: Install a single tool in $GOBIN/
|
||||
.PHONY: tools.install.%
|
||||
tools.install.%:
|
||||
@echo "===========> Installing $,The default installation path is $(GOBIN)/$*"
|
||||
@$(MAKE) install.$*
|
||||
|
||||
## tools.install-all.%: Parallelism install a single tool in ./tools/*
|
||||
.PHONY: tools.install-all.%
|
||||
tools.install-all.%:
|
||||
@echo "===========> Installing $,The default installation path is $(TOOLS_DIR)/$*"
|
||||
@$(MAKE) -j $(nproc) install.$*
|
||||
|
||||
## tools.verify.%: Check if a tool is installed and install it
|
||||
.PHONY: tools.verify.%
|
||||
tools.verify.%:
|
||||
@echo "===========> Verifying $* is installed"
|
||||
@if [ ! -f $(TOOLS_DIR)/$* ]; then GOBIN=$(TOOLS_DIR) $(MAKE) tools.install.$*; fi
|
||||
@echo "===========> $* is install in $(TOOLS_DIR)/$*"
|
||||
|
||||
## install.golangci-lint: Install golangci-lint
|
||||
.PHONY: install.golangci-lint
|
||||
install.golangci-lint:
|
||||
@$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
|
||||
## install.goimports: Install goimports, used to format go source files
|
||||
.PHONY: install.goimports
|
||||
install.goimports:
|
||||
@$(GO) install golang.org/x/tools/cmd/goimports@latest
|
||||
|
||||
## install.addlicense: Install addlicense, used to add license header to source files
|
||||
.PHONY: install.addlicense
|
||||
install.addlicense:
|
||||
@$(GO) install github.com/google/addlicense@latest
|
||||
|
||||
## install.deepcopy-gen: Install deepcopy-gen, used to generate deep copy functions
|
||||
.PHONY: install.deepcopy-gen
|
||||
install.deepcopy-gen:
|
||||
@$(GO) install k8s.io/code-generator/cmd/deepcopy-gen@latest
|
||||
|
||||
## install.conversion-gen: Install conversion-gen, used to generate conversion functions
|
||||
.PHONY: install.conversion-gen
|
||||
install.conversion-gen:
|
||||
@$(GO) install k8s.io/code-generator/cmd/conversion-gen@latest
|
||||
|
||||
## install.ginkgo: Install ginkgo to run a single test or set of tests
|
||||
.PHONY: install.ginkgo
|
||||
install.ginkgo:
|
||||
@$(GO) install github.com/onsi/ginkgo/ginkgo@v1.16.2
|
||||
|
||||
## Install go-gitlint: Install go-gitlint, used to check git commit message
|
||||
.PHONY: install.go-gitlint
|
||||
install.go-gitlint:
|
||||
@$(GO) install github.com/marmotedu/go-gitlint/cmd/go-gitlint@latest
|
||||
|
||||
## install.go-junit-report: Install go-junit-report, used to convert go test output to junit xml
|
||||
.PHONY: install.go-junit-report
|
||||
install.go-junit-report:
|
||||
@$(GO) install github.com/jstemmer/go-junit-report@latest
|
||||
|
||||
# ==============================================================================
|
||||
# Tools that might be used include go gvm
|
||||
#
|
||||
|
||||
## install.kube-score: Install kube-score, used to check kubernetes yaml files
|
||||
.PHONY: install.kube-score
|
||||
install.kube-score:
|
||||
@$(GO) install github.com/zegl/kube-score/cmd/kube-score@latest
|
||||
|
||||
## install.kubeconform: Install kubeconform, used to check kubernetes yaml files
|
||||
.PHONY: install.kubeconform
|
||||
install.kubeconform:
|
||||
@$(GO) install github.com/yannh/kubeconform/cmd/kubeconform@latest
|
||||
|
||||
## install.gsemver: Install gsemver, used to generate semver
|
||||
.PHONY: install.gsemver
|
||||
install.gsemver:
|
||||
@$(GO) install github.com/arnaud-deprez/gsemver@latest
|
||||
|
||||
## install.git-chglog: Install git-chglog, used to generate changelog
|
||||
.PHONY: install.git-chglog
|
||||
install.git-chglog:
|
||||
@$(GO) install github.com/git-chglog/git-chglog/cmd/git-chglog@latest
|
||||
|
||||
## install.github-release: Install github-release, used to create github release
|
||||
.PHONY: install.github-release
|
||||
install.github-release:
|
||||
@$(GO) install github.com/github-release/github-release@latest
|
||||
|
||||
## install.coscli: Install coscli, used to upload files to cos
|
||||
# example: ./coscli cp/sync -r /home/off-line/docker-off-line/ cos://openim-1306374445/openim/image/amd/off-line/off-line/ -e cos.ap-guangzhou.myqcloud.com
|
||||
# https://cloud.tencent.com/document/product/436/71763
|
||||
.PHONY: install.coscli
|
||||
install.coscli:
|
||||
@wget -q https://ghproxy.com/https://github.com/tencentyun/coscli/releases/download/v0.13.0-beta/coscli-linux -O ${TOOLS_DIR}/coscli
|
||||
@chmod +x ${TOOLS_DIR}/coscli
|
||||
|
||||
## install.coscmd: Install coscmd, used to upload files to cos
|
||||
.PHONY: install.coscmd
|
||||
install.coscmd:
|
||||
@if which pip &>/dev/null; then pip install coscmd; else pip3 install coscmd; fi
|
||||
|
||||
## install.delve: Install delve, used to debug go program
|
||||
.PHONY: install.delve
|
||||
install.delve:
|
||||
@$(GO) install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
## install.air: Install air, used to hot reload go program
|
||||
.PHONY: install.air
|
||||
install.air:
|
||||
@$(GO) install github.com/cosmtrek/air@latest
|
||||
|
||||
## install.gvm: Install gvm, gvm is a Go version manager, built on top of the official go tool.
|
||||
# github: https://github.com/moovweb/gvm
|
||||
.PHONY: install.gvm
|
||||
install.gvm:
|
||||
@echo "===========> Installing gvm,The default installation path is ~/.gvm/scripts/gvm"
|
||||
@bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
|
||||
@$(shell source /root/.gvm/scripts/gvm)
|
||||
|
||||
## install.golines: Install golines, used to format long lines
|
||||
.PHONY: install.golines
|
||||
install.golines:
|
||||
@$(GO) install github.com/segmentio/golines@latest
|
||||
|
||||
## install.go-mod-outdated: Install go-mod-outdated, used to check outdated dependencies
|
||||
.PHONY: install.go-mod-outdated
|
||||
install.go-mod-outdated:
|
||||
@$(GO) install github.com/psampaz/go-mod-outdated@latest
|
||||
|
||||
## install.mockgen: Install mockgen, used to generate mock functions
|
||||
.PHONY: install.mockgen
|
||||
install.mockgen:
|
||||
@$(GO) install github.com/golang/mock/mockgen@latest
|
||||
|
||||
## install.gotests: Install gotests, used to generate test functions
|
||||
.PHONY: install.gotests
|
||||
install.gotests:
|
||||
@$(GO) install github.com/cweill/gotests/gotests@latest
|
||||
|
||||
## install.protoc-gen-go: Install protoc-gen-go, used to generate go source files from protobuf files
|
||||
.PHONY: install.protoc-gen-go
|
||||
install.protoc-gen-go:
|
||||
@$(GO) install github.com/golang/protobuf/protoc-gen-go@latest
|
||||
|
||||
## install.cfssl: Install cfssl, used to generate certificates
|
||||
.PHONY: install.cfssl
|
||||
install.cfssl:
|
||||
@$(ROOT_DIR)/scripts/install/install.sh iam::install::install_cfssl
|
||||
|
||||
## install.depth: Install depth, used to check dependency tree
|
||||
.PHONY: install.depth
|
||||
install.depth:
|
||||
@$(GO) install github.com/KyleBanks/depth/cmd/depth@latest
|
||||
|
||||
## install.go-callvis: Install go-callvis, used to visualize call graph
|
||||
.PHONY: install.go-callvis
|
||||
install.go-callvis:
|
||||
@$(GO) install github.com/ofabry/go-callvis@latest
|
||||
|
||||
## install.gothanks: Install gothanks, used to thank go dependencies
|
||||
.PHONY: install.gothanks
|
||||
install.gothanks:
|
||||
@$(GO) install github.com/psampaz/gothanks@latest
|
||||
|
||||
## install.richgo: Install richgo
|
||||
.PHONY: install.richgo
|
||||
install.richgo:
|
||||
@$(GO) install github.com/kyoh86/richgo@latest
|
||||
|
||||
## install.rts: Install rts
|
||||
.PHONY: install.rts
|
||||
install.rts:
|
||||
@$(GO) install github.com/galeone/rts/cmd/rts@latest
|
||||
|
||||
## tools.help: Display help information about the tools package
|
||||
.PHONY: tools.help
|
||||
tools.help: scripts/make-rules/tools.mk
|
||||
$(call smallhelp)
|
||||
Reference in New Issue
Block a user