Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: sonarcloud-analysis
on:
pull_request:
branches:
- "master"
push:
branches:
- "master"

permissions:
contents: read
pull-requests: read

env:
GO_VERSION: '1.22' # Use the version you need
GOLANGCI_LINT_VERSION: v1.59 # Latest version as of my last update

jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install test reporter
run: go install github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest

- name: Run Go tests
run: go test -json -coverprofile=coverage.out ./... | go-ctrf-json-reporter -output ctrf-report.json
continue-on-error: true

- name: Publish Test Summary Results
run: npx github-actions-ctrf ctrf-report.json

# Re-run golangci separately without exiting on errors and generating a report for use in Sonar
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m --issues-exit-code=0 --out-format=checkstyle:golangci-lint-report.xml

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ Thumbs.db
.env.test
.env.production

# SonarCloud temporary files
coverage.out
golangci-lint-report.xml

# Ignore any other files or directories specific to your project
15 changes: 15 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.projectKey=bitcoin-sv_go-sdk
sonar.organization=bitcoin-sv
sonar.projectName=Go SDK
sonar.projectDescription=BSV BLOCKCHAIN | Software Development Kit for Go
sonar.projectVersion=1.0.0
sonar.sources=.
sonar.sourceEncoding=UTF-8
sonar.go.coverage.reportPaths=coverage.out
sonar.go.golangci-lint.reportPaths=golangci-lint-report.xml

sonar.exclusions=**test**,**/docs/**,**vendor**
sonar.coverage.exclusions=docs/**
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.python.version=3.12