Skip to content

Commit

Permalink
Adding code coverage for sonarcloud. (#62)
Browse files Browse the repository at this point in the history
* Adding code coverage for sonarcloud.

* Update the credential.

* Update the secret.
  • Loading branch information
schmidtw authored Aug 26, 2020
1 parent 5352290 commit 97ae895
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Reference:
# https://github.com/SonarSource/sonarcloud_example_go-sqscanner-travis/blob/master/sonar-project.properties


# =====================================================
# Standard properties
# =====================================================

sonar.projectKey=xmidt-org_bascule
sonar.projectName=bascule

sonar.sources=.
sonar.exclusions=**/*_test.go,**/vendor/**

sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.test.exclusions=**/vendor/**

# =====================================================
# Meta-data for the project
# =====================================================

sonar.links.homepage=https://github.com/xmidt-org/bascule
sonar.links.ci=https://travis-ci.org/xmidt-org/bascule
sonar.links.scm=https://github.com/xmidt-org/bascule
sonar.links.issue=https://github.com/xmidt-org/bascule/issues

# =====================================================
# Properties specific to Go
# =====================================================

sonar.go.tests.reportPaths=report.json
sonar.go.coverage.reportPaths=coverage.txt
18 changes: 17 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,31 @@ branches:
- main
- /^v[0-9]+\.[0-9]+\.[0-9]+$/

addons:
sonarcloud:
organization: "xmidt-org"
token:
secure: "0am7scbUL7n2K/grA8cCN+c/s8H/oUhGsoiAepq6//dAJ7j5QjTspvzmVniZ6i+gtjzPdm4ccr8JslibqAksfAwSGYy2hZHtbibPtL2D2nBGaYg9RQTQD1TTPIdOLcrnyCdaE+Ueu2cbB0RmXK/fL+DAPS/NfOsrbWY7NJcu9298iEHZnrlYN7U1P9ENRkxIloLpeJEgkxbGn7T7rEnwbW1I2YE4UXJhGN6UzSXvyex/W4Gto3gDmTFarbLUopA6iZRAOJ6bgpGHNeb87X3AE0MnXBjiKfWUQKZrKBQeCWYkLjqYrsC5hTunL7daJcds4yELqbHIlAYilqr6WxDbu3FmEoH2Iw5bSpEFxuX/vB+GW4ESNEvRmc2xRsxx+FkNFRKRj34rd4lvNpN753po3eavUvPEb1Ze4qcIuABB5jSaBf7bjHou3TC8Per1wfXcBLC00bJUpWTaKUAdDuu5ESJIZoO3hwAYZtt6vBSdajfMgXEQZoUm1YHEuYYY4/Vbs10m3fX6YFPcOhaFHWB6MlwQEiOsLsxnmCDtfRhZplP02xgX5evdSzIvaHCRRlMdEQEPV0VBt0JKiUUtSzKDfxU0tgnE/AtCVAQMDQEOey1Iddyf7fYwUAfgbUtRHrie1gaPd4jAAdwiKumt9RrLgab9vt6ncH2i+eea5stT3O0="

install:
- GO111MODULE=on go mod vendor

# default name is 'test'

script:
- if [ -n "$(gofmt -s -l . | grep -v "vendor")" ]; then diff -u <(echo -n) <(gofmt -d $(gofmt -s -l . | grep -v "vendor")); fi
- GO111MODULE=on go test -v -race -coverprofile=coverage.txt ./...
- GO111MODULE=on go test -race -json ./... > report.json

after_success:
- sonar-scanner -Dproject.settings=./.sonar-project.properties
- bash <(curl -s https://codecov.io/bash)

stages:
- test
- tag
- release

jobs:
include:
- stage: tag
Expand All @@ -37,6 +52,8 @@ jobs:
- export TODAY=`date +'%m/%d/%Y'`
- export NOTES=$(cat CHANGELOG.md | perl -0777 -ne 'print "$ENV{TODAY}\n\n$1\n" if /.*## \[$ENV{TAG}\]\s(.*?)\s+## \[(v\d+.\d+.\d+)\].*/s')
- if [[ "$TAG" != "" && "$TAG" != "$OLD_VERSION" ]]; then git tag -a "$TAG" -m "$NOTES"; git push origin --tags; echo $?; fi
after_success: skip

- stage: release
name: "Make a Release"
if: branch != main
Expand All @@ -47,4 +64,3 @@ jobs:
tags: true
provider: releases
api_key: "$GH_TOKEN"
skip_cleanup: true
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The library for authorization: both acquiring and validating.
[![Apache V2 License](http://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/xmidt-org/bascule/blob/main/LICENSE)
[![GitHub release](https://img.shields.io/github/release/xmidt-org/bascule.svg)](CHANGELOG.md)
[![GoDoc](https://godoc.org/github.com/xmidt-org/bascule?status.svg)](https://godoc.org/github.com/xmidt-org/bascule)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xmidt-org_arrange&metric=alert_status)](https://sonarcloud.io/dashboard?id=xmidt-org_bascule)

## Summary

Expand Down Expand Up @@ -52,4 +53,4 @@ This repo is a library of packages used for the authorization. There is no
installation.

## Contributing
Refer to [CONTRIBUTING.md](CONTRIBUTING.md).
Refer to [CONTRIBUTING.md](CONTRIBUTING.md).

0 comments on commit 97ae895

Please sign in to comment.