Skip to content

Commit

Permalink
Fix coverage (#191)
Browse files Browse the repository at this point in the history
* wip

* vscode test cli + merge coverage

* dont run e2e on linux ci

* separate commands

* fix bug with run-s in windows

* more timeout on debugger tests

* use c8 to run unit tests so it picks up child process coverage

* use components instead of flags

* let codecov merge reports and resolove yml location

* fix codecov.yml syntax
  • Loading branch information
ivojawer authored Oct 8, 2024
1 parent c971091 commit 6cb2a33
Show file tree
Hide file tree
Showing 16 changed files with 397 additions and 217 deletions.
37 changes: 11 additions & 26 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,25 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn compile-tests
- name: Run e2e test
- name: Install dependencies
run: yarn
- name: Compile
run: yarn compile-tests
- name: Run tests
if: matrix.os != 'ubuntu-latest'
uses: coactions/setup-xvfb@v1
with:
run: yarn test-with-coverage:e2e
- name: Run unit tests
run: yarn test-with-coverage:unit
- name: Update server coverage badge
uses: codecov/codecov-action@v4
run: yarn coverage
- name: Run tests
if: matrix.os == 'ubuntu-latest'
uses: coactions/setup-xvfb@v1
with:
files: ./packages/server/coverage/coverage-final.json
verbose: true
flags: lsp-ide-server
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Update client coverage badge
uses: codecov/codecov-action@v3
if: matrix.os == 'windows-latest'
with:
files: ./packages/client/coverage/coverage-final.json
verbose: true
flags: lsp-ide-client
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Update debugger coverage badge
run: yarn test:unit
- name: Update coverage
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'windows-latest'
with:
files: ./packages/debug-adapter/coverage/coverage-final.json
verbose: true
flags: debug-adapter
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Generate VSIX file
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ client/server
.yalc
yalc.lock
.DS_Store
coverage
coverage-*
.nyc_output
wollok.log
tsconfig.tsbuildinfo
Expand Down
6 changes: 6 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"lines": 70,
"all": true,
"include": ["out/**", "packages/**"]
}
17 changes: 17 additions & 0 deletions .vscode-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var { defineConfig } = require('@vscode/test-cli')

module.exports = defineConfig({
tests: [
{
files: 'out/client/src/test/*.test.js',
version: 'stable',
extensionDevelopmentPath: __dirname,
workspaceFolder: `${__dirname}/packages/client/testFixture`,
mocha: {
color: true,
timeout: 10 * 1000,
ui: 'tdd',
},
},
],
})
7 changes: 1 addition & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/client/src/test/index",
"${workspaceRoot}/packages/client/testFixture"
],
"testConfiguration": "${workspaceFolder}/.vscode-test.js",
"outFiles": ["${workspaceRoot}/out/**/*.js"],
"preLaunchTask": {
"type": "npm",
Expand Down
29 changes: 29 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
coverage:
status:
project:
default:
target: auto
threshold: 2%
base: auto

comment:
layout: 'diff, components, files'
behavior: default

component_management:
default_rules:
statuses:
- target: auto
individual_components:
- component_id: debug-adapter
name: Debugger
paths:
- packages/debug-adapter/
- component_id: client
name: Extension Client
paths:
- packages/client/
- component_id: lsp-server
name: LSP Server
paths:
- packages/server/
22 changes: 16 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,20 @@
"check-types": "tsc --noEmit",
"compile": "rimraf ./out && yarn check-types && yarn node esbuild.js",
"compile-tests": "rimraf ./out && tsc --outDir out",
"watch": "npm-run-all --parallel watch:*",
"watch": "run-p -l watch:esbuild watch:tsc",
"watch:esbuild": "yarn node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"watch:compile-tests": "rimraf ./out && tsc --outDir out --watch",
"lint": "yarn workspaces foreach -A run eslint . --fix",
"lint:fix": "cd client && eslint . --fix && cd ../server && eslint . --fix && cd ..",
"test": "yarn compile-tests && yarn test:e2e && yarn test:unit",
"test:e2e": "yarn lint && sh ./scripts/e2e.sh",
"test-with-coverage:e2e": "yarn lint && yarn compile-tests && env COVERAGE=true sh ./scripts/e2e.sh",
"test": "yarn compile-tests && yarn lint && yarn test:e2e && yarn test:unit",
"test:e2e": "vscode-test",
"test:unit": "yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter}' run test",
"test-with-coverage:unit": "yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter}' run test-with-coverage",
"test-local-coverage:unit": "yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter}' run test-local-coverage",
"nyc": "nyc",
"build-coverage-report": "rimraf coverage-total && cpy --flat ./coverage-e2e/coverage-final.json ./coverage-total --rename=coverage-e2e.json && cpy --flat ./coverage-unit/coverage-final.json ./coverage-total --rename=coverage-unit.json && nyc merge ./coverage-total ./coverage-total/coverage.json",
"coverage": "yarn cover:unit && yarn cover:e2e",
"cover:e2e": "vscode-test --coverage --coverage-repoter=text --coverage-reporter=json --coverage-output=coverage-e2e",
"cover:unit": "c8 --reporter=json --report-dir=coverage-unit yarn workspaces foreach -Rpt --from '{wollok-lsp-ide-server,wollok-debug-adapter}' run test",
"bundle": "yarn compile -- --production",
"package": "yarn bundle && vsce package --no-dependencies",
"vscode:prepublish": "yarn bundle",
Expand All @@ -328,14 +331,21 @@
"wollok-ts": "4.1.6"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/source-map-support": "^0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"@vscode/test-cli": "^0.0.10",
"@vscode/vsce": "^3.0.0",
"c8": "^10.1.2",
"cpy-cli": "^5.0.0",
"esbuild": "^0.23.1",
"eslint": "^8.35.0",
"husky": "^8.0.3",
"lint-staged": "^13.1.2",
"nyc": "^17.1.0",
"rimraf": "^6.0.1",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"yarn-run-all": "^3.1.1"
Expand Down
99 changes: 0 additions & 99 deletions packages/client/src/test/index.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/client/src/test/runTest.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/client/testFixture/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"wollokLSP.typeSystem.enabled": false
}
"wollokLSP.typeSystem.enabled": false
}
4 changes: 3 additions & 1 deletion packages/debug-adapter/.mocharc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var path = require('path')

module.exports = {
spec: 'src/test/**/*.test.ts',
spec: path.resolve(__dirname, '../../out/debug-adapter/src/test/*.test.js'),
}
10 changes: 2 additions & 8 deletions packages/debug-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
"type": "git",
"url": "https://github.com/uqbar-project/wollok-lsp-ide"
},
"main": "./out/index.js",
"scripts": {
"test": "yarn ts-mocha -p ../../tsconfig.json --config .mocharc.js",
"test-with-coverage": "nyc --reporter=json --lines 70 ts-mocha -p ../../tsconfig.json",
"test-local-coverage": "nyc --reporter=html --reporter=json --lines 70 ts-mocha -p ../../tsconfig.json"
"test": "mocha --config .mocharc.js"
},
"dependencies": {
"@vscode/debugadapter": "^1.66.0",
Expand All @@ -24,9 +21,6 @@
"@types/node": "^18.14.1",
"@types/vscode": "^1.92.0",
"@vscode/debugadapter-testsupport": "^1.67.0",
"mocha": "^10.7.3",
"nyc": "^17.0.0",
"ts-mocha": "^10.0.0",
"wollok-ts": "4.1.6"
"mocha": "^10.7.3"
}
}
10 changes: 5 additions & 5 deletions packages/debug-adapter/src/test/debug-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { DebugClient } from '@vscode/debugadapter-testsupport'
import * as assert from 'node:assert'
import { DebugProtocol } from '@vscode/debugprotocol'

const DEBUG_ADAPTER = path.resolve(__dirname, '../../../../out/debug-adapter/src/test/start-debug-session.js')
const FIXTURES_ROOT = path.resolve(__dirname, 'fixtures')
const DEBUG_ADAPTER = path.resolve(__dirname, 'start-debug-session.js')
const FIXTURES_ROOT = path.resolve(__dirname, '../../../../packages/debug-adapter/src/test/fixtures')
const PROGRAM = path.resolve(FIXTURES_ROOT, 'aProgram.wpgm')
const WLK = path.resolve(FIXTURES_ROOT, 'anObject.wlk')

describe('debug adapter', function () {
let dc: DebugClient

this.beforeEach( function () {
dc = new DebugClient('node', DEBUG_ADAPTER, 'wollok')
dc = new DebugClient('node', DEBUG_ADAPTER, 'wollok', { stdio: 'pipe' }, true)
return dc.start()
})

Expand All @@ -33,7 +33,7 @@ describe('debug adapter', function () {
},
}),
dc.configurationDoneRequest(),
dc.waitForEvent('terminated', 1000),
dc.waitForEvent('terminated', 3000),
])
})

Expand All @@ -47,7 +47,7 @@ describe('debug adapter', function () {
},
}),
dc.configurationDoneRequest(),
dc.waitForEvent('stopped', 1000),
dc.waitForEvent('stopped', 3000),
])


Expand Down
Loading

0 comments on commit 6cb2a33

Please sign in to comment.