-
Notifications
You must be signed in to change notification settings - Fork 148
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
readme: example uses -Zprofile
which has been removed from Rust nightly
#1240
Comments
Thanks, we should update the README to remove the mention to "-Zprofile". |
Could anyone tell me what the solution is? It seems it does not work if I remove the Original:
I've tried without the
|
@josecelano the solution is using source-based coverage, as described at https://github.com/mozilla/grcov?tab=readme-ov-file#example-how-to-generate-source-based-coverage-for-a-rust-project. |
Thank you @marco-c; I'm trying to upload the generated report to codecov.io. I'm trying to figure out how to update my GitHub workflows. I'm just posting this here in case other people have the same problem. I haven't found the solution yet. I was using the https://github.com/marketplace/actions/grcov-for-rust action to generate the coverage report and upload it to codecov with a workflow similar to this: name: Coverage
on:
push:
branches:
- develop
env:
CARGO_TERM_COLOR: always
jobs:
report:
name: Report
environment: coverage
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
steps:
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: llvm-tools-preview
- id: tools
name: Install Tools
uses: taiki-e/install-action@v2
with:
tool: grcov
- id: coverage
name: Generate Coverage Report
uses: alekitto/grcov@v0.2
- id: upload
name: Upload Coverage Report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.coverage.outputs.report }}
verbose: true
fail_ci_if_error: true The "alekitto/grcov" hasn't been updated for a while and I don't know what type of artefacts generating. Snice the action seems to be unmantained I'm trying to generate the report info manually with a workflow like this: name: Coverage V2
on:
push:
branches:
- develop
env:
CARGO_TERM_COLOR: always
jobs:
report:
name: Report
environment: coverage
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: llvm-tools-preview
- id: cache
name: Enable Workflow Cache
uses: Swatinem/rust-cache@v2
- id: tools
name: Install Tools
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- id: coverage
name: Generate Coverage Report
run: |
mkdir .coverage
cargo llvm-cov --lcov --output-path=./.coverage/lcov.info
- id: upload
name: Upload Coverage Report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./.coverage/lcov.info
verbose: true
fail_ci_if_error: true But I don't know why I needed |
We used to rely on `-Zprofile`, but it was recently removed from Rust Nightly: rust-lang/rust#131829 This commit switches to a stable alternative; cf. mozilla/grcov#1240 This change is accompanied by a change in the build environment: instead of using Clang 18 with Rust Nightly, we now use Clang 18 with Rust 1.81. That's the last Rust version based on LLVM 18. Previously we tried to match LLVM versions between C++ and Rust to avoid weird coverage results. Now, it's *required* to match them, otherwise no coverage is gathered at all. Fixes #2912.
The profile option was removed from Rust nightly, so we need to remove it from the CI. Unfortuanlly, currently `grcov`, tool used on the test coverage, still doesn't support this change. Refs: mozilla/grcov#1240
The profile option was removed from Rust nightly, so we need to remove it from the CI. Unfortuanlly, currently `grcov`, tool used on the test coverage, still doesn't support this change. Refs: mozilla/grcov#1240
did anyone figure this out? my action looks like this:
blows up with this error:
|
Hi @leshow I'm doing this: name: Coverage
on:
push:
branches:
- develop
env:
CARGO_TERM_COLOR: always
jobs:
report:
name: Generate Coverage Report
environment: coverage
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Cinstrument-coverage"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install LLVM tools
run: sudo apt-get update && sudo apt-get install -y llvm
- id: setup
name: Setup Toolchain
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: llvm-tools-preview
- id: cache
name: Enable Workflow Cache
uses: Swatinem/rust-cache@v2
- id: tools
name: Install Tools
uses: taiki-e/install-action@v2
with:
tool: grcov,cargo-llvm-cov
- id: coverage
name: Generate Coverage Report
run: |
cargo clean
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json
- id: upload
name: Upload Coverage Report
uses: codecov/codecov-action@v5
with:
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ github.workspace }}/codecov.json
fail_ci_if_error: true I'm not using I'm generating the report with codecov format but I suppose you can easily change it for coveralls. |
thanks, I think i've got it working more of less the same but on the stable branch if you're interested:
if that helps anyone out, feel free to use it |
Thanks. This worked for me. The only thing I had to change was to run it in nightly to be able to turn coverage off for some code. Which means I lose grcov's ability to do it by line, but I'll have to do without for now. |
Example: How to generate .gcda files for a Rust project in the readme uses
-Zprofile
which has been removed recently from Rust nightly (see rust-lang/rust#131829).The text was updated successfully, but these errors were encountered: