1+ import org.echocat.gradle.plugins.golang.tasks.GolangTask
2+ import org.echocat.gradle.plugins.golang.utils.Executor
3+ import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform
4+
15plugins {
26 id ' org.echocat.golang' version ' 0.1.11'
37}
@@ -6,10 +10,11 @@ group 'github.com/echocat/caddy-filter'
610
711golang {
812 // For testing only the current platform is required.
9- platforms = org.echocat.gradle.plugins.golang.model.Platform . currentPlatform()
13+ platforms = currentPlatform()
1014 dependencies {
1115 build ' github.com/mholt/caddy'
1216 test ' github.com/stretchr/testify'
17+ tool ' github.com/mattn/goveralls'
1318 }
1419 build {
1520 useTemporaryGopath = true
@@ -20,8 +25,25 @@ golang {
2025 }
2126}
2227
23- task baseBuild (type : org.echocat.gradle.plugins.golang.tasks. GolangTask , overwrite : true ) {
28+ task baseBuild (type : GolangTask , overwrite : true ) {
2429 action {
2530 throw new UnsupportedOperationException (" This project only supports test task." );
2631 }
2732}
33+
34+ task uploadCoverage (type : GolangTask , group : " verification" , description : " Upload test coverage report to coveralls.io." , dependsOn : " baseTest" ) {
35+ action {
36+ final token = System . getenv(" COVERALLS_TOKEN" )
37+ if (! token) {
38+ getState(). skipped(" NO-TOKEN-PROVIDED" );
39+ return
40+ }
41+ Executor . executor(" ${ project.buildDir} /tools/github.com/mattn/goveralls${ build.currentPlatformExtension} " , logger)
42+ .argument(" -coverprofile=${ project.buildDir} /testing/${ project.name} .cover" )
43+ .argument(" -service=circle-ci" )
44+ .argument(" -repotoken=${ token} " )
45+ .execute()
46+ }
47+ }
48+
49+ test. dependsOn(" uploadCoverage" )
0 commit comments