Skip to content

ci(rust): --workspace in cargo-flags breaks the coverage job #352

Description

@BryanFRD

reusable-ci-rust.yml cannot express "run tests across the whole workspace, with default features". A caller that wants --workspace on cargo test has no way to keep the coverage job working.

cargo-flags is appended to clippy and test:

run: cargo test --locked $CARGO_FLAGS $TEST_ARGS

The coverage step hardcodes --workspace and falls back to cargo-flags when coverage-flags is empty:

COVERAGE_FLAGS: ${{ inputs.coverage-flags || inputs.cargo-flags }}
run: cargo llvm-cov --locked $COVERAGE_FLAGS --workspace --lcov --output-path lcov.info

So cargo-flags: --workspace produces cargo llvm-cov --locked --workspace --workspace, and llvm-cov refuses:

error: the argument '--workspace' was provided more than once, but cannot be used multiple times

Verified with cargo-llvm-cov 0.8.5.

The coverage-flags description already names the workaround, "set separately when cargo-flags already carries --workspace", but it only works when the caller has some other non-empty value to put there. A caller that deliberately clears the --all-features default has nothing: coverage-flags: '' is falsy in a GitHub expression, so it falls straight back to cargo-flags.

Found in FerrFleet-Cloud, where cargo-flags: '' exists precisely to keep --all-features from compiling database-gated tests into the plain test job. Adding --workspace there as a guard against a future workspace member going untested is currently impossible without breaking Coverage.

Two ways out, either is fine:

  • Drop the hardcoded --workspace from the llvm-cov command and let callers pass it through coverage-flags / cargo-flags. Changes the default for callers that rely on it, so it wants a look at who does.
  • Keep the hardcode and strip a --workspace out of COVERAGE_FLAGS before splicing it.

The second is the smaller change and breaks nobody.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions