From 782b968e0fc55898580bc6ff289e31daf9bb46eb Mon Sep 17 00:00:00 2001 From: Mura Li Date: Thu, 28 May 2020 17:00:46 +0800 Subject: [PATCH 01/10] Enable race detector by default Set RACE_ENABLED=0 to disable it when release --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3cc9ff0cd3f9..5708c38e4bc7 100644 --- a/Makefile +++ b/Makefile @@ -64,9 +64,13 @@ EXTRA_GOFLAGS ?= MAKE_VERSION := $(shell $(MAKE) -v | head -n 1) MAKE_EVIDENCE_DIR := .make_evidence -ifeq ($(RACE_ENABLED),true) - GOFLAGS += -race - GOTESTFLAGS += -race +ifneq ($(RACE_ENABLED),) + ifeq ($(RACE_ENABLED),"all") + GOFLAGS += -race + GOTESTFLAGS += -race + else + GOTESTFLAGS ?= -race + endif endif STORED_VERSION_FILE := VERSION From 5b6bdaa03a0c65fb4d28102a3af807a3e9846551 Mon Sep 17 00:00:00 2001 From: Mura Li Date: Thu, 28 May 2020 17:00:46 +0800 Subject: [PATCH 02/10] Disable race detector for release builds --- .drone.yml | 2 ++ Makefile | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 26726873b9f4..6780910ca2b9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -520,6 +520,7 @@ steps: environment: GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not TAGS: bindata sqlite sqlite_unlock_notify + RACE_ENABLED: "0" - name: gpg-sign pull: always @@ -616,6 +617,7 @@ steps: environment: GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not TAGS: bindata sqlite sqlite_unlock_notify + RACE_ENABLED: "0" - name: gpg-sign pull: always diff --git a/Makefile b/Makefile index 5708c38e4bc7..55e059f31a85 100644 --- a/Makefile +++ b/Makefile @@ -64,13 +64,9 @@ EXTRA_GOFLAGS ?= MAKE_VERSION := $(shell $(MAKE) -v | head -n 1) MAKE_EVIDENCE_DIR := .make_evidence -ifneq ($(RACE_ENABLED),) - ifeq ($(RACE_ENABLED),"all") - GOFLAGS += -race - GOTESTFLAGS += -race - else - GOTESTFLAGS ?= -race - endif +ifneq ($(RACE_ENABLED),"0") + GOFLAGS += -race + GOTESTFLAGS += -race endif STORED_VERSION_FILE := VERSION From dd4674b036459bc1aea9296e13b084c28760eb5b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 2 Jun 2021 20:24:13 +0200 Subject: [PATCH 03/10] use `true` --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6780910ca2b9..e0e1ff7afa85 100644 --- a/.drone.yml +++ b/.drone.yml @@ -520,7 +520,7 @@ steps: environment: GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not TAGS: bindata sqlite sqlite_unlock_notify - RACE_ENABLED: "0" + RACE_ENABLED: true - name: gpg-sign pull: always @@ -617,7 +617,7 @@ steps: environment: GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not TAGS: bindata sqlite sqlite_unlock_notify - RACE_ENABLED: "0" + RACE_ENABLED: true - name: gpg-sign pull: always From 7694598eb2a470f4549a713cb8463a2f0b3a253b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 3 Jun 2021 19:42:45 +0200 Subject: [PATCH 04/10] fix --- .drone.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index e0e1ff7afa85..62c036640686 100644 --- a/.drone.yml +++ b/.drone.yml @@ -214,6 +214,7 @@ steps: environment: GOPROXY: off TAGS: bindata sqlite sqlite_unlock_notify + RACE_ENABLED: true GITHUB_READ_TOKEN: from_secret: github_read_token @@ -236,6 +237,7 @@ steps: environment: GOPROXY: off TAGS: bindata gogit sqlite sqlite_unlock_notify + RACE_ENABLED: true GITHUB_READ_TOKEN: from_secret: github_read_token @@ -246,6 +248,7 @@ steps: environment: GOPROXY: off TAGS: bindata + RACE_ENABLED: true TEST_LDAP: 1 USE_REPO_TEST_DIR: 1 TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200" @@ -259,6 +262,7 @@ steps: environment: GOPROXY: off TAGS: bindata + RACE_ENABLED: true TEST_LDAP: 1 USE_REPO_TEST_DIR: 1 depends_on: @@ -271,6 +275,7 @@ steps: environment: GOPROXY: off TAGS: bindata + RACE_ENABLED: true TEST_LDAP: 1 USE_REPO_TEST_DIR: 1 depends_on: @@ -366,6 +371,7 @@ steps: environment: GOPROXY: off TAGS: bindata gogit sqlite sqlite_unlock_notify + RACE_ENABLED: true TEST_TAGS: gogit sqlite sqlite_unlock_notify USE_REPO_TEST_DIR: 1 depends_on: @@ -378,6 +384,7 @@ steps: environment: GOPROXY: off TAGS: bindata gogit + RACE_ENABLED: true TEST_TAGS: gogit TEST_LDAP: 1 USE_REPO_TEST_DIR: 1 @@ -520,7 +527,6 @@ steps: environment: GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not TAGS: bindata sqlite sqlite_unlock_notify - RACE_ENABLED: true - name: gpg-sign pull: always @@ -617,7 +623,6 @@ steps: environment: GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not TAGS: bindata sqlite sqlite_unlock_notify - RACE_ENABLED: true - name: gpg-sign pull: always From f28079023fb5c129191c10d8bbfdd869537e2a0c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 21 Jul 2021 19:40:42 +0200 Subject: [PATCH 05/10] debug issue --- build/gocovmerge.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/build/gocovmerge.go b/build/gocovmerge.go index b38cf5ea3d5c..9c1e2c8447e2 100644 --- a/build/gocovmerge.go +++ b/build/gocovmerge.go @@ -18,6 +18,7 @@ import ( "log" "os" "sort" + "strings" "golang.org/x/tools/cover" ) @@ -109,7 +110,26 @@ func main() { for _, file := range flag.Args() { profiles, err := cover.ParseProfiles(file) if err != nil { - log.Fatalf("failed to parse profiles: %v", err) + + // for testing only + f, _ := os.Open(file) + defer f.Close() + scanner := bufio.NewScanner(f) + i := 0 + lines := []string{} + for scanner.Scan() { + if i > 10 { + break + } + i++ + lines = append(lines, scanner.Text()) + } + fmt.Println("=== " + file + " ==============================") + fmt.Printf("%s\n", strings.Join(lines, "\n")) + fmt.Println("===============================================") + // end + + log.Fatalf("failed to parse profile '%s': %v", file, err) } for _, p := range profiles { merged = addProfile(merged, p) From 6118e40375288b8d70dd9eb32bd9500a9199b2d4 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 21 Jul 2021 20:08:18 +0200 Subject: [PATCH 06/10] fix --- build/gocovmerge.go | 1 + 1 file changed, 1 insertion(+) diff --git a/build/gocovmerge.go b/build/gocovmerge.go index 9c1e2c8447e2..3271a04db416 100644 --- a/build/gocovmerge.go +++ b/build/gocovmerge.go @@ -12,6 +12,7 @@ package main import ( + "bufio" "flag" "fmt" "io" From 54ddf05deaf9a16cb099c3e8b699d8df24fb099f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 21 Jul 2021 21:20:40 +0200 Subject: [PATCH 07/10] verbose --- Makefile | 2 +- build/gocovmerge.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 55e059f31a85..bc2cf47636f1 100644 --- a/Makefile +++ b/Makefile @@ -385,7 +385,7 @@ test\#%: .PHONY: coverage coverage: - GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all + GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all || cat coverage.out .PHONY: unit-test-coverage unit-test-coverage: diff --git a/build/gocovmerge.go b/build/gocovmerge.go index 3271a04db416..dc71ac740391 100644 --- a/build/gocovmerge.go +++ b/build/gocovmerge.go @@ -125,9 +125,9 @@ func main() { i++ lines = append(lines, scanner.Text()) } - fmt.Println("=== " + file + " ==============================") - fmt.Printf("%s\n", strings.Join(lines, "\n")) - fmt.Println("===============================================") + log.Println("=== " + file + " ==============================") + log.Printf("%s\n", strings.Join(lines, "\n")) + log.Println("===============================================") // end log.Fatalf("failed to parse profile '%s': %v", file, err) From 79b9228ed679bfee6fdea87ebe0299c1ac329980 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 21 Jul 2021 22:10:58 +0200 Subject: [PATCH 08/10] clean --- Makefile | 2 +- build/gocovmerge.go | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/Makefile b/Makefile index bc2cf47636f1..55e059f31a85 100644 --- a/Makefile +++ b/Makefile @@ -385,7 +385,7 @@ test\#%: .PHONY: coverage coverage: - GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all || cat coverage.out + GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all .PHONY: unit-test-coverage unit-test-coverage: diff --git a/build/gocovmerge.go b/build/gocovmerge.go index dc71ac740391..6a1af5b58f79 100644 --- a/build/gocovmerge.go +++ b/build/gocovmerge.go @@ -12,14 +12,12 @@ package main import ( - "bufio" "flag" "fmt" "io" "log" "os" "sort" - "strings" "golang.org/x/tools/cover" ) @@ -111,25 +109,6 @@ func main() { for _, file := range flag.Args() { profiles, err := cover.ParseProfiles(file) if err != nil { - - // for testing only - f, _ := os.Open(file) - defer f.Close() - scanner := bufio.NewScanner(f) - i := 0 - lines := []string{} - for scanner.Scan() { - if i > 10 { - break - } - i++ - lines = append(lines, scanner.Text()) - } - log.Println("=== " + file + " ==============================") - log.Printf("%s\n", strings.Join(lines, "\n")) - log.Println("===============================================") - // end - log.Fatalf("failed to parse profile '%s': %v", file, err) } for _, p := range profiles { From 8a969a188bd3fcdc87c0c2460de521ef5f540207 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 25 Aug 2021 23:58:52 +0800 Subject: [PATCH 09/10] Fix wrong merge --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 55e059f31a85..3cc9ff0cd3f9 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ EXTRA_GOFLAGS ?= MAKE_VERSION := $(shell $(MAKE) -v | head -n 1) MAKE_EVIDENCE_DIR := .make_evidence -ifneq ($(RACE_ENABLED),"0") +ifeq ($(RACE_ENABLED),true) GOFLAGS += -race GOTESTFLAGS += -race endif From 89e19eff64396c44175f5f2b71eaf770969c49fe Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 26 Aug 2021 15:43:20 +0800 Subject: [PATCH 10/10] Fix coverage merge --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3cc9ff0cd3f9..8339e77f4fd7 100644 --- a/Makefile +++ b/Makefile @@ -385,7 +385,7 @@ test\#%: .PHONY: coverage coverage: - GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all + GO111MODULE=on $(GO) run -mod=vendor build/gocovmerge.go integration.coverage.out coverage.out > coverage.all .PHONY: unit-test-coverage unit-test-coverage: