Skip to content

ci: reintroduce code coverage reporting with cargo-llvm-cov#23336

Merged
2010YOUY01 merged 11 commits into
apache:mainfrom
buraksenn:reintroduce-code-coverage-with-llvm-cov
Jul 16, 2026
Merged

ci: reintroduce code coverage reporting with cargo-llvm-cov#23336
2010YOUY01 merged 11 commits into
apache:mainfrom
buraksenn:reintroduce-code-coverage-with-llvm-cov

Conversation

@buraksenn

@buraksenn buraksenn commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Code coverage has been disabled since #3678. The reason was it failed because of sql_integration test binary. This PR reintroduces it

What changes are included in this PR?

Reintroduce code coverage

Are these changes tested?

I've been successfully make it work in my fork: buraksenn#345
image

I needed to add CODECOV_TOKEN as a secret variable to the fork.

You can check #23336 (comment) comment of codecov for successful run

Are there any user-facing changes?

no

@github-actions github-actions Bot added development-process Related to development process of DataFusion core Core DataFusion crate ffi Changes to the ffi crate labels Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning apache/main
    Building datafusion v54.0.0 (current)
       Built [ 105.545s] (current)
     Parsing datafusion v54.0.0 (current)
      Parsed [   0.038s] (current)
    Building datafusion v54.0.0 (baseline)
       Built [ 105.374s] (baseline)
     Parsing datafusion v54.0.0 (baseline)
      Parsed [   0.037s] (baseline)
    Checking datafusion v54.0.0 -> v54.0.0 (no change; assume patch)
     Checked [   1.002s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [ 214.007s] datafusion
    Building datafusion-ffi v54.0.0 (current)
       Built [  58.698s] (current)
     Parsing datafusion-ffi v54.0.0 (current)
      Parsed [   0.065s] (current)
    Building datafusion-ffi v54.0.0 (baseline)
       Built [  58.303s] (baseline)
     Parsing datafusion-ffi v54.0.0 (baseline)
      Parsed [   0.066s] (baseline)
    Checking datafusion-ffi v54.0.0 -> v54.0.0 (no change; assume patch)
     Checked [   0.356s] 223 checks: 222 pass, 1 fail, 0 warn, 30 skip

--- failure feature_missing: package feature removed or renamed ---

Description:
A feature has been removed from this package's Cargo.toml. This will break downstream crates which enable that feature.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#cargo-feature-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/feature_missing.ron

Failed in:
  feature tarpaulin_include in the package's Cargo.toml

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [ 119.158s] datafusion-ffi

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Jul 6, 2026
@codecov-commenter

codecov-commenter commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@2177864). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #23336   +/-   ##
=======================================
  Coverage        ?   80.65%           
=======================================
  Files           ?     1086           
  Lines           ?   366097           
  Branches        ?   366097           
=======================================
  Hits            ?   295265           
  Misses          ?    53237           
  Partials        ?    17595           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@buraksenn

Copy link
Copy Markdown
Contributor Author

As expected it could not compare since there is no code coverage uploaded for main branch. After this PR merges it will be ready

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👀

