Skip to content

Commit

Permalink
feat(swc-plugin-canyon): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Oct 21, 2024
1 parent d1c0966 commit aae5e27
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
58 changes: 58 additions & 0 deletions plugins/swc-plugin-canyon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# swc-plugin-canyon

A swc plugin that instruments your code with Istanbul coverage. It can instantly be used with karma-coverage and mocha on Node.js (through nyc).

__Note:__ To use this plugin, it is recommended to use a branch to determine whether it is in effect or not, as he is not available for production environments.

## Usage

Install it:

```sh
npm install --save-dev swc-plugin-istanbul
```

Add it to `swc.config.js` in test mode:

```js
module.exports = {
plugins:
process.env.CI_COMMIT_REF_NAME === 'test-coverage'? ['istanbul', 'canyon']:[]
}
```

## Configuration

swc.config.js

```js
module.exports = {
plugins:[
'istanbul',
[
'canyon',
{
dsn: 'http://yourdomain.com/coverage/client',
reporter: 'your_token',
projectID: '230614',
sha: 'xxxxxxxxx',
reportID: 'case_id',
branch: 'master',
compareTarget: 'develop',
}
]
]
}
```

| Prop | Description | Usage |
|-----------|-------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| dsn | Service address for reporting coverage, recommended to be configured via pipeline variables. | Required |
| reporter | Reporter for reporting coverage, recommended to be configured via pipeline variables. | Required |
| projectID | Git repository ID, the plugin will detect the variables of the pipeline, which usually don't need to be configured. | Required |
| sha | Git repository SHA, the plugin will detect the variables of the pipeline, which usually don't need to be configured. | Required |
| instrumentCwd | Instrument Cwd, which usually don't need to be configured. | Required |
| reportID | Report ID, Used to distinguish between different test cases. | Optional |
| branch | Git repository branch, the plugin will detect the variables of the pipeline, which usually don't need to be configured. | Optional |
| compareTarget | Compare target, used as a baseline against current sha to calculate change line coverage. | Optional |

4 changes: 2 additions & 2 deletions plugins/swc-plugin-canyon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swc-plugin-canyon",
"version": "0.0.2-alpha.12",
"description": "Canyon SWC plugin, for debugging",
"version": "0.0.2-alpha.15",
"description": "A SWC plugin cooperates with istanbul to report the coverage",
"main": "swc_plugin_canyon.wasm",
"scripts": {
"prepack": "cargo build --release -p swc_plugin_canyon --target wasm32-wasi && cp ../../target/wasm32-wasi/release/swc_plugin_canyon.wasm ."
Expand Down

0 comments on commit aae5e27

Please sign in to comment.