From 976ff159016ab35844b0107552ee8fb28af70ec6 Mon Sep 17 00:00:00 2001 From: Gary Lu <53174584+wenkanglu@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:35:46 +0200 Subject: [PATCH] Sonar: Add coverage reporting (#28) --- sonar-project.properties | 12 ++++++++++++ sonar.yaml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 sonar-project.properties create mode 100644 sonar.yaml diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..eb35dfa --- /dev/null +++ b/sonar-project.properties @@ -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 diff --git a/sonar.yaml b/sonar.yaml new file mode 100644 index 0000000..e3cd69e --- /dev/null +++ b/sonar.yaml @@ -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 }}