Bump SonarAnalyzer.CSharp from 9.12.0.78982 to 9.16.0.82469 #310
Workflow file for this run
This file contains 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: 'Unit Tests' | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
SONAR_PROJECT_KEY: "dk307_HSPI_ZWaveParameters" | |
SONAR_SCANNER_DOWNLOAD_URL: "https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.4.0.40033/sonar-scanner-msbuild-5.4.0.40033-net46.zip" | |
DOTCOVER_DOWNLOAD_URL: "https://download.jetbrains.com/resharper/dotUltimate.2021.2.2/JetBrains.dotCover.CommandLineTools.2021.2.2.zip" | |
SLN_FILE: "HSPI_ZWaveParameters.sln" | |
TEST_FILE_WIN: "tests\\bin\\Debug\\HSPI_ZWaveParametersTest.dll" | |
TEST_FILE_UBUNTU: "./tests/bin/Debug/HSPI_ZWaveParametersTest.dll" | |
jobs: | |
build-cache-test-win: | |
name: Build, cache and test on Windows | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Navigate to Workspace | |
run: cd $GITHUB_WORKSPACE | |
- name: Setup VS Dev Environment | |
uses: seanmiddleditch/gha-setup-vsdevenv@v4 | |
- name: Setup NuGet | |
uses: NuGet/setup-nuget@v1.0.5 | |
- name: Set up JDK for Sonarcloud | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'oracle' | |
- name: Cache Nuget Packages | |
uses: actions/cache@v3 | |
id: nuget | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
restore-keys: ${{ runner.os }}-nuget- | |
- name: Cache Sonar Scanner | |
uses: actions/cache@v3 | |
id: sonar-scanner | |
with: | |
path: ~/.sonar | |
key: ${{ runner.os }}-${{ env.SONAR_SCANNER_DOWNLOAD_URL }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.SONAR_SCANNER_DOWNLOAD_URL }} | |
- name: Cache DotCover | |
uses: actions/cache@v3 | |
id: dotCover | |
with: | |
path: ~/.dotCover | |
key: ${{ runner.os }}-${{ env.DOTCOVER_DOWNLOAD_URL }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.DOTCOVER_DOWNLOAD_URL }} | |
- name: Download and set up sonar-scanner | |
if: steps.sonar-scanner.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Force -ItemType directory -Path $HOME\.sonar | |
Invoke-WebRequest -Uri ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} -OutFile $HOME\.sonar\sonar-scanner.zip | |
unzip -o $HOME\.sonar\sonar-scanner.zip -d $HOME\.sonar\ | |
Remove-Item -Path $HOME\.sonar\sonar-scanner.zip | |
- name: Download and set up dotCover | |
if: steps.dotCover.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Force -ItemType directory -Path $HOME\.dotCover | |
Invoke-WebRequest -Uri ${{ env.DOTCOVER_DOWNLOAD_URL }} -OutFile $HOME\.dotCover\dotCover.zip | |
unzip -o $HOME\.dotCover\dotCover.zip -d $HOME\.dotCover\ | |
Remove-Item -Path $HOME\.dotCover\dotCover.zip | |
- name: Restore Nuget Packages | |
run: nuget restore ${{ env.SLN_FILE }} | |
- name: Set Paths | |
run: | | |
echo "$HOME\.sonar" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
echo "$HOME\.dotCover" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Start Sonar Scanner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: SonarScanner.MSBuild.exe begin /k:"${{ env.SONAR_PROJECT_KEY }}" /o:"dk307" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:"sonar.cs.dotcover.reportsPaths=**\dotCover.html" /d:"sonar.cs.vstest.reportsPaths=**\*.trx" | |
- name: Build Debug | |
shell: powershell | |
run: msbuild.exe ${{ env.SLN_FILE }} /p:platform="Any CPU" /p:configuration="Debug" | |
- name: Upload unit tests binaries | |
id: unit-test-binaries | |
uses: actions/upload-artifact@v3 | |
with: | |
path: .\tests\bin\Debug | |
name: Test-Files-${{ github.sha }} | |
- name: Upload binaries | |
id: test-binaries | |
uses: actions/upload-artifact@v3 | |
with: | |
path: .\plugin\bin\Debug | |
name: Dll-Files-${{ github.sha }} | |
- name: Run tests | |
shell: powershell | |
run: dotCover.exe analyse /ReportType=HTML /Output="dotCover.html" "/TargetExecutable=%VSINSTALLDIR%\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" /TargetWorkingDir=. "/TargetArguments=${{ env.TEST_FILE_WIN }} /Parallel /logger:trx" /DisableNGen | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: Windows Unit Tests | |
path: TestResults/*.trx | |
reporter: dotnet-trx | |
- name: End Sonar Scanner | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: SonarScanner.MSBuild.exe end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | |
cache-use-build-ubuntu: | |
name: Test on Ubuntu | |
runs-on: ubuntu-latest | |
needs: [build-cache-test-win] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Setup mono | |
run: | | |
sudo apt install dirmngr ca-certificates gnupg | |
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF | |
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list | |
sudo apt update | |
sudo apt install mono-devel | |
- name: Navigate to Workspace | |
run: cd $GITHUB_WORKSPACE | |
- name: Download binaries | |
id: test-binaries | |
uses: actions/download-artifact@v2 | |
with: | |
path: ./plugin/bin/Debug | |
name: Dll-Files-${{ github.sha }} | |
- name: Download unit tests binaries | |
uses: actions/download-artifact@v2 | |
with: | |
path: ./tests/bin/Debug | |
name: Test-Files-${{ github.sha }} | |
- run: ls -l ./tests/bin/Debug | |
- name: Run Unit Tests | |
run: dotnet vstest --Parallel --logger:trx ${{ env.TEST_FILE_UBUNTU }} | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: Ubuntu Unit Tests | |
path: TestResults/*.trx | |
reporter: dotnet-trx |