Comment thread .github/workflows/rust.yml Outdated
coverage:
name: coverage
needs: linux-build-lib
runs-on: ${{ vars.USE_RUNS_ON == 'true' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

will this consume more of our ASF runner time?

maybe we can try it for a while and make sure it is useful before we spend too much xtra time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is correct can you check #23336 (comment)

@alamb

alamb commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Looks like the coverage run takes 19m and the main tests take 20m, so this adds a lot of resource usage, but it won't increase testing latancy

Screenshot 2026-07-10 at 8 23 18 PM Screenshot 2026-07-10 at 8 23 33 PM

@Jefffrey

Copy link
Copy Markdown
Contributor

would it also be an option to have it run occasionally on main only, to at least give us a general idea on the health of the codebase in terms of coverage, without consuming too many resources? 🤔

@buraksenn

Copy link
Copy Markdown
Contributor Author

I've first introduced it as uncommenting the coverage step but cargo-llvm-cov internally runs cargo test and calculates coverage with it so instead of this I've changed cargo test (amd64) to use llvm-cov. With this it actually does not cause any resource usage:

cargo test amd64 with llvm-cov:
image

unchanged cargo test amd64:
image

Another approach would be adding it as nightly/weekly. @alamb @Jefffrey

@2010YOUY01 2010YOUY01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM overall—thank you!

Andrew mentioned the resource-usage concern, so here is some background: our CI runner resources are provided by the ASF, and they have noted that DataFusion consumes a significant amount of compute. We are still within the hard limit, IIRC, but it would be good to continue reducing our usage as they suggested.

(I think the biggest contributor is PRs with dozens of commits, but we could address that separately.)

I would prefer to run this check on every PR. It is true that 100% line coverage does not necessarily imply good test quality; however, low coverage strongly suggests that we are missing test cases. I'd want to check the coverage metrics regularly when reviewing.

const KB: usize = 1 << 10;
#[tokio::test]
#[cfg_attr(tarpaulin, ignore)]
#[cfg_attr(coverage, ignore)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think they're not needed:

#[cfg(feature = "extended_tests")]

Those tests are under extended_tests attribute, and now we run llvm-cov in the regular test suite, so those slow tests won't be included.

In the future if there are other tests that are too expensive to run for llvm-cov, I think we should also put them in extended_tests feature, then we don't have to manage this additional coverage attribute to keep things simpler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up, I did not think if they were necessary and blindly applied. Now they are removed

@2010YOUY01 2010YOUY01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks again!

I plan to merge it tomorrow, if the extra CI resource consumption is not acceptable, we could later let it run less frequently.

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is pretty good if it just substitutes in for cargo test as is 👍

@buraksenn

Copy link
Copy Markdown
Contributor Author

Thanks again!

I plan to merge it tomorrow, if the extra CI resource consumption is not acceptable, we could later let it run less frequently.

With the current state it does not cause extra CI consumption actually. I've replaced cargo test with llvm-cov which adds trivial overhead as far as I can see from the last 2-3 runs from the CI

@2010YOUY01

Copy link
Copy Markdown
Contributor

Probably we could add the generated files to .gitignore, to make local runs easier.

However let's merge first, and do it as a follow up PR.

@2010YOUY01
2010YOUY01 added this pull request to the merge queue Jul 16, 2026
Merged via the queue into apache:main with commit 80bc64f Jul 16, 2026
38 checks passed
@alamb

alamb commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Epic!

@buraksenn
buraksenn deleted the reintroduce-code-coverage-with-llvm-cov branch July 16, 2026 11:09
@Jefffrey

Jefffrey commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

when i open https://app.codecov.io/gh/apache/datafusion it seems to show master as default

image
  • the latest commit shown there seems to be pretty old a9f7cac

i cant seem to find main in the dropdown

image

is this an issue we need to fix? i see a comment on my PR how base (main) doesnt have a coverage report uploaded, is this related?

edit: or maybe its still processing on codecov's end

@Jefffrey

Copy link
Copy Markdown
Contributor

oh im seeing this log on main:

info - 2026-07-16 10:36:05,200 -- Found 1 coverage files to report
info - 2026-07-16 10:36:05,200 -- > /__w/datafusion/datafusion/target/codecov.json
info - 2026-07-16 10:36:05,651 -- Upload queued for processing complete
error - 2026-07-16 10:36:05,651 -- Upload queued for processing failed: {"message":"Token required because branch is protected"}

@alamb

alamb commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I filed a ticket to track the fact the reports aren't showing any meaningful coverage reports yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change core Core DataFusion crate development-process Related to development process of DataFusion ffi Changes to the ffi crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coverage jobs are failing on master: Failed to compile tests! Error: sql_integration: linking with cc failed: exit status: 1"

5 participants