Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuthaDev committed Jan 2, 2025
1 parent 961ce98 commit 95c95ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/cypress-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,18 +450,14 @@ jobs:
# - The `router` process must be killed (using SIGINT/SIGTERM) to generate the `coverage.profraw` file, otherwise the coverage will only be generated for the buildscripts
# - Trying to generate branch coverage using "-Z coverage-options=branch" currently fails. Both grcov and cargo-llvm-cov crash when trying
# to process the generated `.profraw` files.
# - Explanation of ignore flags:
# - "*cargo*" : Exclude external crates from the generated `lcov.info` file
# - "target/*" : Exclude compile time generated .rs files, e.g. isodata.rs, chrono-tz/timezones.rs
# - "/*" : Exclude /Users/../rustlib/src/rust/library/core/src/panic.rs, /Users/../rustlib/src/rust/library/std/src/sys/thread_local/native/mod.rs etc.
# - --keep-only argument is used to exclude external crates in generated lcov.info file (~500MiB -> ~70MiB)
- name: Process coverage report
if: ${{ env.RUN_TESTS == 'true' }}
run: |
grcov . --source-dir . --output-types lcov --output-path ${{ env.CODECOV_FILE }} --binary-path ./target/debug --ignore "*cargo*" --ignore "target/*" --ignore "/*"
if: ${{ env.RUN_TESTS == 'true' && github.event_name != 'merge_group' }}
run: grcov . --source-dir . --output-types lcov --output-path ${{ env.CODECOV_FILE }} --binary-path ./target/debug --keep-only "crates/*"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: ${{ env.RUN_TESTS == 'true' }}
if: ${{ env.RUN_TESTS == 'true' && github.event_name != 'merge_group'}}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.CODECOV_FILE }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ $RECYCLE.BIN/
# hyperswitch Project specific excludes
# code coverage report
*.profraw
lcov.info
html/
coverage.json
# other
Expand Down
17 changes: 9 additions & 8 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Please join us!
- [Resolving a Bug Report](#resolving-a-bug-report)
- [Pull Requests](#pull-requests)
- [Cargo Commands](#cargo-commands)
- [Code Coverage](#code-coverage)
- [Commits](#commits)
- [Opening the Pull Request](#opening-the-pull-request)
- [Discuss and update](#discuss-and-update)
Expand Down Expand Up @@ -232,7 +233,7 @@ To generate code coverage using the cypress tests, follow these steps:
0. Make sure `grcov` and `llvm-tools-preview` are installed

```shell
rustup install llvm-tools-preview
rustup component add llvm-tools-preview
cargo install grcov
```

Expand All @@ -250,7 +251,7 @@ To generate code coverage using the cypress tests, follow these steps:
LLVM_PROFILE_FILE="coverage.profraw" target/debug/router
```

3. Open a separate terminal tab and run the cypress tests, following the [README]
3. Open a separate terminal tab and run the cypress tests, following the [README][cypress-v2-readme]

4. After the tests have finished running, stop the `router` process using `Ctrl+C`

Expand All @@ -274,22 +275,22 @@ To generate code coverage using the cypress tests, follow these steps:
rm **/*.profraw
```

Note:
- It is necessary to stop the `router` process to generate the coverage file
- Branch coverage generation requires nightly and currently `grcov` crashes while trying to include branch coverage. (Checked using `--log-level` parameter in `grcov`)

#### Integration with VSCode
You can also visualize code coverage in VSCode using the [coverage-gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) extension.

You need to generate an `lcov.info` file in the directory root. After following till step 4 above:

```shell
grcov . -s . -t lcov --output-path lcov.info --binary-path ./target/debug --ignore "*cargo*" --ignore "target/*" --ignore "/*"
grcov . -s . -t lcov --output-path lcov.info --binary-path ./target/debug --keep-only "crates/*"
```

This will generate an `lcov.info` file that can be read by the extension.

Note:
- It is necessary to stop the `router` process to generate the coverage file
- Branch coverage generation requires nightly and currently `grcov` crashes while trying to include branch coverage. (Checked using `--log-level` parameter in `grcov`)

[README]: /cypress-tests-v2/README.md
[cypress-v2-readme]: /cypress-tests-v2/README.md

### Commits

Expand Down

0 comments on commit 95c95ed

Please sign in to comment.