|
| 1 | +name: .NET |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "**" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master" ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + |
| 12 | + runs-on: windows-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + dotnet: [ '8.0.x' ] |
| 17 | + name: .NET ${{ matrix.dotnet }} |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Set up JDK 17 |
| 21 | + uses: actions/setup-java@v4 |
| 22 | + with: |
| 23 | + java-version: 17 |
| 24 | + distribution: 'zulu' # Alternative distribution options are available. |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 28 | + - name: Setup .NET |
| 29 | + uses: actions/setup-dotnet@v4 |
| 30 | + with: |
| 31 | + dotnet-version: ${{ matrix.dotnet }} |
| 32 | + - name: Cache SonarQube Cloud packages |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: ~\sonar\cache |
| 36 | + key: ${{ runner.os }}-sonar |
| 37 | + restore-keys: ${{ runner.os }}-sonar |
| 38 | + - name: Cache SonarQube Cloud scanner |
| 39 | + id: cache-sonar-scanner |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: .\.sonar\scanner |
| 43 | + key: ${{ runner.os }}-sonar-scanner |
| 44 | + restore-keys: ${{ runner.os }}-sonar-scanner |
| 45 | + - name: Install SonarQube Cloud scanner |
| 46 | + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' |
| 47 | + shell: powershell |
| 48 | + run: | |
| 49 | + New-Item -Path .\.sonar\scanner -ItemType Directory |
| 50 | + dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner |
| 51 | + - name: Restore dependencies |
| 52 | + run: dotnet restore |
| 53 | + - name: SonarCloudPrepare |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 56 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 57 | + run: .\.sonar\scanner\dotnet-sonarscanner begin /k:"TensionDev_UUID.Serialization.SystemTextJson" /o:"tensiondev" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.scanner.scanAll=false /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml |
| 58 | + - name: Build |
| 59 | + run: dotnet build --no-restore |
| 60 | + - name: Test |
| 61 | + run: dotnet test --no-build --verbosity normal --collect "XPlat Code Coverage;Format=opencover" |
| 62 | + - name: SonarCloudAnalyze |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 65 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 66 | + run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" |
| 67 | + |
| 68 | + test: |
| 69 | + |
| 70 | + strategy: |
| 71 | + matrix: |
| 72 | + dotnet: [ '8.0.x' ] |
| 73 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 74 | + |
| 75 | + runs-on: ${{ matrix.os }} |
| 76 | + |
| 77 | + name: .NET ${{ matrix.dotnet }} on ${{ matrix.os }} |
| 78 | + |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + with: |
| 82 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 83 | + - name: Setup .NET |
| 84 | + uses: actions/setup-dotnet@v4 |
| 85 | + with: |
| 86 | + dotnet-version: ${{ matrix.dotnet }} |
| 87 | + - name: Restore dependencies |
| 88 | + run: dotnet restore |
| 89 | + - name: Build |
| 90 | + run: dotnet build --no-restore |
| 91 | + - name: Test |
| 92 | + run: dotnet test --no-build --verbosity normal --collect "XPlat Code Coverage;Format=opencover" |
0 commit comments