Skip to content

Commit 3e89e89

Browse files
authored
add codecov.io service. (#2493)
* add codecov.io service. Signed-off-by: Bo-Yi Wu <[email protected]> * update Signed-off-by: Bo-Yi Wu <[email protected]> * only PR or master branch (for coverage badge) Signed-off-by: Bo-Yi Wu <[email protected]> * update Signed-off-by: Bo-Yi Wu <[email protected]> * update init Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 9ef83a9 commit 3e89e89

File tree

4 files changed

+74
-29
lines changed

4 files changed

+74
-29
lines changed

.drone.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,23 @@ pipeline:
3434
environment:
3535
TAGS: bindata sqlite
3636
GOPATH: /srv/app
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
3750
commands:
3851
- make test
3952
when:
40-
event: [ push, tag, pull_request ]
53+
event: [ tag ]
4154

4255
# Commented until db locking have been resolved!
4356
# test-sqlite:
@@ -52,6 +65,19 @@ pipeline:
5265
# when:
5366
# event: [ push, tag, pull_request ]
5467

68+
test-mysql:
69+
image: webhippie/golang:edge
70+
pull: true
71+
group: test
72+
environment:
73+
TAGS: bindata
74+
GOPATH: /srv/app
75+
commands:
76+
- make integration-test-coverage
77+
when:
78+
event: [ push, pull_request ]
79+
branch: [ master ]
80+
5581
test-mysql:
5682
image: webhippie/golang:edge
5783
pull: true
@@ -62,7 +88,7 @@ pipeline:
6288
commands:
6389
- make test-mysql
6490
when:
65-
event: [ push, tag, pull_request ]
91+
event: [ tag ]
6692

6793
test-pgsql:
6894
image: webhippie/golang:edge
@@ -76,11 +102,26 @@ pipeline:
76102
when:
77103
event: [ push, tag, pull_request ]
78104

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 ]
84125

85126
static:
86127
image: karalabe/xgo-latest:latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ _testmain.go
3030
*.prof
3131

3232
*coverage.out
33+
coverage.all
3334

3435
/modules/options/bindata.go
3536
/modules/public/bindata.go

Makefile

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,17 @@ test: fmt-check
135135
$(GO) test $(PACKAGES)
136136

137137
.PHONY: coverage
138-
coverage: unit-test-coverage integration-test-coverage
138+
coverage:
139139
@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
140140
$(GO) get -u github.com/wadey/gocovmerge; \
141141
fi
142+
echo "mode: set" > coverage.all
142143
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;\
148149
done;
149150

150151
.PHONY: unit-test-coverage
@@ -168,39 +169,41 @@ test-vendor:
168169
test-sqlite: integrations.sqlite.test
169170
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
170171

171-
.PHONY: test-mysql
172-
test-mysql: integrations.mysql.test
172+
generate-ini:
173173
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
178186
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
179187

180188
.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
187190
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
188191

189192
.PHONY: bench-sqlite
190193
bench-sqlite: integrations.sqlite.test
191194
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.bench .
192195

193196
.PHONY: bench-mysql
194-
bench-mysql: integrations.mysql.test
197+
bench-mysql: integrations.mysql.test generate-ini
195198
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.bench .
196199

197200
.PHONY: bench-pgsql
198-
bench-pgsql: integrations.pgsql.test
201+
bench-pgsql: integrations.pgsql.test generate-ini
199202
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.bench .
200203

201204

202205
.PHONY: integration-test-coverage
203-
integration-test-coverage: integrations.cover.test
206+
integration-test-coverage: integrations.cover.test generate-ini
204207
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
205208

206209
integrations.mysql.test: $(SOURCES)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Join the Discord chat at https://discord.gg/NsatcWJ](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ)
77
[![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)
88
[![](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)
1010
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea)
1111
[![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
1212
[![Release](https://github-release-version.herokuapp.com/github/go-gitea/gitea/release.svg?style=flat)](https://github.com/go-gitea/gitea/releases/latest)

0 commit comments

Comments
 (0)