From 11ab87b69d52c35ca73b096fc8f62308b2ee0407 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 19 Jul 2021 21:42:31 +0530 Subject: [PATCH 1/3] Add sonar cloud analysis GitHub action :construction_worker: --- .github/workflows/sonar-cloud-analysis.yml | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/sonar-cloud-analysis.yml diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml new file mode 100644 index 0000000..23b189e --- /dev/null +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -0,0 +1,48 @@ +name: SonarCLoud Analysis + +on: + push: + branches: [main] + pull_request: + branches: [main] + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + - uses: actions/checkout@v2 + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~\sonar\cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache SonarCloud scanner + id: cache-sonar-scanner + uses: actions/cache@v1 + with: + path: .\.sonar\scanner + key: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner + + - name: Install SonarCloud scanner + if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' + run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-extensions" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + dotnet restore + dotnet build --no-restore + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From c34b36d73d1d3ae9ad5e7c7f48f14c770a27fe32 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 19 Jul 2021 21:49:51 +0530 Subject: [PATCH 2/3] Fix the command --- .github/workflows/sonar-cloud-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index 23b189e..4ec1b77 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -42,7 +42,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-extensions" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-extensions" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore dotnet build --no-restore - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file From ae30d9f5876c9e951832850e5baac559be3f6d95 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 19 Jul 2021 21:59:43 +0530 Subject: [PATCH 3/3] Run formatter :art: --- .github/workflows/sonar-cloud-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index 4ec1b77..15a784c 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -45,4 +45,4 @@ jobs: ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-extensions" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore dotnet build --no-restore - ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"