From 3b43be17bb7ae3f4affb4e36f4a7f4b38ad5a4ce Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 13:02:38 +0530 Subject: [PATCH 01/10] Create sonar-cloud-analysis.yml --- .github/workflows/sonar-cloud-analysis.yml | 52 ++++++++++++++++++++++ 1 file changed, 52 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 00000000..a2c5cd1b --- /dev/null +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -0,0 +1,52 @@ +name: .NET + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +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' + shell: pwsh + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + 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 }} + shell: pwsh + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /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 }}" From dd489c18790fd4f20177ec48814cc1254c1ec474 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 13:06:42 +0530 Subject: [PATCH 02/10] format sonar-cloud-analysis.yml :art: --- .github/workflows/sonar-cloud-analysis.yml | 82 +++++++++++----------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index a2c5cd1b..b72cccfd 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -2,51 +2,51 @@ name: .NET on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + 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' - shell: pwsh - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - 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 }} - shell: pwsh - run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /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 }}" + - 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' + shell: pwsh + run: | + New-Item -Path .\.sonar\scanner -ItemType Directory + 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 }} + shell: pwsh + run: | + .\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /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 }}" From d87438a8686c3e9a69e992dfb27f8cbbe56c0800 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 13:10:12 +0530 Subject: [PATCH 03/10] update GitHub action name --- .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 b72cccfd..1025f811 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -1,4 +1,4 @@ -name: .NET +name: SonarCLoud Analysis on: push: From d68f81c32bf1a5ce4ba3052c21eb77498b2ff8c3 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 13:26:06 +0530 Subject: [PATCH 04/10] use default shell to run commands --- .github/workflows/sonar-cloud-analysis.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index 1025f811..7080b070 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -35,18 +35,14 @@ jobs: - name: Install SonarCloud scanner if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' - shell: pwsh - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + 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 }} - shell: pwsh run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /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-net" /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 }}" + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From 2bdd2543a20b00f489337d997e65ffc37c3fbd8f Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 13:30:30 +0530 Subject: [PATCH 05/10] add test command in analysis --- .github/workflows/sonar-cloud-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index 7080b070..a0faa526 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -45,4 +45,5 @@ jobs: ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore dotnet build --no-restore + dotnet test --no-build ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From c0999c965182579908bf641b7f6145097af98efc Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 13:53:43 +0530 Subject: [PATCH 06/10] export code coverage file for sonar cloud --- .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 a0faa526..5dbc7085 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -45,5 +45,5 @@ jobs: ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore dotnet build --no-restore - dotnet test --no-build + dotnet test --no-build --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage/ /p:MergeWith=./coverage/ --collect "Code coverage" ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From 50b74c45aca5a0fb1383f781d05d520fdc9df32d Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 14:17:29 +0530 Subject: [PATCH 07/10] remove tests command from sonar analysis --- .github/workflows/sonar-cloud-analysis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/sonar-cloud-analysis.yml b/.github/workflows/sonar-cloud-analysis.yml index 5dbc7085..7080b070 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -45,5 +45,4 @@ jobs: ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore dotnet build --no-restore - dotnet test --no-build --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage/ /p:MergeWith=./coverage/ --collect "Code coverage" ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From ab1f7578a6346969de1b0ca14c862c513279433f Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 14:46:45 +0530 Subject: [PATCH 08/10] Fix 'errorResponse' is null on at least one execution path. --- Src/Notion.Client/RestClient/RestClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Notion.Client/RestClient/RestClient.cs b/Src/Notion.Client/RestClient/RestClient.cs index 3def9161..91428218 100644 --- a/Src/Notion.Client/RestClient/RestClient.cs +++ b/Src/Notion.Client/RestClient/RestClient.cs @@ -69,7 +69,7 @@ private static async Task BuildException(HttpResponseMessage response } } - return new NotionApiException(response.StatusCode, errorResponse?.ErrorCode, errorResponse.Message); + return new NotionApiException(response.StatusCode, errorResponse?.ErrorCode, errorResponse?.Message); } private async Task SendAsync( From cc71bb788245ab64561b3bdf93264da5c9a88215 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 14:54:59 +0530 Subject: [PATCH 09/10] use release configuration --- .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 7080b070..96938d62 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -44,5 +44,5 @@ jobs: run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore - dotnet build --no-restore + dotnet build --no-restore --configuration release ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" From d54c8159beb01f5d364b585e7b65ea4f505d5947 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Sat, 17 Jul 2021 15:09:41 +0530 Subject: [PATCH 10/10] revert configuration flag change --- .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 96938d62..7080b070 100644 --- a/.github/workflows/sonar-cloud-analysis.yml +++ b/.github/workflows/sonar-cloud-analysis.yml @@ -44,5 +44,5 @@ jobs: run: | ./.sonar/scanner/dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet restore - dotnet build --no-restore --configuration release + dotnet build --no-restore ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"