From fdf9d5f96e652983950dc32ff017c2f72131518e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 13:28:10 -0400 Subject: [PATCH 1/8] - replaces sonar login by token Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a3bfb0497d..39ea1cfa1b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -91,7 +91,7 @@ jobs: CoverletOutputFormat: "opencover" # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682 shell: pwsh run: | - ./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoft_kiota" /o:"microsoft" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/**/coverage.opencover.xml" + ./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoft_kiota" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/**/coverage.opencover.xml" dotnet build dotnet test kiota.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From 016603c0e9c029912c8d791c3f692ca4d8ab789d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 14:23:51 -0400 Subject: [PATCH 2/8] - removes cache condition for tool install Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 39ea1cfa1b..d3fb2206ea 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -79,10 +79,9 @@ jobs: 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 + New-Item -Path ./.sonar/scanner -ItemType Directory -Force dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner - name: Build and analyze env: From 026431ec87cd7a68e9a6cddb8d5bd0488f5db74b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 14:30:11 -0400 Subject: [PATCH 3/8] - fixes sonar cache keys Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index d3fb2206ea..0741c2d7aa 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -70,14 +70,14 @@ jobs: with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar-${{ hashFiles('./.sonar/cache/**') }} - name: Cache SonarCloud scanner id: cache-sonar-scanner uses: actions/cache@v4 with: path: ./.sonar/scanner key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner + restore-keys: ${{ runner.os }}-sonar-scanner-${{ hashFiles('./.sonar/scanner/**') }} - name: Install SonarCloud scanner shell: pwsh run: | From b75b00a16845450a815ed9ca76687e372f861b59 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 14:32:59 -0400 Subject: [PATCH 4/8] - moves file hash to correct key Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 0741c2d7aa..6ef1e2c459 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -69,15 +69,15 @@ jobs: uses: actions/cache@v4 with: path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar-${{ hashFiles('./.sonar/cache/**') }} + key: ${{ runner.os }}-sonar-${{ hashFiles('./.sonar/cache/**') }} + restore-keys: ${{ runner.os }}-sonar - name: Cache SonarCloud scanner id: cache-sonar-scanner uses: actions/cache@v4 with: path: ./.sonar/scanner - key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner-${{ hashFiles('./.sonar/scanner/**') }} + key: ${{ runner.os }}-sonar-scanner-${{ hashFiles('./.sonar/scanner/**') }} + restore-keys: ${{ runner.os }}-sonar-scanner - name: Install SonarCloud scanner shell: pwsh run: | From 9feedd07d9157d42559f9492bc45279e1c7be73b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 14:38:10 -0400 Subject: [PATCH 5/8] - fixes cache path for sonarcloud cache Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 6ef1e2c459..9bb78fe7b5 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -69,7 +69,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.sonar/cache - key: ${{ runner.os }}-sonar-${{ hashFiles('./.sonar/cache/**') }} + key: ${{ runner.os }}-sonar-${{ hashFiles('~/.sonar/cache/**') }} restore-keys: ${{ runner.os }}-sonar - name: Cache SonarCloud scanner id: cache-sonar-scanner From d9871757f1b4758a53588279753e2f35f445cb89 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 14:58:01 -0400 Subject: [PATCH 6/8] - removes scanner caching as invalidation doesnt work as expected and there's no way to make it work without maintaining another version file Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 9bb78fe7b5..d926f2e1c6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -69,20 +69,12 @@ jobs: uses: actions/cache@v4 with: path: ~/.sonar/cache - key: ${{ runner.os }}-sonar-${{ hashFiles('~/.sonar/cache/**') }} + key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Cache SonarCloud scanner - id: cache-sonar-scanner - uses: actions/cache@v4 - with: - path: ./.sonar/scanner - key: ${{ runner.os }}-sonar-scanner-${{ hashFiles('./.sonar/scanner/**') }} - restore-keys: ${{ runner.os }}-sonar-scanner - name: Install SonarCloud scanner shell: pwsh run: | - New-Item -Path ./.sonar/scanner -ItemType Directory -Force - dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner + dotnet tool install dotnet-sonarscanner - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any @@ -90,7 +82,7 @@ jobs: CoverletOutputFormat: "opencover" # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682 shell: pwsh run: | - ./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoft_kiota" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/**/coverage.opencover.xml" + dotnet tool run dotnet-sonarscanner begin /k:"microsoft_kiota" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="tests/**/coverage.opencover.xml" dotnet build dotnet test kiota.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + dotnet tool run dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" From c3c3d4a00a550856cda71b448022fabf4bf11380 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 14:59:47 -0400 Subject: [PATCH 7/8] - adds missing manifest argument Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index d926f2e1c6..1ae4bff8b6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -74,7 +74,7 @@ jobs: - name: Install SonarCloud scanner shell: pwsh run: | - dotnet tool install dotnet-sonarscanner + dotnet tool install dotnet-sonarscanner --create-manifest-if-needed - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From d19f01492a4758572526277b0860bb9d1a39fb45 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 6 May 2024 15:43:44 -0400 Subject: [PATCH 8/8] - cleanup Signed-off-by: Vincent Biret --- .github/workflows/sonarcloud.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 1ae4bff8b6..56c1d98a16 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -72,9 +72,7 @@ jobs: key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Install SonarCloud scanner - shell: pwsh - run: | - dotnet tool install dotnet-sonarscanner --create-manifest-if-needed + run: dotnet tool install dotnet-sonarscanner --create-manifest-if-needed - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any