From e9c611ec8f17ca3e560bac1598e23c008942383c Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Fri, 1 Apr 2022 16:20:27 -0500 Subject: [PATCH] ci: Move sonarcloud job into separate workflow file --- .github/workflows/build.yml | 55 ------------------------ .github/workflows/sonarcloud.yml | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e98bdb9a..d0d36be7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -130,58 +130,3 @@ jobs: draft: false prerelease: ${{ steps.gitversion.outputs.preReleaseTag != '' }} - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - env: - DOTNET_ROLL_FORWARD: LatestMajor - GITHUB_TOKEN: ${{ secrets.PAT }} - steps: - - name: Get Source Code - uses: actions/checkout@v2 - with: - fetch-depth: 0 # avoid shallow clone for GitVersion - - - name: Setup dotnet - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ env.dotnetVersion }} - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.7 - with: - versionSpec: 5.x - - - name: Determine Version - uses: gittools/actions/gitversion/execute@v0.9.7 - id: gitversion - - - name: Install Sonar Scanner - run: dotnet tool install --global dotnet-sonarscanner - - - name: Begin Sonar Scanner - run: > - dotnet sonarscanner begin - -o:"rcdailey" - -k:"rcdailey_trash-updater" - -n:"Trash Updater" - -v:"${{ steps.gitversion.outputs.fullSemVer }}" - -d:sonar.login="${{ secrets.SONAR_TOKEN }}" - -d:sonar.host.url="https://sonarcloud.io" - -d:sonar.cs.opencover.reportsPaths="**/TestResults/*/coverage.opencover.xml" - - # Run a full build command because if we just do the tests, it will not build everything. - - name: Build - run: dotnet build src - - - name: Test - run: > - dotnet test src - --no-build - --collect:"XPLat Code Coverage" - -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover - - - name: End Sonar Scanner - run: > - dotnet sonarscanner end - -d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 00000000..7086beae --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,72 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +name: Sonarcloud + +on: + push: + paths-ignore: + - "wiki/**" + - "**.md" + pull_request: + paths-ignore: + - "wiki/**" + - "**.md" + +env: + dotnetVersion: "6.0.x" + +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + env: + DOTNET_ROLL_FORWARD: LatestMajor + GITHUB_TOKEN: ${{ secrets.PAT }} + steps: + - name: Get Source Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 # avoid shallow clone for GitVersion + + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: ${{ env.dotnetVersion }} + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.7 + with: + versionSpec: 5.x + + - name: Determine Version + uses: gittools/actions/gitversion/execute@v0.9.7 + id: gitversion + + - name: Install Sonar Scanner + run: dotnet tool install --global dotnet-sonarscanner + + - name: Begin Sonar Scanner + run: > + dotnet sonarscanner begin + -o:"rcdailey" + -k:"rcdailey_trash-updater" + -n:"Trash Updater" + -v:"${{ steps.gitversion.outputs.fullSemVer }}" + -d:sonar.login="${{ secrets.SONAR_TOKEN }}" + -d:sonar.host.url="https://sonarcloud.io" + -d:sonar.cs.opencover.reportsPaths="**/TestResults/*/coverage.opencover.xml" + + # Run a full build command because if we just do the tests, it will not build everything. + - name: Build + run: dotnet build src + + - name: Test + run: > + dotnet test src + --no-build + --collect:"XPLat Code Coverage" + -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover + + - name: End Sonar Scanner + run: > + dotnet sonarscanner end + -d:sonar.login="${{ secrets.SONAR_TOKEN }}"