react-native-dotenv icon indicating copy to clipboard operation
react-native-dotenv copied to clipboard

Add option to ignore process.env when on CI

Open lmcjt37 opened this issue 3 years ago • 3 comments

My team found during an upgrade to react native, along with many other packages, that a change occurred that caused our .env.test to be ignored in favour of the environment variables injected via the CI. This appeared to only be the case when running yarn test --coverage.

Interestingly, when changing the coverageProvider to "v8", the environment variables were correct. But that didn't solve all our issues and raised other significantly complex issues.

Part of the solution took inspiration from this PR: https://github.com/ember-cli/babel-plugin-ember-modules-api-polyfill/pull/156/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556

Link to issue

fixes #410 This is a solution we felt that the community might benefit from.

Description of changes being made

  • An extra option of ci has been added, which will allow the process.env variables to be ignored. The reason we got into this scenario was due to the environment variables in Circle CI being included in the initial temporary object and then subsequent values appeared to be ignored.
  • The update to ImportDeclaration() was a fix (link up above) for "container is falsey" that was found when running yarn jest --coverage.
  • Both changes were required to solve the overall issue.

lmcjt37 avatar Jan 11 '23 20:01 lmcjt37

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.64%. Comparing base (4d5d11a) to head (2f62b99). Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
index.js 60.00% 2 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #403      +/-   ##
===========================================
- Coverage   100.00%   97.64%   -2.36%     
===========================================
  Files            1        1              
  Lines           82       85       +3     
===========================================
+ Hits            82       83       +1     
- Misses           0        2       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jan 12 '23 11:01 codecov[bot]

Hi @lmcjt37 sorry for not seeing this sooner. Thank you for opening this! Excellent code quality. I'd normally be happy to dive in and help fix any issue so this passes.

However, I I'm a bit concerned because I don't quite understand what the need is for this. I've opened ticket #410 to discuss. Also I need to modify the Sonatype settings to not be so worried about the test folder.

goatandsheep avatar Feb 08 '23 05:02 goatandsheep

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 11 '23 12:04 stale[bot]