Skip to content

Honor ignore files and exclude tests from scans (#5) #17

Honor ignore files and exclude tests from scans (#5)

Honor ignore files and exclude tests from scans (#5) #17

Workflow file for this run

name: SonarCloud
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: read
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: '1.26.2'
cache: true
- name: Cache SonarQube packages
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Test with coverage
run: go test ./... -coverprofile=coverage.out -covermode=atomic
- name: Skip when SONAR_TOKEN is not configured
if: ${{ env.SONAR_TOKEN == '' }}
run: echo "SONAR_TOKEN is not configured; skipping SonarCloud analysis."
- name: SonarCloud scan
if: ${{ env.SONAR_TOKEN != '' }}
uses: SonarSource/sonarqube-scan-action@59db25f34e16620e48ab4bb9e4a5dce155cb5432 # v8.0.0
env:
SONAR_TOKEN: ${{ env.SONAR_TOKEN }}