Skip to content

Commit

Permalink
Sonar: Add coverage reporting (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenkanglu authored Sep 12, 2024
1 parent c0f60d3 commit 976ff15
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sonar.organization = luno
sonar.projectKey = luno_lu
sonar.projectName = lu
sonar.links.scm = https://github.com/luno/lu

sonar.sources = .
sonar.exclusions= **/*_test.go, **/*pb.go
sonar.go.coverage.reportPaths = coverage.out
sonar.go.tests.reportPaths = sonar-report.json
sonar.tests = .
sonar.test.inclusions = **/*_test.go
sonar.test.exclusions= **/*pb.go
30 changes: 30 additions & 0 deletions sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Sonar Report

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Generate Sonar Report
run: go test -coverpkg=./... -coverprofile=coverage.out -json ./... > sonar-report.json

- name: Upload coverage reports to Sonar
uses: sonarsource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 comments on commit 976ff15

Please sign in to comment.