Repository navigation
Add delivery pipeline and ceplugin template #5
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: SonarQube Cloud | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - '.editorconfig' | |
| - '.github/**' | |
| - 'CheatEngine.Client.slnx' | |
| - 'Directory.Build.props' | |
| - 'Directory.Build.targets' | |
| - 'Directory.Packages.props' | |
| - 'eng/**' | |
| - 'global.json' | |
| - 'libs/**' | |
| - 'src/**' | |
| - 'templates/**' | |
| - 'tests/**' | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| paths: | |
| - '.editorconfig' | |
| - '.github/**' | |
| - 'CheatEngine.Client.slnx' | |
| - 'Directory.Build.props' | |
| - 'Directory.Build.targets' | |
| - 'Directory.Packages.props' | |
| - 'eng/**' | |
| - 'global.json' | |
| - 'libs/**' | |
| - 'src/**' | |
| - 'templates/**' | |
| - 'tests/**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| shell: pwsh | |
| env: | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| MSBUILDDISABLENODEREUSE: true | |
| SONAR_SCANNER_VERSION: 11.3.0 | |
| jobs: | |
| analyze: | |
| name: Build, test, and analyze | |
| # Secrets are intentionally never exposed to pull requests from forks. | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: windows-latest | |
| timeout-minutes: 35 | |
| steps: | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0 | |
| with: | |
| distribution: zulu | |
| java-version: '21' | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install pinned .NET SDK | |
| uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 | |
| with: | |
| global-json-file: global.json | |
| cache: true | |
| cache-dependency-path: | | |
| **/packages.lock.json | |
| Directory.Packages.props | |
| - name: Install pinned SonarScanner for .NET | |
| id: scanner | |
| run: | | |
| $scannerDirectory = Join-Path $env:RUNNER_TEMP 'sonar-scanner' | |
| New-Item -Path $scannerDirectory -ItemType Directory -Force | Out-Null | |
| dotnet tool install dotnet-sonarscanner --tool-path $scannerDirectory --version $env:SONAR_SCANNER_VERSION | |
| "path=$(Join-Path $scannerDirectory 'dotnet-sonarscanner.exe')" >> $env:GITHUB_OUTPUT | |
| - name: Restore locked dependency graph | |
| run: dotnet restore CheatEngine.Client.slnx --locked-mode | |
| - name: Begin Sonar analysis | |
| env: | |
| SONAR_SCANNER: ${{ steps.scanner.outputs.path }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: | | |
| & $env:SONAR_SCANNER begin ` | |
| /k:"CheatEngineNet_CheatEngine.Client" ` | |
| /o:"cheatenginenet" ` | |
| /d:sonar.token="$env:SONAR_TOKEN" ` | |
| /d:sonar.coverage.exclusions="tests/CheatEngine.Client.AotProbe/**" ` | |
| /d:sonar.cs.cobertura.reportsPaths="artifacts/sonar-test-results/**/*.cobertura.xml" | |
| - name: Build Release | |
| run: dotnet build CheatEngine.Client.slnx --configuration Release --no-restore --warnaserror | |
| - name: Run tests with Cobertura coverage | |
| run: >- | |
| dotnet test --solution CheatEngine.Client.slnx --configuration Release --no-build --no-restore | |
| --coverage --coverage-output-format cobertura --report-trx | |
| --results-directory artifacts/sonar-test-results --fail-skips on | |
| - name: Verify coverage reports | |
| run: | | |
| $reports = @(Get-ChildItem -Path artifacts/sonar-test-results -Recurse -File -Filter '*.cobertura.xml' -ErrorAction SilentlyContinue) | |
| if ($reports.Count -eq 0) { | |
| throw 'Microsoft Testing Platform did not produce a Cobertura coverage report.' | |
| } | |
| $reports | ForEach-Object { Write-Host "Coverage report: $($_.FullName)" } | |
| - name: End Sonar analysis | |
| env: | |
| SONAR_SCANNER: ${{ steps.scanner.outputs.path }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| run: '& $env:SONAR_SCANNER end /d:sonar.token="$env:SONAR_TOKEN"' | |
| - name: Upload Sonar coverage reports | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: sonar-coverage | |
| path: artifacts/sonar-test-results/**/*.cobertura.xml | |
| if-no-files-found: warn | |
| retention-days: 14 |