66 lines
2.2 KiB
YAML
66 lines
2.2 KiB
YAML
# https://github.com/SonarSource/sonarcloud-github-action
|
|
name: SonarCloud
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
branches: [main]
|
|
paths-ignore:
|
|
- "README.md"
|
|
- ".github/workflows/**.yml"
|
|
- "docs/**"
|
|
- "**/*.md"
|
|
- "**/*.yml"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and Analyze
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: 21
|
|
check-latest: true
|
|
distribution: "sapmachine"
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Cache SonarCloud Packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~\sonar\cache
|
|
key: ${{ runner.os }}-sonar
|
|
restore-keys: ${{ runner.os }}-sonar
|
|
|
|
- name: Cache SonarCloud Scanner
|
|
id: cache-sonar-scanner
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .\.sonar\scanner
|
|
key: ${{ runner.os }}-sonar-scanner
|
|
restore-keys: ${{ runner.os }}-sonar-scanner
|
|
|
|
- name: Install SonarCloud Scanner
|
|
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
|
|
shell: powershell
|
|
run: |
|
|
New-Item -Path .\.sonar\scanner -ItemType Directory
|
|
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
|
|
|
|
- name: Build, Test and Analyze
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
shell: powershell
|
|
run: |
|
|
.\.sonar\scanner\dotnet-sonarscanner begin /k:"ASP.NET-Core-Clean-Architecture-CQRS-Event-Sourcing" /o:"jeangatto" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.verbose=false /d:sonar.scanner.scanAll=false /d:sonar.dotnet.excludeTestProjects=true /d:sonar.scanner.skipJreProvisioning=true
|
|
dotnet restore Shop.sln
|
|
dotnet build Shop.sln --nologo --no-restore
|
|
dotnet test Shop.sln --nologo --no-build --no-restore --verbosity minimal -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:CoverletOutput=TestResults/
|
|
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|