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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
DATABASE_URL: postgres://postgres:postgres@localhost/cargo_registry_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost/cargo_registry_test
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
RUSTFLAGS: "-D warnings"
MALLOC_CONF: "background_thread:true,abort_conf:true,abort:true,junk:true"

services:
Expand Down Expand Up @@ -197,7 +197,16 @@ jobs:
cargo fmt -- --check
cargo clippy --all-targets --all-features --all
- 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.

Wouldn't it be reasonable to cache tarpaulin? There is no need to rebuild it every CI run I feel?

https://github.com/marketplace/actions/cache#skipping-steps-based-on-cache-hit
https://github.com/actions/cache/blob/main/examples.md#rust---cargo

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 :/


- name: Run tests (with coverage report)
if: matrix.rust == 'stable'
run: cargo tarpaulin

- name: Run tests
if: matrix.rust != 'stable'
run: cargo test

- name: Prune unnecessary cache
Expand Down