|
9 | 9 | runs-on: windows-latest
|
10 | 10 |
|
11 | 11 | steps:
|
| 12 | + - name: Unset CACHE_VERSION |
| 13 | + shell: powershell |
| 14 | + run: | |
| 15 | + Remove-Item Env:CACHE_VERSION -ErrorAction SilentlyContinue |
| 16 | + Write-Host "CACHE_VERSION has been unset" |
| 17 | +
|
12 | 18 | - uses: actions/checkout@v4
|
13 | 19 | with:
|
14 | 20 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
15 | 21 |
|
16 | 22 | - name: Setup dotnet
|
17 | 23 | uses: actions/setup-dotnet@v4
|
18 | 24 | with:
|
19 |
| - dotnet-version: 8.0.x # SDK Version to use. |
| 25 | + dotnet-version: 9.0.x # SDK Version to use. |
20 | 26 |
|
21 | 27 | - name: Set up JDK 21
|
22 | 28 | uses: actions/setup-java@v4
|
23 | 29 | with:
|
24 | 30 | distribution: temurin
|
25 | 31 | java-version: 21
|
26 | 32 |
|
27 |
| - - name: Cache Nuget packages |
28 |
| - uses: actions/cache@v4 |
29 |
| - with: |
30 |
| - path: ~/.nuget/packages |
31 |
| - # Look to see if there is a cache hit for the corresponding requirements file |
32 |
| - key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} |
33 |
| - restore-keys: ${{ runner.os }}-nuget |
34 |
| - |
35 |
| - - name: Install dependencies |
36 |
| - run: dotnet restore src/WebEid.Security.sln |
37 |
| - |
38 |
| - - name: Cache SonarCloud packages |
39 |
| - uses: actions/cache@v4 |
40 |
| - with: |
41 |
| - path: ~/.sonar/cache |
42 |
| - key: ${{ runner.os }}-sonar |
43 |
| - restore-keys: ${{ runner.os }}-sonar |
44 |
| - |
45 |
| - - name: Cache SonarCloud scanner |
46 |
| - id: cache-sonar-scanner |
47 |
| - uses: actions/cache@v4 |
48 |
| - with: |
49 |
| - path: .\.sonar\scanner |
50 |
| - key: ${{ runner.os }}-sonar-scanner |
51 |
| - restore-keys: ${{ runner.os }}-sonar-scanner |
52 |
| - |
53 | 33 | - name: Install SonarCloud scanner
|
54 |
| - if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
55 | 34 | shell: powershell
|
56 | 35 | run: |
|
57 |
| - New-Item -Path .\.sonar\scanner -ItemType Directory |
58 |
| - dotnet tool install dotnet-sonarscanner --tool-path .\.sonar\scanner --version 10.1.2 |
| 36 | + dotnet tool install --global dotnet-sonarscanner |
| 37 | +
|
| 38 | + - name: Create SonarQube.Analysis.xml |
| 39 | + shell: powershell |
| 40 | + run: | |
| 41 | + @" |
| 42 | + <?xml version="1.0" encoding="utf-8"?> |
| 43 | + <SonarQubeAnalysisProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1"> |
| 44 | + <Property Name="sonar.host.url">https://sonarcloud.io</Property> |
| 45 | + <Property Name="sonar.token">${{ secrets.SONAR_TOKEN }}</Property> |
| 46 | + <Property Name="sonar.password"></Property> |
| 47 | + </SonarQubeAnalysisProperties> |
| 48 | + "@ | Out-File -FilePath SQ.Analysis.xml -Encoding UTF8 |
59 | 49 |
|
60 | 50 | - name: Build and analyze
|
61 | 51 | env:
|
62 | 52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
63 |
| - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
64 |
| - CACHE_VERSION: ${{ vars.CACHE_VERSION }} |
65 | 53 | shell: powershell
|
66 | 54 | run: |
|
67 |
| - Write-Host "Branch: ${{ github.ref_name }}" |
68 |
| - Write-Host "Repository: ${{ github.repository }}" |
69 |
| - Write-Host "Event: ${{ github.event_name }}" |
70 | 55 | if ("${{ secrets.SONAR_TOKEN }}" -eq "") {
|
71 | 56 | Write-Host "SONAR_TOKEN is missing"
|
72 | 57 | } else {
|
73 |
| - Write-Host "SONAR_TOKEN is available -3 (length: $("${{ secrets.SONAR_TOKEN }}".Length))" |
| 58 | + Write-Host "SONAR_TOKEN is available -8 (length: $("${{ secrets.SONAR_TOKEN }}".Length))" |
74 | 59 | }
|
75 |
| - Remove-Item Env:CACHE_VERSION -ErrorAction SilentlyContinue |
76 |
| - .\.sonar\scanner\dotnet-sonarscanner begin /k:"web-eid_web-eid-authtoken-validation-dotnet" /o:"web-eid" /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" /d:sonar.cs.vstest.reportsPaths="**/TestResults/*.trx" /d:sonar.verbose=true /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" |
77 |
| - dotnet build --configuration Release --no-restore src/WebEid.Security.sln |
| 60 | + Write-Host "Branch: ${{ github.ref_name }}" |
| 61 | + Write-Host "CACHE_VERSION value: '$env:CACHE_VERSION'" |
| 62 | + dotnet sonarscanner begin /k:"web-eid_web-eid-authtoken-validation-dotnet" /o:"web-eid" /s:".\SQ.Analysis.xml" /d:sonar.verbose=true |
| 63 | + Get-ChildItem -Path ".\.sonarqube" -Recurse | Select-Object FullName, Length, LastWriteTime | Format-Table -AutoSize |
| 64 | + dotnet build --no-incremental --configuration Release src/WebEid.Security.sln |
78 | 65 | dotnet test src/WebEid.Security.sln --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --results-directory "TestResults"
|
79 |
| - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |
| 66 | + dotnet sonarscanner end |
0 commit comments