Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions .github/actions/generate-coverage/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

- Add an optional `extra-cargo-args` input whose shell-parsed tokens are
appended to every `cargo llvm-cov` invocation. This allows callers to pass
workspace selection flags such as `--exclude <crate>`, including for the
optional cucumber-rs coverage run. Omitting the input preserves the existing
command unchanged. Package selection flags (`-p` or `--package`) suppress the
default `--workspace`, so they narrow coverage rather than being overridden by
it; `--exclude` keeps `--workspace` because it refines that selection.

- Stop masking coverage failures with an empty-artefact-name error. The
"Archive coverage" step runs with `if: always()`, but the step that computes
its artefact name previously did not, so any earlier failure (for example a
Expand Down
37 changes: 37 additions & 0 deletions .github/actions/generate-coverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Known limitations:
| with-cucumber-rs | Run cucumber-rs scenarios under coverage | no | `false` |
| cucumber-rs-features | Path to cucumber feature files | no | |
| cucumber-rs-args | Extra arguments for cucumber | no | |
| extra-cargo-args | Extra arguments appended to `cargo llvm-cov`, parsed with shell quoting rules. Package selection flags suppress the default `--workspace`. | no | |
| pytest-workers | Value passed to pytest-xdist's `-n` flag. Accepts a positive integer, `auto`, `logical`, or `""` (empty) to disable parallelism. | no | `auto` |
<!-- markdownlint-enable MD013 -->

Expand Down Expand Up @@ -274,6 +275,42 @@ Disable cargo-nextest:
use-cargo-nextest: false
```

Exclude crates from Rust workspace coverage:

```yaml
- uses: ./.github/actions/generate-coverage
with:
output-path: coverage.xml
extra-cargo-args: >-
--exclude rustc-proxy
--exclude dylint-ui-fixture
```

```yaml
- uses: leynos/shared-actions/.github/actions/generate-coverage@v1
with:
output-path: coverage.xml
extra-cargo-args: >-
--exclude rustc-proxy
--exclude dylint-ui-fixture
```

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Measure a single crate instead of the whole workspace:

```yaml
- uses: leynos/shared-actions/.github/actions/generate-coverage@v1
with:
output-path: coverage.xml
extra-cargo-args: --package coverage-helper
```

The action passes `--workspace` by default so that `--exclude` has a package
set to refine. When `extra-cargo-args` contains a package selection flag
(`-p`, `--package`, or either spelling with an inline value), the default
`--workspace` is omitted so the selection actually narrows the run — Cargo
treats `--workspace` as "all members" and would otherwise build and report the
whole workspace regardless of `--package`.

Run pytest serially (disable pytest-xdist):

```yaml
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/generate-coverage/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ inputs:
cucumber-rs-args:
description: Extra arguments for cucumber
required: false
extra-cargo-args:
description: Extra arguments appended to cargo llvm-cov, e.g. --exclude <crate>
required: false
pytest-workers:
description: |
Value passed to pytest-xdist's `-n` flag for the Python coverage run.
Expand Down Expand Up @@ -226,6 +229,7 @@ runs:
INPUT_WITH_CUCUMBER_RS: ${{ inputs.with-cucumber-rs }}
INPUT_CUCUMBER_RS_FEATURES: ${{ inputs.cucumber-rs-features }}
INPUT_CUCUMBER_RS_ARGS: ${{ inputs.cucumber-rs-args }}
INPUT_EXTRA_CARGO_ARGS: ${{ inputs.extra-cargo-args }}
BASELINE_RUST_FILE: ${{ inputs.baseline-rust-file }}
shell: bash

Expand Down
Loading
Loading