Skip to content

Test if token is available #462

Test if token is available

Test if token is available #462

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: 9.0.x # SDK Version to use.
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Install SonarCloud scanner
shell: powershell
run: |
dotnet tool install --global dotnet-sonarscanner
- 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: |
if ("${{ secrets.SONAR_TOKEN }}" -eq "") {
Write-Host "SONAR_TOKEN is missing"
} else {
Write-Host "SONAR_TOKEN is available -8 (length: $("${{ secrets.SONAR_TOKEN }}".Length))"
}
Write-Host "Branch: ${{ github.ref_name }}"
Write-Host "CACHE_VERSION value: '$env:CACHE_VERSION'"
dotnet sonarscanner begin /k:"web-eid_web-eid-authtoken-validation-dotnet" /o:"web-eid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.verbose=true /d:sonar.branch.name="${{ github.ref_name }}"
Get-ChildItem -Path ".\.sonarqube" -Recurse | Select-Object FullName, Length, LastWriteTime | Format-Table -AutoSize
dotnet build --no-incremental --configuration Release 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"
dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"