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

Add 'collectCoverageForm' configuration to track all files for Jest coverage #1143

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

jiji14
Copy link
Contributor

@jiji14 jiji14 commented Apr 8, 2024

Related Issue

e-mission/e-mission-docs#1064

Overview

We have been ignoring files not included in the test folder when calculating coverage. To improve this, I added the collectCoverageFrom configuration.

For more information, please refer to this document: https://jestjs.io/docs/configuration#collectcoveragefrom-array

Code coverage report after adding collectCoverageFrom

Screenshot 2024-04-08 at 1 05 31 PM

@jiji14 jiji14 changed the title Add 'collectCoverageForm' confi to track all files for Jest coverage Add 'collectCoverageForm' configuration to track all files for Jest coverage Apr 8, 2024
@shankari
Copy link
Contributor

shankari commented Apr 19, 2024

@jiji14 it looks like the code coverage action is failing consistently; can you please take a look? It looks to me like the upload is failing - I am not sure

[2024-04-17T05:47:30.371Z] ['info'] Detected GitHub Actions as the CI provider.
[2024-04-17T05:47:30.786Z] ['info'] Pinging Codecov: https://codecov.io/upload/v4?package=github-action-3.1.6-uploader-0.7.3&token=*******&branch=refactoring_timelinecontext&build=8716915136&build_url=https%3A%2F%2Fgithub.com%2Fe-mission%2Fe-mission-phone%2Factions%2Fruns%2F8716915136%2Fjob%2F23911189335&commit=91af26c8627b51da61f9061be8c0a23194f1a9ca&job=code+coverage&pr=1138&service=github-actions&slug=e-mission%2Fe-mission-phone&name=&tag=&flags=unit&parent=
[2024-04-17T05:47:31.007Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}

Here's a related SO post
https://stackoverflow.com/a/69578040

If the only solution is to use secrets, it won't work in a PR any more (recall that secrets are not available to PRs). We have to use pull_request_target or only run this on push

@jiji14
Copy link
Contributor Author

jiji14 commented Apr 19, 2024

@jiji14 it looks like the code coverage action is failing consistently; can you please take a look? It looks to me like the upload is failing - I am not sure

[2024-04-17T05:47:30.371Z] ['info'] Detected GitHub Actions as the CI provider.
[2024-04-17T05:47:30.786Z] ['info'] Pinging Codecov: https://codecov.io/upload/v4?package=github-action-3.1.6-uploader-0.7.3&token=*******&branch=refactoring_timelinecontext&build=8716915136&build_url=https%3A%2F%2Fgithub.com%2Fe-mission%2Fe-mission-phone%2Factions%2Fruns%2F8716915136%2Fjob%2F23911189335&commit=91af26c8627b51da61f9061be8c0a23194f1a9ca&job=code+coverage&pr=1138&service=github-actions&slug=e-mission%2Fe-mission-phone&name=&tag=&flags=unit&parent=
[2024-04-17T05:47:31.007Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 404 - {'detail': ErrorDetail(string='Unable to locate build via Github Actions API. Please upload with the Codecov repository upload token to resolve issue.', code='not_found')}

Here's a related SO post https://stackoverflow.com/a/69578040

If the only solution is to use secrets, it won't work in a PR any more (recall that secrets are not available to PRs). We have to use pull_request_target or only run this on push

Certainly! Here's the corrected version:

@shankari I've researched how to fix this issue before, but I wasn't able to find one except for adding a token (which doesn't work for our project). Should I try Force-push to retrigger Codecov?

@jiji14
Copy link
Contributor Author

jiji14 commented Apr 20, 2024

@shankari There are multiple issues regarding this, and I don't think we can fix it on our own. What should I do for the next step? 1. Waiting for the Codecov team 2. Using Jest code coverage report temporarily

[ Related Issues ]
codecov/codecov-action#1379
codecov/codecov-action#1373
codecov/codecov-action#1368

@shankari
Copy link
Contributor

@jiji14 I don't think that all the issues that you have linked to are related. At least two relate to uploads with tokens. Since we are attempting to use tokenless updates, they are not related. Please filter down to only the ones that relate to tokenless updates and/or PRs from forks.

In #1143 (comment), I indicated that

If the only solution is to use secrets, it won't work in a PR any more (recall that secrets are not available to PRs). We have to use pull_request_target or only run this on push

I am not sure what "Using Jest code coverage report temporarily", can you clarify?

Copy link

codecov bot commented Apr 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 27.32%. Comparing base (76839de) to head (f0c85f2).
Report is 27 commits behind head on master.

❗ Current head f0c85f2 differs from pull request most recent head 22cbf2f. Consider uploading reports for the commit 22cbf2f to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1143       +/-   ##
===========================================
- Coverage   77.49%   27.32%   -50.17%     
===========================================
  Files          29      113       +84     
  Lines        1693     4816     +3123     
  Branches      370     1037      +667     
===========================================
+ Hits         1312     1316        +4     
- Misses        381     3498     +3117     
- Partials        0        2        +2     
Flag Coverage Δ
unit 27.32% <ø> (-50.17%) ⬇️

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

see 92 files with indirect coverage changes

@jiji14
Copy link
Contributor Author

jiji14 commented Apr 22, 2024

@shankari

Sorry, I was completely on the wrong page. The issue arose after a recent update from the Codecov team. The error was caused by the v3 action using the v4 API. The simple solution was to update from v3 to v4. Here is the related issue: link to the issue.

With Codecov v4, tokenless uploading is unsupported. However, pull requests made from forks to the upstream public repositories will support tokenless uploading (e.g., contributors to open-source projects do not need the upstream repository's Codecov token). Therefore, even without a token, we can still upload the report. I referred to this link: https://github.com/codecov/codecov-action

I checked that the Codecov report was successfully uploaded after updating the version. However, the codecov/project failed due to a decrease in coverage percentage. Apologies for the incorrect comments!

@shankari
Copy link
Contributor

Great job, @jiji14!
I understand that the code coverage went down significantly, but I also don't want to live in a fool's paradise

@shankari shankari merged commit 1589f74 into e-mission:master Apr 26, 2024
7 of 8 checks passed
@shankari
Copy link
Contributor

@jiji14 @JGreenlee after merging this, the CI broke

The error is

npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.2.*" from the root project
npm ERR!   peer react@">=16.8.0" from @testing-library/[email protected]
npm ERR!   node_modules/@testing-library/react-native
npm ERR!     dev @testing-library/react-native@"^12.3.0" from the root project
npm ERR!   1 more (react-native)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.3.0" from [email protected]
npm ERR! node_modules/react-test-renderer
npm ERR!   peer react-test-renderer@">=16.8.0" from @testing-library/[email protected]
npm ERR!   node_modules/@testing-library/react-native
npm ERR!     dev @tes

I don't think this is related to the change, it may just be a missing/obsolete dependency. In other words, there might be a change to the packages published on npm that causes this to break. Can you take a look?

@jiji14
Copy link
Contributor Author

jiji14 commented Apr 26, 2024

@shankari sure I will!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants