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

Improve code coverage reporting #7961

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

nwmac
Copy link
Member

@nwmac nwmac commented Jan 19, 2023

Fixes #7142

This improves the code coverage reports.

This PR includes the important changes from - #7166 so that can be closed.

I gave up on trying to get the unit and e2e coverage reports to report over the same set of files and instead went for a post-process approach - we post-process the reports and ensure that both reports contain coverage data for the files included in the individual report.

The artifact uploaded to GitHub has been updated - this now contains unit, e2e and combined results and these now make sense - i.e. the combined result is at least as high as the lowest of the two.

Note that codecov still reports a slightly different coverage value that the reports above - but it is at least now approximately correct - e.g. the reports generated via Istanbul might show 27.8% and codecov will report 27.1% - it appears codecov uses a different (or newer version of) a library for processing these - you can see it identified more lines etc than the istanbul reports - but I think the numbers are now close enough that this is ok.

FYI: @cnotv

@github-actions github-actions bot added this to the v2.7.next2 milestone Jan 19, 2023
@nwmac nwmac requested a review from cnotv January 19, 2023 09:41
@cnotv
Copy link
Contributor

cnotv commented Jan 19, 2023

@nwmac Did you make a test to the Codecov report to be sure it's actually working, before we merge this?
Every time I did anything related to coverage I have been always doing tests on my fork to be sure that the values are reported.

@cnotv
Copy link
Contributor

cnotv commented Jan 19, 2023

@nwmac I also cannot see anymore the Codecov delta comment here in the PR, has this been removed from the settings?

@nwmac
Copy link
Member Author

nwmac commented Jan 19, 2023

@cnotv Okay - once PSA stuff is done - you and I can look at the PR stuff - maybe I missed a change for that.

cp -r coverage/* coverage-artifacts/coverage/
ls -al coverage-artifacts

- name: Upload updated coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have 4 uploads now?

@@ -72,7 +72,7 @@ export default defineConfig({
},
env: {
baseUrl,
coverage: false,
coverage: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Once again this is turned to true. Doing so it wastes time while developing E2E tests.
Please try to understand this point.

package.json Outdated
@@ -30,6 +30,7 @@
"docker:local:start": "docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -e CATTLE_BOOTSTRAP_PASSWORD=password -e CATTLE_PASSWORD_MIN_LENGTH=3 --name cypress --privileged rancher/rancher:v2.7-head",
"docker:local:stop": "docker kill cypress || docker rm cypress || true",
"build": "./node_modules/.bin/nuxt build --devtools",
"build:ci": "node --max-old-space-size=8192 ./node_modules/.bin/nuxt build",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is --max-old-space-size=8192 required?

Copy link
Contributor

Choose a reason for hiding this comment

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

We do not use nuxt anymore as well, so it should be something like

    "build: ci": "NODE_OPTIONS=--max_old_space_size=8192 ./node_modules/.bin/vue-cli-service build",

Although we had the same issue in build, so maybe we just stick to the current value

@@ -72,7 +72,7 @@ export default defineConfig({
},
env: {
baseUrl,
coverage: false,
coverage: process.env.TEST_COVERAGE === 'true',
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not forget to mention it in the documentation, sorry about mentioning it 😬

@@ -2931,6 +2931,16 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==

"@types/strip-bom@^3.0.0":
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to generate a new yarn.lock as some changes seems should not be there? 🤔

@@ -1 +1,10 @@
module.exports = require('./shell/babel.config.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

Careful with this change, since in the shell we have some configuration changed, including the one where we allow the use of require, otherwise it creates error:

TypeError: require.context is not a function

@nwmac nwmac modified the milestones: v2.8.0, v2.8.next1 Sep 27, 2023
@nwmac nwmac modified the milestones: v2.9.0, v2.10.0 May 7, 2024
@nwmac
Copy link
Member Author

nwmac commented May 7, 2024

I've been looking into the mismatch between the coverage reports generated by jest and cypress - looks like the cypress files ignore import and export statements - did a search and found this - istanbuljs/babel-plugin-istanbul#135

@nwmac nwmac modified the milestones: v2.10.0, v2.11.0 Sep 30, 2024
@nwmac nwmac modified the milestones: v2.12.0, v2.11.0 Nov 1, 2024
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.

Coverage computation does not match the pull request
3 participants