Skip to content

Commit b3abe2d

Browse files
Add code cov support (#40)
- Use our internal self hosted code cov portal to manage the coverage reports (https://codecov.staging.cloud.databricks.com/gh/databricks/databricks-vscode). - This deployment of codecov might not be stable. But should be good enough for initial setup.
1 parent ccc1b6f commit b3abe2d

File tree

5 files changed

+1054
-291
lines changed

5 files changed

+1054
-291
lines changed

.github/workflows/push.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
branches: [main]
88

99
jobs:
10-
unit-test-sdk:
11-
name: Unit Test Databricks SDK
10+
test-sdk:
11+
name: Test Databricks SDK
1212
runs-on: ${{ matrix.os }}
1313

1414
strategy:
@@ -38,39 +38,28 @@ jobs:
3838
- name: Prettier and Linting
3939
run: yarn run test:lint
4040

41-
- name: Unit Tests
42-
run: yarn test:run
41+
- name: Unit Tests With Code Cov
42+
run: yarn test:cov
4343

44-
integ-test-sdk:
45-
name: Integration Test Databricks SDK
46-
runs-on: ubuntu-latest
47-
48-
defaults:
49-
run:
50-
working-directory: packages/databricks-sdk-js
51-
52-
steps:
53-
- uses: actions/checkout@v3
54-
55-
- name: Use Node.js 18.x
56-
uses: actions/setup-node@v3
57-
with:
58-
node-version: 18.x
59-
cache: "yarn"
60-
61-
- run: yarn install --immutable
62-
63-
- name: Integration Tests
64-
run: yarn run test:integ
44+
- name: Integration Tests With Code Cov
45+
run: yarn run test:integ:cov
6546
env:
6647
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
6748
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
6849
TEST_DEFAULT_CLUSTER_ID: ${{ secrets.TEST_DEFAULT_CLUSTER_ID }}
6950

51+
- run: |
52+
cd coverage
53+
mkdir -p all && mkdir -p final
54+
mv integration/coverage-final.json all/integration.json
55+
mv unit/coverage-final.json all/unit.json
56+
yarn nyc merge all final/final.json
57+
yarn nyc report --reporter text -t ./coverage/final >> $GITHUB_STEP_SUMMARY
58+
7059
test-extension:
7160
name: Test VSCode Extension
7261
runs-on: ${{ matrix.os }}
73-
needs: [unit-test-sdk, integ-test-sdk]
62+
needs: [test-sdk]
7463

7564
strategy:
7665
matrix:
@@ -105,16 +94,20 @@ jobs:
10594
- run: yarn run test:compile
10695
working-directory: packages/databricks-vscode
10796

108-
- name: Tests (OSX)
97+
- name: Unit Tests with Coverage (OSX)
10998
uses: GabrielBB/xvfb-action@v1
11099
if: matrix.os != 'windows-latest'
111100
with:
112-
run: yarn run test:unit
101+
run: yarn run test:cov
113102
working-directory: packages/databricks-vscode
114103

115-
- name: Tests (Windows)
104+
- name: Unit Tests with Coverage (Windows)
116105
if: matrix.os == 'windows-latest'
117-
run: yarn run test:unit
106+
run: yarn run test:cov
107+
working-directory: packages/databricks-vscode
108+
109+
- name: Show coverage test result
110+
run: yarn nyc report --reporter text -t ./coverage >> $GITHUB_STEP_SUMMARY
118111
working-directory: packages/databricks-vscode
119112

120113
- name: Integration Tests

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ out/
1010
!.yarn/plugins
1111
!.yarn/releases
1212
!.yarn/sdks
13-
!.yarn/versions
13+
!.yarn/versions
14+
**/coverage/
15+
**/.nyc_output/

packages/databricks-sdk-js/package.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,50 @@
2424
"test:lint": "eslint src --ext ts && prettier . -c",
2525
"test:run": "ts-mocha --type-check 'src/**/*.test.ts'",
2626
"test": "yarn run test:lint && yarn run test:run",
27-
"test:integ": "ts-mocha --type-check 'src/**/*.integ.ts'"
27+
"test:integ": "ts-mocha --type-check 'src/**/*.integ.ts'",
28+
"test:cov": "nyc --report-dir ./coverage/unit yarn run test:run",
29+
"test:integ:cov": "nyc --report-dir ./coverage/integration yarn run test:integ"
2830
},
2931
"dependencies": {
3032
"ini": "^3.0.0",
3133
"node-fetch": "^2.6.7"
3234
},
3335
"devDependencies": {
36+
"@istanbuljs/nyc-config-typescript": "^1.0.2",
3437
"@types/ini": "^1.3.31",
3538
"@types/mocha": "^9.1.1",
3639
"@types/node-fetch": "^2.6.2",
3740
"@types/tmp": "^0.2.3",
3841
"@types/uuid": "^8.3.4",
3942
"eslint": "^8.20.0",
4043
"mocha": "^10.0.0",
44+
"nyc": "^15.1.0",
4145
"prettier": "^2.7.1",
4246
"tmp-promise": "^3.0.3",
4347
"ts-loader": "^9.3.1",
4448
"ts-mocha": "^10.0.0",
4549
"ts-node": "^10.9.1",
4650
"typescript": "^4.7.4",
47-
"uuid": "^8.3.2"
51+
"uuid": "^8.3.2",
52+
"webpack": "^5.73.0"
53+
},
54+
"nyc": {
55+
"extends": "@istanbuljs/nyc-config-typescript",
56+
"check-coverage": false,
57+
"all": true,
58+
"skip-empty": true,
59+
"include": [
60+
"src/**/*.ts"
61+
],
62+
"exclude": [
63+
"src/**/*.test.ts",
64+
"src/**/*.integ.ts",
65+
"src/apis/**"
66+
],
67+
"reporter": [
68+
"lcov",
69+
"json"
70+
],
71+
"report-dir": "coverage"
4872
}
4973
}

