From 7fe658e3944051f17732f8fb9aa24ffea8dbe421 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Tue, 12 Nov 2024 12:50:22 +0300 Subject: [PATCH 1/3] Add check for sonar token and make output path in tests platform agnostic --- .github/workflows/build-vscode-extension.yml | 12 ++++++++++++ .../suite/commands/generateClientCommand.test.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml index ee28133534..bc071c49ca 100644 --- a/.github/workflows/build-vscode-extension.yml +++ b/.github/workflows/build-vscode-extension.yml @@ -10,7 +10,19 @@ permissions: contents: read jobs: + checksecret: + name: check if SONAR_TOKEN is set in github secrets + runs-on: ubuntu-latest + outputs: + is_SONAR_TOKEN_set: ${{ steps.checksecret_job.outputs.is_SONAR_TOKEN_set }} + steps: + - name: Check whether unity activation requests should be done + id: checksecret_job + run: | + echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT build_extension: + needs: [checksecret] + if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/vscode/microsoft-kiota/src/test/suite/commands/generateClientCommand.test.ts b/vscode/microsoft-kiota/src/test/suite/commands/generateClientCommand.test.ts index 7f15478fb7..edc0337b60 100644 --- a/vscode/microsoft-kiota/src/test/suite/commands/generateClientCommand.test.ts +++ b/vscode/microsoft-kiota/src/test/suite/commands/generateClientCommand.test.ts @@ -217,7 +217,7 @@ suite('GenerateClientCommand Test Suite', () => { //stub and call generateCommand const generateClientCommand = new generateModule.GenerateClientCommand(treeProvider, context, viewProvider, setWorkspaceGenerationContext); - var outputPath = "path/to/temp/folder/appPackage"; + var outputPath = path.join("path", "to", "temp", "folder", "appPackage"); //make it os agnostic const generateManifestAndRefreshUIExpectation = sinon.mock(generateClientCommand).expects( "generateManifestAndRefreshUI").twice().withArgs( config, extensionSettings, outputPath, ["repairs"] From d2fb117e30e249491b17074b5785de68ee6505a5 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Tue, 12 Nov 2024 13:01:07 +0300 Subject: [PATCH 2/3] make the if sonar token is set requirement more task-specific --- .github/workflows/build-vscode-extension.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml index bc071c49ca..760dc50174 100644 --- a/.github/workflows/build-vscode-extension.yml +++ b/.github/workflows/build-vscode-extension.yml @@ -22,7 +22,6 @@ jobs: echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT build_extension: needs: [checksecret] - if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -44,14 +43,15 @@ jobs: - run: npm run lint working-directory: vscode/microsoft-kiota - name: run tests(linux) - if: runner.os == 'Linux' + if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' and runner.os == 'Linux' run: xvfb-run -a npm run test-with-coverage working-directory: vscode/microsoft-kiota - name: run tests - if: runner.os != 'Linux' + if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' and runner.os != 'Linux' run: npm run test-with-coverage working-directory: vscode/microsoft-kiota - name: Run sonar cloud analysis + if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From 9e58494629599e9b17f773d4733c8d178bbe21d9 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Tue, 12 Nov 2024 13:20:26 +0300 Subject: [PATCH 3/3] only check for secret before doing the sonar analysis --- .github/workflows/build-vscode-extension.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml index 760dc50174..7b9742750e 100644 --- a/.github/workflows/build-vscode-extension.yml +++ b/.github/workflows/build-vscode-extension.yml @@ -43,11 +43,11 @@ jobs: - run: npm run lint working-directory: vscode/microsoft-kiota - name: run tests(linux) - if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' and runner.os == 'Linux' + if: runner.os == 'Linux' run: xvfb-run -a npm run test-with-coverage working-directory: vscode/microsoft-kiota - name: run tests - if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true' and runner.os != 'Linux' + if: runner.os != 'Linux' run: npm run test-with-coverage working-directory: vscode/microsoft-kiota - name: Run sonar cloud analysis