From 4566cc08cf2b9d2b41cfeb7be668010d7ce89652 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sat, 21 Dec 2024 11:44:59 -0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=92=9A=20Enable=20babel=20transpiling?= =?UTF-8?q?=20of=20react-native=20as=20well?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the code coverage github action. Without this change, we were getting the error ``` i FAIL www/__tests__/DateSelect.test.tsx ● Test suite failed to run SyntaxError: /private/tmp/e-mission-phone/node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js: Unexpected token, expected "]" (39:5) ``` The last successful run was from Oct 17. The first failed run was from Oct 23. We have not made any changes to the react-native components that we directly import since Sept 2024. However, we use a carat semver, so we will pull newly released minor versions. One of our dependencies bumped up the version of RN that they use, and released a new minor version, which broke this. After fruitlessly searching around for a root cause (as documented in the PR comments), since we import a lot of components and it was laborious to check when each of them have been updated, I did a brute force search in GitHub for this error and found both the same issue https://github.com/facebook/react-native/issues/48228 and a fix that worked https://github.com/facebook/react-native/issues/48228#issuecomment-2547160218 I am surprised this has not been reported widely, but I guess it is fairly new! Thanks to @Basil-Code for the suggestion! --- babel.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babel.config.js b/babel.config.js index b3c97fe4c..9e4bc46af 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,4 @@ module.exports = { - presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'], + presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react', 'module:@react-native/babel-preset'], plugins: ['@babel/plugin-transform-flow-strip-types'], } From 126ceb994761f3c7c47e2b97c7c82aa02594b587 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sat, 21 Dec 2024 12:06:09 -0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=91=B7=20Run=20the=20tests=20using=20?= =?UTF-8?q?npm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running the test using `npx jest` instead of `npm run test` means that passing in command line arguments to jest needs to either be coded in two places, or that jest would be potentially invoked inconsistently. This changes the invocation to use `npm` so that the command line args (if any) can be passed in to a single location. https://github.com/e-mission/e-mission-phone/pull/1193#issuecomment-2558224236 --- .github/workflows/code-coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index dc1af47ac..a97fb3925 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -24,7 +24,7 @@ jobs: shell: bash -l {0} run: | source setup/activate_serve.sh - npx jest + npm run test - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 @@ -33,4 +33,4 @@ jobs: files: ./coverage/coverage-final.json flags: unit fail_ci_if_error: ${{ github.repository == 'e-mission/e-mission-phone' }} - \ No newline at end of file + From bee8bed43e6c766ecd856c6e10e17ad7718fc4d4 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sat, 21 Dec 2024 12:45:24 -0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=B7=20Upload=20exact=20versions=20?= =?UTF-8?q?of=20the=20packages=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use `^` versions for our dependencies, which means that any compatible minor version could be pulled. However, we recently ran into an issue (https://github.com/e-mission/e-mission-phone/pull/1193#issuecomment-2558223871) in which a change to a minor version broke our tests. Sifting through all our dependencies to find the ones that were bumped, and which dependencies they bumped in turn is time consuming. For example in the issue above, the dependency that caused the break was `react-native`, which we don't include directly in our project. One option to identify changes would be to check the `package-lock.json`, but unless we are constantly reinstalling npm, we won't necessarily know what changed around the time that the tests broke. Uploading the `package-lock.json` from runs allows us to see the versions from before and after the break and narrow down the potential changes. --- .github/workflows/code-coverage.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index a97fb3925..a6100b0bf 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -26,6 +26,14 @@ jobs: source setup/activate_serve.sh npm run test + - name: Upload exact version(s) of packages used + uses: actions/upload-artifact@v4 + with: + name: versions-results + path: | + package-lock.json + ./coverage/coverage-final.json + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: From e9abaeef8e905ef9c3b6f5912a94b9a523a95624 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sat, 21 Dec 2024 13:14:43 -0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=94=A5=20Stop=20failing=20the=20test?= =?UTF-8?q?=20if=20code=20coverage=20goes=20down?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We currently run tests and check code coverage in the same workflow, and fail if the code coverage goes down. But our current coverage is fairly limited (< 20%) so we have a lot of failures from changes to code that currently does not have any tests. Let's still check the code coverage for the patch, but disable it for the project, so it doesn't mask errors in the tests. We should not have to enable this since https://docs.codecov.com/docs/common-recipe-list#set-project-coverage-checks-on-a-pull-request > By default, Codecov will only show git diff coverage checks on a PR. > "Project coverage" checks and "project coverage" reporting is not available for Private Repos on the Codecov team plan. > For all other private repos, and for all public repos, here's how you can also show project coverage checks on a PR. But it is clearly failing and is the only test failing, so let's make the change anyway. Once we improve coverage to cover more areas, we can re-enable this. --- codecov.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 125b560ef..48490ad0b 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,7 @@ +coverage: + status: + project: + default: false # disable the default status that measures entire project comment: layout: " diff, flags, files" behavior: default @@ -5,4 +9,4 @@ comment: require_base: false require_head: true hide_project_coverage: false - \ No newline at end of file +