From 6bc23062f3c86973d37522e95da696de7b3fbc9d Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Thu, 15 Dec 2022 18:53:23 -0500 Subject: [PATCH] chore(tests): local codecov integration - https://codecov.io Signed-off-by: Lexus Drumgold --- .dictionary.txt | 1 + .gitignore | 1 + .vscode/settings.json | 3 +++ CONTRIBUTING.md | 41 +++++++++++++++++++++++++++++++++-------- package.json | 2 ++ 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.dictionary.txt b/.dictionary.txt index a0ba578d..cd5212ad 100644 --- a/.dictionary.txt +++ b/.dictionary.txt @@ -1,6 +1,7 @@ ardatan bdougie cefc +codecov commitlintrc dawidd dedupe diff --git a/.gitignore b/.gitignore index 152598f9..34f145d5 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ yarn-error.log* # ------------------------------------------------------------------------------ *.lcov __tests__/report.json +codecov coverage/ tsconfig.temp.json vitest.config.*.timestamp-*.mjs diff --git a/.vscode/settings.json b/.vscode/settings.json index 620ace5f..cdbf8acf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { + "[dotenv]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + }, "[handlebars]": { "editor.defaultFormatter": "Greenbyte.handlebars-preview", "editor.rulers": [ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a3450d23..7e257e93 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,7 +74,9 @@ Follow the steps below to setup your local development environment: # LOAD ENVIRONMENT VARIABLES IN CURRENT WORKING DIRECTORY # 1. $GITHUB_WORKSPACE + # 2. environment variables (local) [ -d $PWD/.git ] && export GITHUB_WORKSPACE=$(git rev-parse --show-toplevel) + [ -f $PWD/.env.local ] && source $PWD/.env.local ``` 9. Load `dotenv` plugin via `$ZDOTDIR/.zshrc`: @@ -96,6 +98,7 @@ Follow the steps below to setup your local development environment: | name | | ----------------------- | | `CI` | +| `CODECOV_TOKEN` | | `NODE_ENV` | | `NODE_NO_WARNINGS` | | `NODE_OPTIONS` | @@ -231,11 +234,31 @@ Be sure to use [`it.skip`][15] or [`it.todo`][16] where appropriate. - `yarn test:cov` - See terminal for coverage output +#### Code Coverage + +Code coverage is reported using [Codecov][17]. + +To manually upload coverage reports: + +1. Retrieve `CODECOV_TOKEN` from a maintainer + +2. Add `CODECOV_TOKEN` to `.env.local` + +3. Reload shell + + ```sh + exec $SHELL + ``` + +4. Install the [Codecov Uploader][18] + +5. Run `yarn codecov` + ### Getting Help If you need help, make note of any issues in their respective files in the form of a [JSDoc comment][12]. If you need help with a test, don't forget to use [`it.skip`][15] and/or [`it.todo`][16]. Afterwards, [start a discussion in the -Q&A category][17]. +Q&A category][19]. ## Labels @@ -257,7 +280,7 @@ If you haven't found a related open issue, or feel that a closed issue should be A well-written issue - contains a well-written summary of the bug, feature, or improvement -- contains a [minimal, reproducible example][18] (if applicable) +- contains a [minimal, reproducible example][20] (if applicable) - includes links to related articles and documentation (if any) - includes an emoji in the title :wink: @@ -356,8 +379,8 @@ Before deploying, the following steps must be completed: - delete the release branch - on release publish, [publish workflow](.github/workflows/publish.yml) will fire - if successful, the workflow will: - - publish package to [github package registry][19] - - publish package to [npm][20] + - publish package to [github package registry][21] + - publish package to [npm][22] [1]: https://brew.sh [2]: @@ -376,7 +399,9 @@ Before deploying, the following steps must be completed: [14]: https://vitest.dev [15]: https://vitest.dev/api/#test-skip [16]: https://vitest.dev/api/#test-todo -[17]: https://github.com/flex-development/pathe/discussions/new?category=q-a -[18]: https://stackoverflow.com/help/minimal-reproducible-example -[19]: https://github.com/features/packages -[20]: https://npmjs.com +[17]: https://codecov.io +[18]: https://docs.codecov.com/docs/codecov-uploader +[19]: https://github.com/flex-development/pathe/discussions/new?category=q-a +[20]: https://stackoverflow.com/help/minimal-reproducible-example +[21]: https://github.com/features/packages +[22]: https://npmjs.com diff --git a/package.json b/package.json index d4cba0d1..bbb9477b 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "clean:modules": "trash ./.yarn/{cache,*.gz} ./node_modules", "clean:pack": "trash ./*.tgz", "clean:test": "yarn clean:coverage && trash ./__tests__/report.json", + "codecov": "yarn test:cov && yarn test:cov:upload", "conventional-changelog": "node --loader=./loader.mjs ./node_modules/.bin/conventional-changelog -n ./changelog.config.cts", "fix:cg": "yarn fix:format && yarn fix:lint", "fix:dedupe": "yarn dedupe --strategy=highest", @@ -69,6 +70,7 @@ "test": "vitest run", "test:cov": "yarn clean:coverage; yarn test --coverage", "test:cov:serve": "serve ./coverage/lcov-report", + "test:cov:upload": "./codecov -t $CODECOV_TOKEN -f ./coverage/lcov.info", "test:watch": "vitest", "typecheck": "vitest typecheck --run", "typecheck:watch": "vitest typecheck"