Lots of small cleanup #133
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: Continuous Integration | |
on: [push, pull_request] | |
env: | |
Configuration: Release | |
ContinuousIntegrationBuild: true | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_NOLOGO: true | |
jobs: | |
package: | |
strategy: | |
matrix: | |
os: [ macos-latest, ubuntu-latest, windows-latest ] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
name: Build and run tests | |
steps: | |
- name: Checkout git repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Retrieve cached NuGet packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
- name: Restore NuGet packages for Core | |
run: dotnet restore CoreTest/CoreTest.csproj --verbosity normal | |
- name: Build solution for Core | |
run: dotnet build CoreTest/CoreTest.csproj --verbosity normal | |
- name: Run tests for Core | |
run: dotnet test CoreTest/CoreTest.csproj --no-build --verbosity normal --logger:"html;LogFileName=../../TestResults-${{ runner.os }}.html" | |
- name: Restore NuGet packages for PixelCanvas | |
run: dotnet restore PixelCanvasTest/PixelCanvasTest.csproj --verbosity normal | |
- name: Build solution for PixelCanvas | |
run: dotnet build PixelCanvasTest/PixelCanvasTest.csproj --verbosity normal | |
- name: Run tests for PixelCanvas | |
run: dotnet test PixelCanvasTest/PixelCanvasTest.csproj --no-build --verbosity normal --logger:"html;LogFileName=../../TestResults-${{ runner.os }}.html" | |
- name: Restore NuGet packages for Windows | |
run: dotnet restore WindowsTest/WindowsTest.csproj --verbosity normal | |
if: startsWith(matrix.os,'windows') | |
- name: Build solution for Windows | |
run: dotnet build WindowsTest/WindowsTest.csproj --verbosity normal | |
if: startsWith(matrix.os,'windows') | |
- name: Run tests for Windows | |
run: dotnet test WindowsTest/WindowsTest.csproj --no-build --verbosity normal --logger:"html;LogFileName=../../TestResults-${{ runner.os }}.html" | |
if: startsWith(matrix.os,'windows') | |
- name: Upload received files from failing tests | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: Received-${{ runner.os }} | |
path: "**/*.received.*" | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: TestResults-${{ runner.os }} | |
path: TestResults-${{ runner.os }}.html | |
- name: Create and validate NuGet package for Core | |
run: dotnet pack --no-build --verbosity normal Core/Core.csproj | |
if: startsWith(matrix.os,'windows') | |
- name: Create and validate NuGet package for PixelCanvas | |
run: dotnet pack --no-build --verbosity normal PixelCanvas/PixelCanvas.csproj | |
if: startsWith(matrix.os,'windows') | |
- name: Create and validate NuGet package for Windows | |
run: dotnet pack --no-build --verbosity normal WindowsTest/WindowsTest.csproj | |
if: startsWith(matrix.os,'windows') | |
- name: Set up JDK 17 (for SonarQube) | |
if: startsWith(matrix.os,'windows') | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Cache SonarCloud packages | |
if: startsWith(matrix.os,'windows') | |
uses: actions/cache@v4 | |
with: | |
path: ~\sonar\cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
if: startsWith(matrix.os,'windows') | |
id: cache-sonar-scanner | |
uses: actions/cache@v4 | |
with: | |
path: .\.sonar\scanner | |
key: ${{ runner.os }}-sonar-scanner | |
restore-keys: ${{ runner.os }}-sonar-scanner | |
- name: Install SonarCloud scanner | |
if: startsWith(matrix.os,'windows') && steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Path .\.sonar\scanner -ItemType Directory | |
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
- name: Cache dotnet-coverage | |
if: startsWith(matrix.os,'windows') | |
id: cache-dotnet-coverage | |
uses: actions/cache@v4 | |
with: | |
path: .\.dotnet-coverage | |
key: ${{ runner.os }}-dotnet-coverage | |
restore-keys: ${{ runner.os }}-dotnet-coverage | |
- name: Install dotnet-coverage | |
if: startsWith(matrix.os,'windows') && steps.cache-dotnet-coverage.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Path .\.dotnet-coverage -ItemType Directory | |
dotnet tool update dotnet-coverage --tool-path .\.dotnet-coverage | |
- name: Build and analyze | |
if: startsWith(matrix.os,'windows') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: | | |
dotnet clean | |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"manuelbl_SwissQRBill.NET" /o:"manuelbl-github" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
dotnet build --no-incremental | |
.\.dotnet-coverage\dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml" | |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |