diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml index e7aa9f1d3773..30432945e3b1 100644 --- a/.github/workflows/cypress-tests-runner.yml +++ b/.github/workflows/cypress-tests-runner.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index dcbeddf7adab..d53145b33ee9 100644 --- a/.gitignore +++ b/.gitignore @@ -241,6 +241,7 @@ $RECYCLE.BIN/ # hyperswitch Project specific excludes # code coverage report *.profraw +lcov.info html/ coverage.json # other diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 9efb6529bf19..d9314ceb9196 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -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) @@ -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 ``` @@ -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` @@ -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