|
1 | | -name: Build and analyze |
| 1 | +name: SonarQube |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
5 | 4 | push: |
6 | | - branches: [ "main" ] |
| 5 | + branches: |
| 6 | + - main |
7 | 7 | pull_request: |
8 | | - branches: [ "main" ] |
| 8 | + types: [ opened, synchronize, reopened ] |
9 | 9 |
|
10 | 10 | jobs: |
11 | 11 | build: |
12 | 12 | name: Build and analyze |
13 | 13 | runs-on: windows-latest |
14 | | - env: |
15 | | - ProjectName: 'AStar.Dev.Functional.Extensions' |
16 | | - RepositoryName: 'astar-dev-functional-extensions' |
| 14 | + |
17 | 15 | steps: |
18 | | - - name: Set up JDK |
19 | | - uses: actions/setup-java@v4.4.0 |
| 16 | + - name: Set up JDK 17 |
| 17 | + uses: actions/setup-java@v4 |
20 | 18 | with: |
21 | 19 | java-version: 17 |
22 | 20 | distribution: 'zulu' |
23 | 21 |
|
24 | | - - name: Checkout |
25 | | - |
| 22 | + - uses: actions/checkout@v4 |
26 | 23 | with: |
27 | | - fetch-depth: 0 |
| 24 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
28 | 25 |
|
29 | | - - name: Cache SonarCloud packages |
30 | | - uses: actions/cache@v4.2.3 |
| 26 | + - name: Cache SonarQube Cloud packages |
| 27 | + uses: actions/cache@v4 |
31 | 28 | with: |
32 | 29 | path: ~\sonar\cache |
33 | 30 | key: ${{ runner.os }}-sonar |
34 | 31 | restore-keys: ${{ runner.os }}-sonar |
35 | 32 |
|
36 | | - - name: Cache SonarCloud scanner |
| 33 | + - name: Cache SonarQube Cloud scanner |
37 | 34 | id: cache-sonar-scanner |
38 | | - uses: actions/cache@v4.2.3 |
| 35 | + uses: actions/cache@v4 |
39 | 36 | with: |
40 | 37 | path: .\.sonar\scanner |
41 | 38 | key: ${{ runner.os }}-sonar-scanner |
42 | 39 | restore-keys: ${{ runner.os }}-sonar-scanner |
43 | 40 |
|
44 | | - - name: Install SonarCloud scanner |
| 41 | + - name: Install SonarQube Cloud scanner |
45 | 42 | if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
46 | 43 | shell: powershell |
47 | 44 | run: | |
|
50 | 47 |
|
51 | 48 | - name: Build and analyze |
52 | 49 | env: |
53 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
54 | 50 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
55 | 51 | shell: powershell |
56 | 52 | run: | |
57 | | - dotnet tool install --global dotnet-coverage |
58 | | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_${{ env.RepositoryName }}" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.scanner.scanAll=false |
59 | | - dotnet-coverage collect 'dotnet test --filter "FullyQualifiedName!~Tests.EndToEnd"' -f xml -o 'coverage.xml' |
60 | | - dotnet build --configuration Release |
61 | | - dotnet-coverage collect 'dotnet test --filter "FullyQualifiedName!~Tests.EndToEnd"' -f xml -o 'coverage.xml' |
| 53 | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"astar-development_astar-dev-functional-extensions" /o:"astar-development" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" |
| 54 | + dotnet build |
62 | 55 | .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |
63 | | -
|
64 | | - - name: Pack NuGet package |
65 | | - if: github.ref == 'refs/heads/main-not' |
66 | | - run: dotnet pack .\src\${{ env.ProjectName }}\${{ env.ProjectName }}.csproj |
67 | | - |
68 | | - - name: Push to NuGet |
69 | | - if: github.ref == 'refs/heads/main-not' |
70 | | - run: dotnet nuget push "**\${{ env.ProjectName }}.*.nupkg" --api-key ${{secrets.nuget_api_key}} --skip-duplicate --source https://api.nuget.org/v3/index.json |
71 | | - |
0 commit comments