|
| 1 | +name: .NET |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +env: |
| 9 | + JAVA_VERSION: '21' |
| 10 | + DOTNET_VERSION: '8.0.x' |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build, Test and Analyse |
| 15 | + runs-on: ubuntu-24.04 |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 # Shallow clones disabled for a better relevancy of SC analysis |
| 20 | + |
| 21 | + - name: Setup .NET ${{ env.DOTNET_VERSION }} |
| 22 | + uses: actions/setup-dotnet@v4 |
| 23 | + with: |
| 24 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 25 | + |
| 26 | + - name: Set up JDK ${{ env.JAVA_VERSION }} |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + java-version: ${{ env.JAVA_VERSION }} |
| 30 | + distribution: 'microsoft' |
| 31 | + |
| 32 | + - name: Cache SonarCloud packages |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: ~\sonar\cache |
| 36 | + key: ${{ runner.os }}-sonar |
| 37 | + restore-keys: ${{ runner.os }}-sonar |
| 38 | + |
| 39 | + - name: Install SonarCloud scanners |
| 40 | + run: dotnet tool install --global dotnet-sonarscanner |
| 41 | + |
| 42 | + - name: Install dotnet reportgenerator |
| 43 | + run: dotnet tool install --global dotnet-reportgenerator-globaltool |
| 44 | + |
| 45 | + - name: Add nuget package source |
| 46 | + run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/DFE-Digital/index.json" |
| 47 | + |
| 48 | + - name: Restore dependencies |
| 49 | + run: dotnet restore DfE.ExternalApplications.Api.sln |
| 50 | + |
| 51 | + - name: Build, Test and Analyze |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 55 | + run: | |
| 56 | + dotnet-sonarscanner begin /d:sonar.qualitygate.wait=true /d:sonar.scanner.skipJreProvisioning=true /k:"DFE-Digital_external-applications-api" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" |
| 57 | + dotnet build DfE.ExternalApplications.Api.sln --no-restore |
| 58 | + dotnet test DfE.ExternalApplications.Api.sln --no-build --verbosity normal --collect:"XPlat Code Coverage" |
| 59 | + dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |
0 commit comments