Skip to content

Commit 5a72923

Browse files
Add Sonar configuration (#22)
* Add sonar-project.properties file * Add Sonar workflow configuration * github/workflows: Set v2 as default directory * github: cd v2 * workflows: cd to v2 before executing * gomod: 1.24 * v2: Move out of folder (module name already prefixed) (#23) * Update .github/workflows/sonar.yml * Update .github/workflows/sonar.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * sonar: Update * Update .github/workflows/sonar.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * sonar: Remove local report * sonar: Fixup suggestion --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent fc431c0 commit 5a72923

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

.github/workflows/sonar.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sonar Report
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
11+
sonar:
12+
runs-on: ubuntu-latest
13+
14+
services:
15+
etcd:
16+
image: bitnami/etcd:latest
17+
env:
18+
ALLOW_NONE_AUTHENTICATION: "yes"
19+
ETCD_ADVERTISE_CLIENT_URLS: "http://localhost:2379"
20+
ports:
21+
- 2379
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: '1.24'
30+
31+
- name: Generate Sonar Report
32+
env:
33+
TESTING_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports['2379'] }}
34+
run: go test -coverpkg=./... -coverprofile=coverage.out -json ./... > sonar-report.json
35+
36+
- name: Upload coverage reports to Sonar
37+
env:
38+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39+
if: github.event.pull_request.head.repo.full_name == github.repository || env.SONAR_TOKEN != ''
40+
uses: SonarSource/[email protected]

sonar-project.properties

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sonar.organization=luno
2+
sonar.projectKey=luno_rink
3+
sonar.projectName=rink
4+
sonar.links.scm=https://github.com/luno/rink
5+
sonar.sources=.
6+
sonar.exclusions=**/*_test.go, **/*pb.go, _examples/**/*
7+
sonar.go.coverage.reportPaths=coverage.out
8+
sonar.go.tests.reportPaths=sonar-report.json
9+
sonar.tests=.
10+
sonar.test.inclusions=**/*_test.go
11+
sonar.test.exclusions=**/*pb.go, _examples/**/*

0 commit comments

Comments
 (0)