DataDog / datadog-ci-rb

Ruby library for Datadog test visibility
https://docs.datadoghq.com/continuous_integration/tests/ruby
Other
8 stars 4 forks source link

[CIVIS-2892] datadog_cov native extension for per test code coverage #137

Closed anmarchenko closed 7 months ago

anmarchenko commented 7 months ago

What does this PR do? Adds datadog_cov native extension for per test code coverage.

Usage of Datadog::CI::ITR::Coverage::DDCov:

# track files coverage in the current folder
cov = Datadog::CI::ITR::Coverage::DDCov.new(root: Dir.pwd)
cov.start_coverage
Calculator.new.add(1, 2) # => 3
cov.stop_coverage # => { "/path/to/current-folder/calculator.rb" => true }

# track lines coverage
cov = Datadog::CI::ITR::Coverage::DDCov.new(root: Dir.pwd, mode: :lines)
cov.start_coverage
Calculator.new.add(1, 2) # => 3
cov.stop_coverage # => { "/path/to/current-folder/calculator.rb" => {12 => true, 13 => true} }

Additional Notes Current limitations:

How to test the change? Unit tests are provided in spec/datadog/ci/cov_spec.rb

Scenarios tested:

codecov-commenter commented 7 months ago

Codecov Report

Attention: Patch coverage is 99.57447% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 99.22%. Comparing base (6a994b6) to head (e4e86f3).

Files Patch % Lines
lib/datadog/ci/utils/git.rb 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## 1.0 #137 +/- ## ========================================== + Coverage 99.19% 99.22% +0.02% ========================================== Files 163 171 +8 Lines 7240 7468 +228 Branches 302 310 +8 ========================================== + Hits 7182 7410 +228 Misses 58 58 ```

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

anmarchenko commented 7 months ago

This pull request is now rebased on top of 1.0 branch and the base is set to 1.0.

From now on, all ITR functionality will go into 1.0 branch so that we don't add additional risks for ddtrace 1.x gem.

anmarchenko commented 7 months ago

@ivoanjo this is ready for another pass