Skip to content

Commit

Permalink
Task 5442/add automated tests to vscode extension (#5540)
Browse files Browse the repository at this point in the history
* Setup unittests

wip

* initial coverage setup

Improve coverage configs

checkpoint 1

checkpoint 2

checkpoint 3

add task to run test in build-extension workflow

Add sonar cloud analysis step

Remove unused libraries

Add projectKey to sonar properties

* test monorepo setup

* use paths for pull_request trigger
  • Loading branch information
fey101 authored Nov 11, 2024
1 parent 5922724 commit e843dce
Show file tree
Hide file tree
Showing 18 changed files with 2,084 additions and 668 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build-vscode-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ jobs:
working-directory: vscode/microsoft-kiota
- run: npm run lint
working-directory: vscode/microsoft-kiota
- name: run tests(linux)
if: runner.os == 'Linux'
run: xvfb-run -a npm run test-with-coverage
working-directory: vscode/microsoft-kiota
- name: run tests
if: runner.os != 'Linux'
run: npm run test-with-coverage
working-directory: vscode/microsoft-kiota
- name: Run sonar cloud analysis
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: vscode/microsoft-kiota
- run: npm run package
working-directory: vscode/microsoft-kiota
- run: npm i -g @vscode/vsce
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ on:
"**.md",
".vscode/**",
"**.svg",
"vscode/**",
]
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
paths:
[
"abstractions/**",
"authentication/**",
"serialization/**",
"http/**",
"**.md",
".vscode/**",
"**.svg",
"!abstractions/**",
"!authentication/**",
"!serialization/**",
"!http/**",
"!**.md",
"!.vscode/**",
"!**.svg",
"!vscode/**",
]

permissions:
Expand Down
4 changes: 3 additions & 1 deletion vscode/microsoft-kiota/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
dist/
out/
.kiotabin/
*.vsix
*.vsix
.vscode-test
coverage/
14 changes: 14 additions & 0 deletions vscode/microsoft-kiota/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
tests:[
{
files: 'out/test/**/*.test.js'
}
],
coverage: {
includeAll: true,
exclude: ["**/src/test", "**/dist", "**/*.test.[tj]s", "**/*.ts"],
reporter: ["text-summary", "html", "json-summary", "lcov", "cobertura"],
},
});
60 changes: 31 additions & 29 deletions vscode/microsoft-kiota/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,35 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
}
2 changes: 2 additions & 0 deletions vscode/microsoft-kiota/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ vsc-extension-quickstart.md
.kiotabin/
.vsix
images/samples/
.vscode-test
coverage/
6 changes: 3 additions & 3 deletions vscode/microsoft-kiota/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import stylisticTs from '@stylistic/eslint-plugin-ts'
import stylisticTs from '@stylistic/eslint-plugin-ts';
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";

export default [{
ignores: ["**/out", "**/dist", "**/*.d.ts", ".vscode-test", "node_modules", "eslint.config.mjs", "webpack.config.cjs"],
ignores: ["**/out", "**/dist", "**/*.d.ts", ".vscode-test", "node_modules", "eslint.config.mjs", "webpack.config.cjs", "coverage"],
}, {
files: ["**/*.ts"],
plugins: {
Expand Down Expand Up @@ -31,4 +31,4 @@ export default [{
"no-throw-literal": "warn",
semi: "off",
},
}];
}];
Loading

0 comments on commit e843dce

Please sign in to comment.