Browse Source

add codecov.io service. (#2493)

* add codecov.io service.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* only PR or master branch (for coverage badge)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* update init

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Bo-Yi Wu 2 years ago
parent
commit
3e89e89670
4 changed files with 74 additions and 29 deletions
  1. 48 7
      .drone.yml
  2. 1 0
      .gitignore
  3. 24 21
      Makefile
  4. 1 1
      README.md

+ 48 - 7
.drone.yml

@@ -35,9 +35,22 @@ pipeline:
35 35
       TAGS: bindata sqlite
36 36
       GOPATH: /srv/app
37 37
     commands:
38
+      - make unit-test-coverage
39
+    when:
40
+      event: [ push, pull_request ]
41
+      branch: [ master ]
42
+
43
+  test:
44
+    image: webhippie/golang:edge
45
+    pull: true
46
+    group: test
47
+    environment:
48
+      TAGS: bindata
49
+      GOPATH: /srv/app
50
+    commands:
38 51
       - make test
39 52
     when:
40
-      event: [ push, tag, pull_request ]
53
+      event: [ tag ]
41 54
 
42 55
   # Commented until db locking have been resolved!
43 56
   # test-sqlite:
@@ -60,9 +73,22 @@ pipeline:
60 73
       TAGS: bindata
61 74
       GOPATH: /srv/app
62 75
     commands:
76
+      - make integration-test-coverage
77
+    when:
78
+      event: [ push, pull_request ]
79
+      branch: [ master ]
80
+
81
+  test-mysql:
82
+    image: webhippie/golang:edge
83
+    pull: true
84
+    group: test
85
+    environment:
86
+      TAGS: bindata
87
+      GOPATH: /srv/app
88
+    commands:
63 89
       - make test-mysql
64 90
     when:
65
-      event: [ push, tag, pull_request ]
91
+      event: [ tag ]
66 92
 
67 93
   test-pgsql:
68 94
     image: webhippie/golang:edge
@@ -76,11 +102,26 @@ pipeline:
76 102
     when:
77 103
       event: [ push, tag, pull_request ]
78 104
 
79
-  # coverage:
80
-  #   image: plugins/coverage:latest
81
-  #   pull: true
82
-  #   secrets: [ github_token ]
83
-  #   server: https://coverage.gitea.io
105
+  generate-coverage:
106
+    image: webhippie/golang:edge
107
+    pull: true
108
+    environment:
109
+      TAGS: bindata
110
+      GOPATH: /srv/app
111
+    commands:
112
+      - make coverage
113
+    when:
114
+      event: [ push, pull_request ]
115
+      branch: [ master ]
116
+
117
+  coverage:
118
+    image: robertstettner/drone-codecov
119
+    secrets: [ codecov_token ]
120
+    files:
121
+      - coverage.all
122
+    when:
123
+      event: [ push, pull_request ]
124
+      branch: [ master ]
84 125
 
85 126
   static:
86 127
     image: karalabe/xgo-latest:latest

+ 1 - 0
.gitignore

@@ -30,6 +30,7 @@ _testmain.go
30 30
 *.prof
31 31
 
32 32
 *coverage.out
33
+coverage.all
33 34
 
34 35
 /modules/options/bindata.go
35 36
 /modules/public/bindata.go

+ 24 - 21
Makefile

@@ -135,16 +135,17 @@ test: fmt-check
135 135
 	$(GO) test $(PACKAGES)
136 136
 
137 137
 .PHONY: coverage
138
-coverage: unit-test-coverage integration-test-coverage
138
+coverage:
139 139
 	@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
140 140
 		$(GO) get -u github.com/wadey/gocovmerge; \
141 141
 	fi
142
+	echo "mode: set" > coverage.all
142 143
 	for PKG in $(PACKAGES); do\
143
-	  touch $$GOPATH/src/$$PKG/coverage.out;\
144
-	  egrep "$$PKG[^/]*\.go" integration.coverage.out > int.coverage.out;\
145
-	  gocovmerge $$GOPATH/src/$$PKG/coverage.out int.coverage.out > pkg.coverage.out;\
146
-	  mv pkg.coverage.out $$GOPATH/src/$$PKG/coverage.out;\
147
-	  rm int.coverage.out;\
144
+		egrep "$$PKG[^/]*\.go" integration.coverage.out > int.coverage.out;\
145
+		gocovmerge $$GOPATH/src/$$PKG/coverage.out int.coverage.out > pkg.coverage.out;\
146
+		grep -h -v "^mode:" pkg.coverage.out >>  coverage.all;\
147
+		mv pkg.coverage.out $$GOPATH/src/$$PKG/coverage.out;\
148
+		rm int.coverage.out;\
148 149
 	done;
149 150
 
150 151
 .PHONY: unit-test-coverage
@@ -168,22 +169,24 @@ test-vendor:
168 169
 test-sqlite: integrations.sqlite.test
169 170
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
170 171
 
171
-.PHONY: test-mysql
172
-test-mysql: integrations.mysql.test
172
+generate-ini:
173 173
 	sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
174
-	    -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
175
-	    -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
176
-	    -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
177
-		  integrations/mysql.ini.tmpl > integrations/mysql.ini
174
+		-e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
175
+		-e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
176
+		-e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
177
+			integrations/mysql.ini.tmpl > integrations/mysql.ini
178
+	sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
179
+		-e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
180
+		-e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
181
+		-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
182
+			integrations/pgsql.ini.tmpl > integrations/pgsql.ini
183
+
184
+.PHONY: test-mysql
185
+test-mysql: integrations.mysql.test generate-ini
178 186
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
179 187
 
180 188
 .PHONY: test-pgsql
181
-test-pgsql: integrations.pgsql.test
182
-	sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
183
-	    -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
184
-	    -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
185
-	    -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
186
-		  integrations/pgsql.ini.tmpl > integrations/pgsql.ini
189
+test-pgsql: integrations.pgsql.test generate-ini
187 190
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
188 191
 
189 192
 .PHONY: bench-sqlite
@@ -191,16 +194,16 @@ bench-sqlite: integrations.sqlite.test
191 194
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.bench .
192 195
 
193 196
 .PHONY: bench-mysql
194
-bench-mysql: integrations.mysql.test
197
+bench-mysql: integrations.mysql.test generate-ini
195 198
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.bench .
196 199
 
197 200
 .PHONY: bench-pgsql
198
-bench-pgsql: integrations.pgsql.test
201
+bench-pgsql: integrations.pgsql.test generate-ini
199 202
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.bench .
200 203
 
201 204
 
202 205
 .PHONY: integration-test-coverage
203
-integration-test-coverage: integrations.cover.test
206
+integration-test-coverage: integrations.cover.test generate-ini
204 207
 	GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
205 208
 
206 209
 integrations.mysql.test: $(SOURCES)

+ 1 - 1
README.md

@@ -6,7 +6,7 @@
6 6
 [![Join the Discord chat at https://discord.gg/NsatcWJ](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ)
7 7
 [![Join the Matrix chat at https://matrix.to/#/#gitea:matrix.org](https://img.shields.io/badge/matrix-%23gitea%3Amatrix.org-7bc9a4.svg)](https://matrix.to/#/#gitea:matrix.org)
8 8
 [![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
9
-[![Coverage Status](https://coverage.gitea.io/badges/go-gitea/gitea/coverage.svg)](https://coverage.gitea.io/go-gitea/gitea)
9
+[![codecov](https://codecov.io/gh/go-gitea/gitea/branch/master/graph/badge.svg)](https://codecov.io/gh/go-gitea/gitea)
10 10
 [![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea)
11 11
 [![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
12 12
 [![Release](https://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)