dd-trace-js
dd-trace-js copied to clipboard
[ci-visibility] [do not review - wip] Per test code coverage for `jest`
What does this PR do?
Read code coverage in jest if it's available (global.__coverage__) and reset the counters after every test. This results in a code coverage that is exclusive to the test. This works because tests (it clauses) are run sequentially within a test file.
After code coverage is formatted, it is exported through exportCoverage, a new function in AgentlessCiVisibilityExporter, which ends up using CIVisibilityCoverageEncoder encoder, which encodes the data in the expected format.
Additionally, a new dependency istanbul-lib-coverage is added for parsing the code coverage:
https://www.npmjs.com/package/istanbul-lib-coverage
https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-lib-coverage
Motivation
Per test code coverage is another requirement for intelligent test runner.
Plugin Checklist
- [x] Unit tests.
- [ ] TypeScript definitions.
- [ ] TypeScript tests.
- [ ] API documentation.
- [ ] CircleCI jobs/workflows.
- [ ] Plugin is exported.
Additional Notes
Overall package size
Self size: 2.6 MB Deduped: 29.78 MB No deduping: 30.41 MB
Dependency sizes
| name | version | self size | total size |
|---|---|---|---|
| @datadog/pprof | 1.0.2 | 8.74 MB | 14.46 MB |
| @datadog/native-metrics | 1.4.2 | 6.61 MB | 7.04 MB |
| @datadog/native-appsec | 1.2.1 | 5.1 MB | 5.43 MB |
| opentracing | 0.14.7 | 194.81 kB | 194.81 kB |
| @datadog/sketches-js | 2.0.0 | 105.44 kB | 105.44 kB |
| lodash.sortby | 4.7.0 | 75.76 kB | 75.76 kB |
| semver | 5.7.1 | 61.58 kB | 61.58 kB |
| ignore | 5.2.0 | 48.87 kB | 48.87 kB |
| import-in-the-middle | 1.3.0 | 30.3 kB | 34.77 kB |
| istanbul-lib-coverage | 3.2.0 | 29.34 kB | 29.34 kB |
| retry | 0.10.1 | 27.44 kB | 27.44 kB |
| lodash.uniq | 4.5.0 | 25.01 kB | 25.01 kB |
| limiter | 1.1.5 | 23.17 kB | 23.17 kB |
| lodash.kebabcase | 4.1.1 | 17.75 kB | 17.75 kB |
| lodash.pick | 4.4.0 | 16.33 kB | 16.33 kB |
| crypto-randomuuid | 1.0.0 | 11.18 kB | 11.18 kB |
| diagnostics_channel | 1.1.0 | 7.07 kB | 7.07 kB |
| path-to-regexp | 0.1.7 | 6.78 kB | 6.78 kB |
| koalas | 1.0.2 | 6.47 kB | 6.47 kB |
| methods | 1.1.2 | 5.29 kB | 5.29 kB |
| module-details-from-path | 1.0.3 | 4.47 kB | 4.47 kB |
🤖 This report was automatically generated by heaviest-objects-in-the-universe
Codecov Report
Merging #2271 (2406421) into master (995da60) will decrease coverage by
0.29%. The diff coverage is89.86%.
@@ Coverage Diff @@
## master #2271 +/- ##
==========================================
- Coverage 92.86% 92.57% -0.30%
==========================================
Files 222 224 +2
Lines 8547 8655 +108
==========================================
+ Hits 7937 8012 +75
- Misses 610 643 +33
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...ges/dd-trace/src/encode/agentless-ci-visibility.js | 64.67% <ø> (-1.81%) |
:arrow_down: |
| ...ace/src/ci-visibility/exporters/agentless/index.js | 80.95% <70.37%> (-19.05%) |
:arrow_down: |
| ...ce/src/ci-visibility/exporters/agentless/writer.js | 91.30% <75.00%> (-8.70%) |
:arrow_down: |
| packages/dd-trace/src/exporters/common/writer.js | 78.94% <75.00%> (ø) |
|
| packages/datadog-instrumentations/src/jest.js | 82.82% <85.71%> (-16.00%) |
:arrow_down: |
| ...-visibility/exporters/agentless/coverage-writer.js | 90.90% <90.90%> (ø) |
|
| packages/datadog-plugin-jest/src/index.js | 83.33% <100.00%> (-9.69%) |
:arrow_down: |
| packages/dd-trace/src/config.js | 98.96% <100.00%> (+0.02%) |
:arrow_up: |
| packages/dd-trace/src/encode/0.4.js | 98.05% <100.00%> (-0.02%) |
:arrow_down: |
| ...ages/dd-trace/src/encode/coverage-ci-visibility.js | 100.00% <100.00%> (ø) |
|
| ... and 5 more |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
any other concern @rochdev ? I think I applied all the feedback