You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/02/27 06:20:01 UTC

[dubbo-go] 01/01: move linter to makefile

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch feture/linter
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git

commit 6d39f0110faa83ae8c2567b1503b412887d3034b
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sat Feb 27 14:15:49 2021 +0800

    move linter to makefile
---
 .github/workflows/github-actions.yml | 12 +++---------
 Makefile                             | 22 +++++++++++++++++-----
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml
index c0bc085..26e3f47 100644
--- a/.github/workflows/github-actions.yml
+++ b/.github/workflows/github-actions.yml
@@ -59,19 +59,13 @@ jobs:
         go fmt ./... && git checkout -- go.mod && git status && [[ -z `git status -s` ]]
         # diff -u <(echo -n) <(gofmt -d -s .)
 
-    - name: Install go ci lint
-      run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
-
-    - name: Run Linter
-      run: golangci-lint run --timeout=10m -v
-
     - name: Verify
       run: |
         make verify
 
-#    - name: Integrate Test
-#      run: |
-#        chmod +x integrate_test.sh && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}}
+    - name: Integrate Test
+      run: |
+        chmod +x integrate_test.sh && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}}
 
     - name: Post Coverage
       run: bash <(curl -s https://codecov.io/bash)
diff --git a/Makefile b/Makefile
index 2f6c9bd..bb0f926 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,10 @@ VERSION ?= latest
 
 GO = go
 GO_PATH = $(shell $(GO) env GOPATH)
+DUBBOGO_PATH = ~/dubbogo
 GO_OS = $(shell $(GO) env GOOS)
+GO_OS0 := $(GO_OS)
+GO_ARCH = $(shell $(GO) env GOARCH)
 ifeq ($(GO_OS), darwin)
     GO_OS = mac
 endif
@@ -30,9 +33,10 @@ GO_BUILD_FLAGS = -v
 GO_BUILD_LDFLAGS = -X main.version=$(VERSION)
 
 GO_LICENSE_CHECKER_DIR = license-header-checker-$(GO_OS)
-GO_LICENSE_CHECKER = $(GO_PATH)/bin/license-header-checker
+GO_LICENSE_CHECKER = $(DUBBOGO_PATH)/bin/license-header-checker
+GO_LINT_DIR = golangci-lint-1.37.1-$(GO_OS0)-$(GO_ARCH)
+GO_LINT = $(DUBBOGO_PATH)/bin/golangci-lint
 LICENSE_DIR = /tmp/tools/license
-
 ARCH = amd64
 # for add zookeeper fatjar
 ZK_TEST_LIST=config_center/zookeeper registry/zookeeper cluster/router/chain cluster/router/condition cluster/router/tag  metadata/report/zookeeper
@@ -44,9 +48,12 @@ ZK_JAR=$(ZK_JAR_PATH)/$(ZK_JAR_NAME)
 SHELL = /bin/bash
 
 prepareLic:
-	$(GO_LICENSE_CHECKER) -version || (wget https://github.com/lsm-dev/license-header-checker/releases/download/v1.2.0/$(GO_LICENSE_CHECKER_DIR).zip -O $(GO_LICENSE_CHECKER_DIR).zip && unzip -o $(GO_LICENSE_CHECKER_DIR).zip && mkdir -p $(GO_PATH)/bin/ && cp $(GO_LICENSE_CHECKER_DIR)/64bit/license-header-checker $(GO_PATH)/bin/)
+	$(GO_LICENSE_CHECKER) -version || (wget https://github.com/lsm-dev/license-header-checker/releases/download/v1.2.0/$(GO_LICENSE_CHECKER_DIR).zip -O $(GO_LICENSE_CHECKER_DIR).zip && unzip -o $(GO_LICENSE_CHECKER_DIR).zip && mkdir -p $(DUBBOGO_PATH)/bin/ && cp $(GO_LICENSE_CHECKER_DIR)/64bit/license-header-checker $(DUBBOGO_PATH)/bin/)
 	ls /tmp/tools/license/license.txt || wget -P $(LICENSE_DIR) https://github.com/dubbogo/resources/raw/master/tools/license/license.txt
 
+prepareLint:
+	$(GO_LINT) -v || (wget https://github.com/golangci/golangci-lint/releases/download/v1.37.1/$(GO_LINT_DIR).tar.gz -O $(GO_LINT_DIR).tar.gz && tar -zxf $(GO_LINT_DIR).tar.gz && mkdir -p $(DUBBOGO_PATH)/bin/ && mv $(GO_LINT_DIR)/golangci-lint $(DUBBOGO_PATH)/bin/) && rm -rf $(GO_LINT_DIR).tar.gz $(GO_LINT_DIR)
+
 prepareZk:
 	ls $(ZK_JAR) || (mkdir -p $(ZK_JAR_PATH)&&  wget -P $(ZK_JAR_PATH) https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/${ZK_JAR_NAME})
 	@for i in $(ZK_TEST_LIST); do \
@@ -54,7 +61,7 @@ prepareZk:
 		cp ${ZK_JAR} $$i$(ZK_FATJAR_BASE);\
 	done
 
-prepare: prepareZk prepareLic
+prepare: prepareZk prepareLic prepareLint
 
 .PHONE: test
 test: clean prepareZk
@@ -67,10 +74,15 @@ deps: prepare
 license: clean prepareLic
 	$(GO_LICENSE_CHECKER) -v -a -r -i vendor $(LICENSE_DIR)/license.txt . go && [[ -z `git status -s` ]]
 
+.PHONY: linter
+linter: prepareLint
+	$(GO_LINT) run --timeout=5m -v
+
 .PHONY: verify
-verify: clean license test
+verify: clean license linter test
 
 .PHONY: clean
 clean: prepare
 	rm -rf coverage.txt
 	rm -rf license-header-checker*
+