packages/databricks-vscode/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
"test:integ:prepare": "yarn run vscode:package && extest get-vscode --type ${VSCODE_TEST_VERSION:-stable} --storage /tmp/vscode-test-databricks && extest get-chromedriver --storage /tmp/vscode-test-databricks && extest install-vsix -f databricks-0.0.1.vsix --storage /tmp/vscode-test-databricks",
220220
"test:integ:run": "yarn run test:compile && ts-node src/test/e2e/scripts/e2e.ts --storage /tmp/vscode-test-databricks --code_settings src/test/e2e/settings.json 'out/**/*.e2e.js'",
221221
"test:integ": "yarn run test:integ:prepare && yarn run test:integ:run",
222+
"test:cov": "nyc yarn run test:unit",
222223
"test": "yarn run compile && yarn run test:lint && yarn run test:unit",
223224
"build": "yarn run vscode:prepublish",
224225
"clean": "rm -rf node_modules out dist .vscode-test"
@@ -228,6 +229,7 @@
228229
"@vscode/webview-ui-toolkit": "^1.0.0"
229230
},
230231
"devDependencies": {
232+
"@istanbuljs/nyc-config-typescript": "^1.0.2",
231233
"@types/glob": "^7.2.0",
232234
"@types/mocha": "^9.1.1",
233235
"@types/node": "^18.0.6",
@@ -238,6 +240,7 @@
238240
"eslint": "^8.20.0",
239241
"glob": "^8.0.3",
240242
"mocha": "^10.0.0",
243+
"nyc": "^15.1.0",
241244
"prettier": "^2.7.1",
242245
"tmp-promise": "^3.0.3",
243246
"ts-loader": "^9.3.1",
@@ -248,5 +251,23 @@
248251
"vscode-extension-tester": "^4.3.0",
249252
"webpack": "^5.73.0",
250253
"webpack-cli": "^4.10.0"
254+
},
255+
"nyc": {
256+
"extends": "@istanbuljs/nyc-config-typescript",
257+
"check-coverage": false,
258+
"all": true,
259+
"skip-empty": true,
260+
"include": [
261+
"src/**/*.ts"
262+
],
263+
"exclude": [
264+
"src/**/*.test.ts",
265+
"src/**/*.integ.ts"
266+
],
267+
"reporter": [
268+
"lcov",
269+
"json"
270+
],
271+
"report-dir": "coverage"
251272
}
252273
}

0 commit comments

Comments
 (0)