Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(workflows): Add code coverage reporting for v2 #6884

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AnuthaDev
Copy link
Contributor

@AnuthaDev AnuthaDev commented Dec 19, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Added a CI pipeline that will run cypress tests and generate code coverage reports for v2

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Closes #1593
Closes #1587
Closes #1622
Closes #1700

How did you test it?

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

Copy link

semanticdiff-com bot commented Dec 19, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  cypress-tests-v2/package-lock.json  30% smaller
  .github/workflows/cypress-tests-runner.yml Unsupported file format
  README.md Unsupported file format
  docs/CONTRIBUTING.md Unsupported file format
  justfile Unsupported file format
  scripts/execute_cypress.sh Unsupported file format

.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 19, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@AnuthaDev AnuthaDev force-pushed the code-vyapti branch 5 times, most recently from d2a1842 to 4873fa2 Compare December 26, 2024 16:09
@AnuthaDev AnuthaDev marked this pull request as ready for review December 26, 2024 16:09
@AnuthaDev AnuthaDev requested review from a team as code owners December 26, 2024 16:09
@AnuthaDev AnuthaDev self-assigned this Dec 26, 2024
@AnuthaDev AnuthaDev added A-CI-CD Area: Continuous Integration/Deployment api-v2 labels Dec 26, 2024
@AnuthaDev AnuthaDev added this to the December 2024 Release milestone Dec 26, 2024
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
scripts/execute_cypress_v2.sh Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
docs/CONTRIBUTING.md Outdated Show resolved Hide resolved
justfile Outdated Show resolved Hide resolved
scripts/execute_cypress_v2.sh Outdated Show resolved Hide resolved
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that, looks good to me!

.github/workflows/cypress-tests-runner.yml Outdated Show resolved Hide resolved
# - 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /Users paths are MacOS specific though, are they also needed on Linux (which is what CI runs on)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, we can use $HOME instead? I missed these during my review...

# - 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would using *cargo* exclude paths like crates/router_env/src/cargo_workspace.rs in our repository as well? Ideally we'd want to include such paths in the coverage report.

This makes me wonder, should we consider passing something like --keep-only crates/* instead of --ignore, or are there anything outside of crates that we need included in the coverage report?

Comment on lines +457 to +464
- 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 "/*"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: ${{ env.RUN_TESTS == 'true' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need coverage reports to be processed / uploaded for merge queue runs as well? If not, we'd have to tweak the if condition for both of these steps to not run on merge queue (but include the other conditions specified in RUN_TESTS).

LLVM_PROFILE_FILE="coverage.profraw" target/debug/router
```

3. Open a separate terminal tab and run the cypress tests, following the [README]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
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]

And update the link to be:

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

@pixincreate Should we consider linking to the v1 README file instead?
Should we also remove all content from cypress-tests-v2/README.md, and update it to suggest referring to the cypress-tests/README.md file, to ease maintenance?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thing is that, in v2, entire format / architecture is different from v1. and removing readme from might create some chaos imo.

i'm also planning to slowly start moving to ts in the coming days.

i prefer to keep it, at least for now.

Comment on lines +288 to +290
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`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this note have been included before the VS Code specific information?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please update the TOC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CI-CD Area: Continuous Integration/Deployment api-v2
Projects
None yet
4 participants