Skip to content

CI: Run tests via cargo-tarpaulin #2951

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

Merged
merged 4 commits into from
Feb 12, 2021
Merged

CI: Run tests via cargo-tarpaulin #2951

merged 4 commits into from
Feb 12, 2021

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Oct 23, 2020

This PR adds https://github.com/actions-rs/tarpaulin to our CI pipeline to display a test coverage report.

Resolves #1162

@rust-highfive
Copy link

r? @carols10cents

(rust_highfive has picked a reviewer for you, use r? to override)

@jtgeibel
Copy link
Member

cc @pietroalbini as I think you had some concerns about running 3rd party actions on CI.

@pietroalbini
Copy link
Member

In general I'd prefer if we avoid using third-party actions, as those could be yet another avenue to inject malicious code into the build.

@Turbo87
Copy link
Member Author

Turbo87 commented Nov 2, 2020

can we make them first-party actions?

@JohnTitor
Copy link
Member

If the issue is to use "the third party actions", we could use cargo-tarpaulin directly.

@Turbo87 Turbo87 force-pushed the tarpaulin branch 5 times, most recently from c642977 to 22319f3 Compare November 24, 2020 14:32
@pietroalbini
Copy link
Member

Without using the external action this looks good on my side!

@Turbo87
Copy link
Member Author

Turbo87 commented Nov 24, 2020

unfortunately this still has two issues:

  1. it doesn't actually work (yet?): 0.00% coverage, 0/2661 lines covered

  2. it currently takes 12 minutes to install tarpaulin on CI and then run the tests in it, which seems like quite a lot 😞

@JohnTitor
Copy link
Member

it doesn't actually work (yet?): 0.00% coverage, 0/2661 lines covered

Hmm, I'm not sure at all.

it currently takes 12 minutes to install tarpaulin on CI and then run the tests in it, which seems like quite a lot

So, in general, releases don't happen that often and it'd solve the issue to save the binary in the cache.

@Turbo87 Turbo87 marked this pull request as draft December 3, 2020 14:32
@Turbo87 Turbo87 changed the title WIP: CI: Run tests via cargo-tarpaulin CI: Run tests via cargo-tarpaulin Dec 7, 2020
@Turbo87
Copy link
Member Author

Turbo87 commented Jan 30, 2021

@xd009642 any clue what might be the problem here? 🙏

@xd009642
Copy link

oh sorry I realise I've neglected the issue my end. I remember when I tried it last I was struggling to get the backend tests working on fedora but I've got an ubuntu laptop here so I'll try again. I'll tag you on xd009642/tarpaulin#601 if I have any questions just to avoid filling up the PR comments 👍

@xd009642
Copy link

Couple of comments on the PR from working on sorting the coverage issue in github actions:

  1. Either add --force to the cargo install or check for the existence of tarpaulin first otherwise the install fails
  2. You probably only want to run coverage for one specific toolchain, otherwise you'll have multiple reports per commit and I'm not sure if any services like coveralls or codecov support that

@Turbo87
Copy link
Member Author

Turbo87 commented Jan 30, 2021

looks like this is ready to go now! thanks again @xd009642 :)

r? @pietroalbini

@Turbo87 Turbo87 marked this pull request as ready for review January 30, 2021 20:54
- name: Test
- name: Install cargo-tarpaulin
if: matrix.rust == 'stable'
run: which cargo-tarpaulin || cargo install cargo-tarpaulin
Copy link
Member

Choose a reason for hiding this comment

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

This workaround is still needed on CI? I think recent cargo doesn't require it anymore.

Choose a reason for hiding this comment

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

It failed for me running the CI twice consecutively yesterday on my test project to debug the 0% coverage https://github.com/xd009642/crates-io-test/actions

Copy link
Member

Choose a reason for hiding this comment

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

Hm, that's interesting, I guess cargo recognizes it as an untracked file since it's introduced by cache (or another reason) 🤔. Thanks for clarifying, then I'm fine as-is.

Copy link
Contributor

@simonsan simonsan Feb 1, 2021

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAICT

- name: Cache cargo binaries
uses: actions/cache@v2
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('.diesel_version') }}
should already cache the binaries including diesel-cli and cargo-tarpaulin

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, sorry then. Must have overlooked that part :/

Having this flag is preventing tarpaulin from providing us with test coverage reports and I can't find any documented reason for why we would need this.
@Turbo87 Turbo87 added the C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear label Feb 11, 2021
@jtgeibel
Copy link
Member

Alright, lets try this out on master and we'll see how well caching works on new PRs.

@bors r+

@bors
Copy link
Contributor

bors commented Feb 12, 2021

📌 Commit 23bae68 has been approved by jtgeibel

@bors
Copy link
Contributor

bors commented Feb 12, 2021

⌛ Testing commit 23bae68 with merge e719e04...

@bors
Copy link
Contributor

bors commented Feb 12, 2021

☀️ Test successful - checks-actions
Approved by: jtgeibel
Pushing e719e04 to master...

@bors bors merged commit e719e04 into rust-lang:master Feb 12, 2021
@Turbo87 Turbo87 deleted the tarpaulin branch February 12, 2021 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tarpulin for code coverage
9 participants