Feature/update actions #21
Workflow file for this run
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 Analysis | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| pull_request: | |
| branches: [ "main", "develop" ] | |
| env: | |
| DOTNET_VERSION: "8.0.x" | |
| BUILD_CONFIG: "Release" | |
| jobs: | |
| sonarcloud: | |
| name: 📊 SonarCloud Analysis | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| pull-requests: write | |
| security-events: write | |
| steps: | |
| - name: 📥 Checkout Code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: 🗄️ Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: 🔧 Install SonarCloud scanners | |
| run: | | |
| dotnet tool install --global dotnet-sonarscanner | |
| dotnet tool install --global dotnet-coverage | |
| - name: 🔧 Restore Dependencies | |
| run: dotnet restore QRCoder.Core.sln | |
| - name: 📊 Start SonarCloud analysis | |
| run: | | |
| dotnet sonarscanner begin /k:"afonsoft_QRCoder.Core" \ | |
| /o:"afonsoft" \ | |
| /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ | |
| /d:sonar.host.url="https://sonarcloud.io" \ | |
| /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
| - name: 🏗️ Build Solution | |
| run: | | |
| dotnet build QRCoder.Core.sln \ | |
| --configuration ${{ env.BUILD_CONFIG }} \ | |
| --no-restore | |
| - name: 🧪 Run Tests with Coverage | |
| run: | | |
| dotnet test QRCoder.Core.Tests/ \ | |
| --configuration ${{ env.BUILD_CONFIG }} \ | |
| --no-build \ | |
| --collect:"XPlat Code Coverage" \ | |
| --results-directory TestResults | |
| - name: 📊 Convert Coverage to XML | |
| run: | | |
| dotnet tool run reportgenerator \ | |
| -reports:TestResults/**/coverage.cobertura.xml \ | |
| -targetdir:TestResults/CoverageReport \ | |
| -reporttypes:XmlSummary | |
| - name: 📊 End SonarCloud analysis | |
| run: | | |
| dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | |
| - name: 📤 Upload Test Results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: sonar-test-results | |
| path: TestResults/ | |
| retention-days: 7 |