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

Enable coverage reporting for emulator #969

Merged

Conversation

m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Apr 11, 2023

Work towards onflow/developer-grants#132

Description

Allows developers to start the emulator with coverage reporting, which can be viewed in the browser, on this URL:

The respective flag (--coverage-reporting) can be used like this:

flow emulator --storage-limit=false --coverage-reporting -v

It also adds an HTTP endpoint for flushing/resetting all the collected coverage report, on this URL:

This endpoint accepts only a PUT verb, at the moment. For example:

curl -XPUT 'http://localhost:8080/emulator/codeCoverage/reset'

Special thanks to @bluesign, for his great ideas 🙌
Special thanks to @turbolent, for his great reviews, which have unblocked this 💯


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2023

Codecov Report

Merging #969 (451fec6) into master (3fc9e7e) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@            Coverage Diff            @@
##           master    #969      +/-   ##
=========================================
- Coverage    2.53%   2.52%   -0.01%     
=========================================
  Files           5       5              
  Lines         434     435       +1     
=========================================
  Hits           11      11              
- Misses        422     423       +1     
  Partials        1       1              
Flag Coverage Δ
unittests 2.52% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/super/project.go 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@devbugging
Copy link
Contributor

@m-Peter should we merge?

@m-Peter
Copy link
Collaborator Author

m-Peter commented Apr 12, 2023

@sideninja Yes, of course! We are just awaiting this to be included in a release, before publicly announcing the new features to the dev community 🙏

@devbugging
Copy link
Contributor

@m-Peter could we add docs on this to the CLI, how you run it and maybe an example?

@m-Peter
Copy link
Collaborator Author

m-Peter commented Apr 12, 2023

@sideninja I have created an entire repository with detailed usage of these new features: https://github.com/Build-Squad/flow-code-coverage/blob/385067c991608e7a37eba742bd857fab136ebeb0/README.md. I am just waiting for a new release of flow-cli to share it with the rest of the community. We can add afterwards more docs on every relevant repository. What is your opinion on this?

@devbugging
Copy link
Contributor

@m-Peter sure that makes sense. The thing required tho is to document the flags as part of the CLI docs.

@m-Peter
Copy link
Collaborator Author

m-Peter commented Apr 13, 2023

@sideninja Are you referring to this section? Because I don't see the test command there. I also found this document

@devbugging
Copy link
Contributor

@m-Peter sorry for not making it clearer, what I meant was adding the docs for flags here https://github.com/onflow/flow-cli/blob/master/docs/run-tests.md
You can check other files in docs to see the format of documenting flags.

@m-Peter
Copy link
Collaborator Author

m-Peter commented Apr 13, 2023

@sideninja Ah, thanks. I am already updating that document. I will ping you soon 🙏

@m-Peter
Copy link
Collaborator Author

m-Peter commented Apr 13, 2023

@sideninja I have added two more commits regarding documentation:

I will also open a PR on the flow-emulator repository, to address the new --coverage-reporting flag that was recently added.

@devbugging
Copy link
Contributor

@m-Peter looks good. Let me merge and I can make a release EOT.

@devbugging devbugging merged commit cfd3dc4 into onflow:master Apr 13, 2023
@m-Peter
Copy link
Collaborator Author

m-Peter commented Apr 13, 2023

@sideninja That would be great 💯
Here's the companion documentation PR, for flow-emulator onflow/flow-emulator#354

@m-Peter m-Peter deleted the enable-coverage-reporting-for-emulator branch April 13, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants