build: update JDK version to 11 and add distribution option in SonarCloud workflow

This commit is contained in:
Jean Gatto
2023-05-28 10:53:15 -03:00
parent ee6489c8c8
commit 006acfc487
+10 -19
View File
@@ -1,4 +1,4 @@
name: SonarCloud analysis
name: SonarCloud
on:
push:
@@ -8,23 +8,21 @@ on:
paths-ignore:
- "README.md"
permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results
jobs:
build:
name: Build
name: Build and analyze
runs-on: windows-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.11
java-version: 11
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v3
@@ -48,19 +46,12 @@ jobs:
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: "7.0.x"
- name: Build, Test and Analyze
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"jeangatto_ASP.NET-Core-API-CQRS-EVENT-DDD-SOLID" /o:"jeangatto" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet restore
dotnet build --no-restore
dotnet test --no-build --no-restore --verbosity normal -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:CoverletOutput=TestResults/
dotnet restore && dotnet build --no-restore && dotnet test --no-build --no-restore --verbosity normal -p:CollectCoverage=true -p:CoverletOutputFormat=opencover -p:CoverletOutput=TestResults/
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"