2023-08-27 04:21:41 +01:00
|
|
|
name: SonarCloud
|
2021-04-27 01:41:32 +01:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2022-04-30 17:01:01 +01:00
|
|
|
- main
|
2023-04-13 21:55:00 +01:00
|
|
|
workflow_dispatch:
|
2021-04-27 01:41:32 +01:00
|
|
|
pull_request:
|
2023-08-27 04:21:41 +01:00
|
|
|
types: [ opened, synchronize, reopened ]
|
|
|
|
|
2021-04-27 01:41:32 +01:00
|
|
|
jobs:
|
2023-08-27 04:21:41 +01:00
|
|
|
sonarcloud:
|
|
|
|
name: SonarCloud Analysis
|
2021-04-27 01:41:32 +01:00
|
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
2023-08-27 04:33:24 +01:00
|
|
|
- name: Set up JDK 17
|
|
|
|
uses: actions/setup-java@v3
|
2021-04-27 01:41:32 +01:00
|
|
|
with:
|
2023-08-27 04:33:24 +01:00
|
|
|
java-version: 17
|
|
|
|
distribution: 'zulu'
|
2023-08-27 04:21:41 +01:00
|
|
|
|
2023-03-28 15:02:09 +01:00
|
|
|
- uses: actions/checkout@v3
|
2021-04-27 01:41:32 +01:00
|
|
|
with:
|
|
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
2023-08-27 04:21:41 +01:00
|
|
|
|
2021-04-27 01:41:32 +01:00
|
|
|
- name: Cache SonarCloud packages
|
2023-08-27 04:33:24 +01:00
|
|
|
uses: actions/cache@v3
|
2021-04-27 01:41:32 +01:00
|
|
|
with:
|
|
|
|
path: ~\sonar\cache
|
|
|
|
key: ${{ runner.os }}-sonar
|
|
|
|
restore-keys: ${{ runner.os }}-sonar
|
2023-08-27 04:21:41 +01:00
|
|
|
|
2021-04-27 01:41:32 +01:00
|
|
|
- name: Cache SonarCloud scanner
|
|
|
|
id: cache-sonar-scanner
|
2023-08-27 04:33:24 +01:00
|
|
|
uses: actions/cache@v3
|
2021-04-27 01:41:32 +01:00
|
|
|
with:
|
|
|
|
path: .\.sonar\scanner
|
|
|
|
key: ${{ runner.os }}-sonar-scanner
|
|
|
|
restore-keys: ${{ runner.os }}-sonar-scanner
|
2023-08-27 04:21:41 +01:00
|
|
|
|
2021-04-27 01:41:32 +01:00
|
|
|
- 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
|
2023-08-27 04:21:41 +01:00
|
|
|
|
2021-04-27 01:41:32 +01:00
|
|
|
- name: Build and analyze
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
shell: powershell
|
|
|
|
run: |
|
2023-08-27 04:33:24 +01:00
|
|
|
.\.sonar\scanner\dotnet-sonarscanner begin /k:"oliverbooth_X10D" /o:"oliverbooth" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
|
2022-04-20 22:53:32 +01:00
|
|
|
dotnet build --no-incremental
|
2022-04-20 23:00:33 +01:00
|
|
|
dotnet dotcover test --dcReportType=HTML
|
2023-08-27 04:33:24 +01:00
|
|
|
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|