Test if token is available #451
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SonarCloud code analysis | |
| on: [push] | |
| jobs: | |
| analyze: | |
| name: Analyze | |
| if: github.repository == 'web-eid/web-eid-authtoken-validation-dotnet' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Unset CACHE_VERSION | |
| shell: powershell | |
| run: | | |
| Remove-Item Env:CACHE_VERSION -ErrorAction SilentlyContinue | |
| Write-Host "CACHE_VERSION has been unset" | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Setup dotnet | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x # SDK Version to use. | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| - name: Cache Nuget packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| # Look to see if there is a cache hit for the corresponding requirements file | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
| restore-keys: ${{ runner.os }}-nuget | |
| - name: Install dependencies | |
| run: dotnet restore src/WebEid.Security.sln | |
| - name: Install SonarCloud scanner | |
| shell: powershell | |
| run: | | |
| New-Item -Path .\.sonar\scanner -ItemType Directory | |
| dotnet tool install dotnet-sonarscanner --tool-path .\.sonar\scanner --version 10.1.2 | |
| - 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: | | |
| Write-Host "Branch: ${{ github.ref_name }}" | |
| Write-Host "Repository: ${{ github.repository }}" | |
| Write-Host "Event: ${{ github.event_name }}" | |
| Write-Host "CACHE_VERSION value: '$env:CACHE_VERSION'" | |
| if ("${{ secrets.SONAR_TOKEN }}" -eq "") { | |
| Write-Host "SONAR_TOKEN is missing" | |
| } else { | |
| Write-Host "SONAR_TOKEN is available -4 (length: $("${{ secrets.SONAR_TOKEN }}".Length))" | |
| } | |
| .\.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" | |
| dotnet build --configuration Release --no-restore src/WebEid.Security.sln | |
| dotnet test src/WebEid.Security.sln --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --results-directory "TestResults" | |
| .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |