diff --git a/README.md b/README.md index 1d18de5a8..e3b2bef4a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # code-server · [!["GitHub Discussions"](https://img.shields.io/badge/%20GitHub-%20Discussions-gray.svg?longCache=true&logo=github&colorB=purple)](https://github.com/cdr/code-server/discussions) [!["Join us on Slack"](https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&logo=slack&colorB=brightgreen)](https://cdr.co/join-community) [![Twitter Follow](https://img.shields.io/twitter/follow/CoderHQ?label=%40CoderHQ&style=social)](https://twitter.com/coderhq) +![Lines](https://img.shields.io/badge/Coverage-46.71%25-green.svg) + Run [VS Code](https://github.com/Microsoft/vscode) on any machine anywhere and access it in the browser. ![Screenshot](./doc/assets/screenshot.png) diff --git a/ci/README.md b/ci/README.md index 5ef2a2c51..b261a0ff4 100644 --- a/ci/README.md +++ b/ci/README.md @@ -21,6 +21,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) - Remember to update the chart version as well on top of appVersion in `Chart.yaml`. - Run `rg -g '!yarn.lock' -g '!*.svg' '3\.7\.5'` to ensure all values have been changed. Replace the numbers as needed. + 4. Update the code coverage badge (see [here](#updating-code-coverage-in-readme) for instructions) 2. GitHub actions will generate the `npm-package`, `release-packages` and `release-images` artifacts. 1. You do not have to wait for these. 3. Run `yarn release:github-draft` to create a GitHub draft release from the template with @@ -43,6 +44,19 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) 11. Update the homebrew package. - Send a pull request to [homebrew-core](https://github.com/Homebrew/homebrew-core) with the URL in the [formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/code-server.rb) updated. +## Updating Code Coverage in README + +Currently, we run a command to manually generate the code coverage shield. Follow these steps: + +1. Run `yarn badges` +2. Go into the README and change the color from `red` to `green` in this line: + +``` +![Lines](https://img.shields.io/badge/Coverage-46.71%25-red.svg) +``` + +NOTE: we have to manually change the color because the default is red if coverage is less than 80. See code [here](https://github.com/olavoparno/istanbul-badges-readme/blob/develop/src/editor.ts#L24-L33). + ## dev This directory contains scripts used for the development of code-server. diff --git a/package.json b/package.json index a432acab4..33310d2c0 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "test": "./ci/dev/test.sh", "ci": "./ci/dev/ci.sh", "watch": "VSCODE_IPC_HOOK_CLI= NODE_OPTIONS=--max_old_space_size=32384 ts-node ./ci/dev/watch.ts", - "icons": "./ci/dev/gen_icons.sh" + "icons": "./ci/dev/gen_icons.sh", + "badges": "istanbul-badges-readme" }, "main": "out/node/entry.js", "devDependencies": { @@ -53,6 +54,7 @@ "eslint-config-prettier": "^6.0.0", "eslint-plugin-import": "^2.18.2", "eslint-plugin-prettier": "^3.1.0", + "istanbul-badges-readme": "^1.2.0", "leaked-handles": "^5.2.0", "parcel-bundler": "^1.12.4", "prettier": "^2.0.5", @@ -124,10 +126,16 @@ "coverageDirectory": "/coverage", "coverageReporters": [ "json", + "json-summary", "text" ], "coveragePathIgnorePatterns": [ "out" - ] + ], + "coverageThreshold": { + "global": { + "lines": 40 + } + } } } diff --git a/test/socket.test.ts b/test/socket.test.ts index 7a5a71764..9ff5038ec 100644 --- a/test/socket.test.ts +++ b/test/socket.test.ts @@ -14,8 +14,8 @@ describe("SocketProxyProvider", () => { const onServerError = new Emitter<{ event: string; error: Error }>() const onClientError = new Emitter<{ event: string; error: Error }>() const onProxyError = new Emitter<{ event: string; error: Error }>() - const fromServerToClient = new Emitter() - const fromClientToServer = new Emitter() + const fromServerToClient = new Emitter() + const fromClientToServer = new Emitter() const fromClientToProxy = new Emitter() let errors = 0 @@ -92,10 +92,10 @@ describe("SocketProxyProvider", () => { it("should work without a proxy", async () => { server.write("server->client") - const dataFromServerToClient = await (await getData(fromServerToClient)).toString() + const dataFromServerToClient = (await getData(fromServerToClient)).toString() expect(dataFromServerToClient).toBe("server->client") client.write("client->server") - const dataFromClientToServer = await (await getData(fromClientToServer)).toString() + const dataFromClientToServer = (await getData(fromClientToServer)).toString() expect(dataFromClientToServer).toBe("client->server") expect(errors).toEqual(0) }) diff --git a/yarn.lock b/yarn.lock index 618121a70..d692116ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4360,6 +4360,11 @@ isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= +istanbul-badges-readme@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/istanbul-badges-readme/-/istanbul-badges-readme-1.2.0.tgz#f6dc226fb2ef498b1743ca15ae2dd82ccd3b0c28" + integrity sha512-7yU9tFbl7IsqlgfFF52G1fj7w2Z2k+UykVrCCIAQ8pnezZIIwxtAD079cIcqsbyCH7gCAALhiW3waHv9C24vrg== + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"