Add build badge for GitHub Actions #7
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: Build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| types: [opened, synchronize, reopened] | |
| release: | |
| types: [created] | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: 17 | |
| distribution: 'zulu' # Alternative distribution options are available. | |
| - name: Setup dotnet | |
| uses: actions/setup-dotnet@v5.2.0 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Cache SonarQube Cloud packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~\sonar\cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache SonarQube Cloud scanner | |
| id: cache-sonar-scanner | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ runner.temp }}\scanner | |
| key: ${{ runner.os }}-sonar-scanner | |
| restore-keys: ${{ runner.os }}-sonar-scanner | |
| - name: Install SonarQube Cloud scanner | |
| if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
| shell: powershell | |
| run: | | |
| New-Item -Path ${{ runner.temp }}\scanner -ItemType Directory | |
| dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}\scanner | |
| - name: SonarQube Cloud scanner begin | |
| if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && env.SONAR_TOKEN != '') }} | |
| run: ${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"KxSystems_csharpkdb" /o:"kxsystems" /d:sonar.token="$env:SONAR_TOKEN" /d:sonar.cs.vstest.reportsPaths="**\TestResults\*.trx" /d:sonar.cs.opencover.reportsPaths="*\coverage.opencover.xml" /d:sonar.verbose=false | |
| - name: Build | |
| run : dotnet build /p:Configuration=Release .\CSharpKdb.sln | |
| - name: Test | |
| run: dotnet test /p:Configuration=Release --no-build .\kx.Test\kx.Test.csproj --logger:trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | |
| - name: SonarQube Cloud scanner finish | |
| if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && env.SONAR_TOKEN != '') }} | |
| run: ${{ runner.temp }}\scanner\dotnet-sonarscanner end /d:sonar.token="$env:SONAR_TOKEN" |