-
Notifications
You must be signed in to change notification settings - Fork 35
feat(ci): enforce rust crate registration in codecov coverage (#155) #449
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
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a9c7aa6
ci(build): add Rust coverage workflow and codecov.yml mirroring upstr…
WilliamBerryiii d35e8f0
feat(ci): enforce rust crate registration in codecov coverage (#155)
WilliamBerryiii 7a808d0
Merge remote-tracking branch 'github/main' into feat/issue-155-rust-c…
WilliamBerryiii 870d0cd
fix(ci): make rust-tests reusable and wire into pr-validation and main
WilliamBerryiii 918300c
fix(ci): register rust crate paths and correct matrix in reusable wor…
WilliamBerryiii 9d35fe5
fix(ci): make rust-tests reusable-only by removing pull_request/push …
WilliamBerryiii 7f40a2b
chore(scripts): relocate rust-crate-registration-report to logs/
WilliamBerryiii dd4375a
ci(rust): replace enterprise-blocked actions with shell equivalents a…
WilliamBerryiii 3c632df
ci(rust-tests): install protoc and ffmpeg dev libs for candle-onnx/ff…
WilliamBerryiii 15c5dfc
ci(rust-tests): add Syft SBOM + Grype scan for apt packages
WilliamBerryiii 21af59a
Merge remote-tracking branch 'github/main' into feat/issue-155-rust-c…
WilliamBerryiii c118d32
fix(detect-changes): broaden Rust change-file regex to cover all src/…
WilliamBerryiii ce01b6e
chore(workflows): add matrix-folder-check docstring, refactor matrix-…
WilliamBerryiii a9f4ee9
chore(pester): default OutputPath to ./test-results
WilliamBerryiii e63cee9
feat(coverage): expand Rust coverage matrix to 9 crates and fix valid…
WilliamBerryiii 005ecd1
fix(lint): rename Get-RustHasChanges to Test-RustHasChange
WilliamBerryiii 685b62b
fix(workflows): use canonical tarball filenames for syft/grype sha256…
WilliamBerryiii eab9c58
fix(workflows): use Syft-compliant relative exclude patterns in rust-…
WilliamBerryiii 076bde7
fix(ci): resolve rust test failures - add Array4 import, update topic…
WilliamBerryiii 5b3e0fa
fix(clippy): gate Array4 import to test module
WilliamBerryiii 1d4cdb1
fix(rust): correct alert topic detection and gate backend availabilit…
WilliamBerryiii 05f6a05
ci(rust-tests): harden syft download with curl retries
WilliamBerryiii 684e11c
ci(workflows): cache syft binary to mitigate transient GitHub release…
WilliamBerryiii d7984ff
fix(ci): apply .grype.yaml in vuln-scan via sparse checkout
WilliamBerryiii ff3ecef
chore(ci): narrow SBOM scan to repo sources
WilliamBerryiii 18e085a
ci(rust-tests): remove continue-on-error from vuln-scan now that work…
WilliamBerryiii b70610f
Merge branch 'main' into feat/issue-155-rust-coverage-codecov
WilliamBerryiii e13b2fa
Merge branch 'main' into feat/issue-155-rust-coverage-codecov
WilliamBerryiii 4037f46
Merge branch 'main' into feat/issue-155-rust-coverage-codecov
WilliamBerryiii 6220d47
ci(rust-tests): retry apt-get to mitigate transient mirror DNS failures
WilliamBerryiii b414d14
Merge branch 'main' into feat/issue-155-rust-coverage-codecov
WilliamBerryiii 7ec83aa
ci: name vuln-scan matrix entries by crate for clearer job labels
WilliamBerryiii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
.github/instructions/rust-crate-registration.instructions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| --- | ||
| description: 'Required registration of Rust crates under src/500-application for CI test/coverage and Codecov reporting - Brought to you by microsoft/edge-ai' | ||
| applyTo: '**/src/500-application/**/Cargo.toml,**/.github/workflows/rust-tests.yml,**/.github/workflows/pr-validation.yml,**/scripts/build/Detect-Folder-Changes.ps1,**/codecov.yml' | ||
| --- | ||
|
|
||
| # Rust Crate Registration Instructions | ||
|
|
||
| These rules govern how Rust application crates under `src/500-application/**` are registered with CI and Codecov. They complement the broader Rust guidance in [.github/instructions/rust.instructions.md](.github/instructions/rust.instructions.md) ("Workspace Architecture" section) and are enforced by an automated CI gate (see "CI Gate" below). | ||
|
|
||
| Every Rust crate under `src/500-application/**` MUST be either: | ||
|
|
||
| 1. **Registered for coverage** in all three locations described in [Required Registration](#required-registration), OR | ||
| 2. **Explicitly opted out** via the [Coverage Opt-Out](#coverage-opt-out) path in `codecov.yml`. | ||
|
|
||
| There is no third option. PRs that add or restructure a Rust crate without satisfying one of the above will fail the `validate-rust-registration` CI gate. | ||
|
|
||
| <!-- <rust-crate-registration-instructions> --> | ||
|
|
||
| ## Required Registration | ||
|
|
||
| When a Rust crate participates in coverage, it MUST be registered in **all three** of the following locations. Missing any one of them is a CI failure. | ||
|
|
||
| ### 1. `.github/workflows/rust-tests.yml` matrix | ||
|
|
||
| Add the crate as an `include:` entry under `jobs.coverage.strategy.matrix`. Each entry is an object with a `crate` path and optional `system_deps` for extra apt packages: | ||
|
|
||
| ```yaml | ||
| jobs: | ||
| coverage: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - crate: src/500-application/503-media-capture-service/services/media-capture-service | ||
| system_deps: ffmpeg # optional: extra apt packages installed before build | ||
| - crate: src/500-application/507-ai-inference/services/ai-edge-inference | ||
| - crate: src/500-application/507-ai-inference/services/ai-edge-inference-crate | ||
| - crate: src/500-application/NNN-your-new-crate/services/your-service # <-- add here | ||
| ``` | ||
|
|
||
| The `crate` value MUST be the directory containing the crate's `Cargo.toml`. When adding an entry, also bump the `vuln-scan` job's `matrix.index` array so its length matches the number of `include:` entries (zero-based indices). | ||
|
|
||
| ### 2. `scripts/build/Detect-Folder-Changes.ps1` change-detection regex | ||
|
|
||
| `rust-tests.yml` is a reusable workflow (`on: workflow_call`) and has no path triggers of its own. It is invoked by the `rust-tests` job in `pr-validation.yml`, which is gated by the `changesInRust` output of the shared `matrix-changes` job (the reusable `matrix-folder-check.yml` workflow). That output is computed by `scripts/build/Detect-Folder-Changes.ps1`, which matches the diffed PR file list against this regex: | ||
|
|
||
| ```text | ||
| ^src/500-application/ # any path under this prefix | ||
| ^Cargo\.toml$ | ||
| ^Cargo\.lock$ | ||
| ^\.github/workflows/rust-tests\.yml$ | ||
| ^\.github/workflows/pr-validation\.yml$ | ||
| ^codecov\.yml$ | ||
| ``` | ||
|
|
||
| Any crate located under `src/500-application/` is already covered by the `^src/500-application/` prefix and requires **no change** to this filter. Only extend the filter when a crate lives outside that prefix; in that case add a matching condition to the `$rustChangeFiles` block in `scripts/build/Detect-Folder-Changes.ps1` (for example `$_ -match '^src/600-other-area/'`). | ||
|
|
||
| ### 3. `codecov.yml` rust flag paths | ||
|
|
||
| Add a glob covering the crate to `flags.rust.paths` so Codecov associates uploaded coverage with the `rust` flag: | ||
|
|
||
| ```yaml | ||
| flags: | ||
| rust: | ||
| paths: | ||
| - "src/500-application/503-media-capture-service/**" | ||
| - "src/500-application/507-ai-inference/**" | ||
| - "src/500-application/NNN-your-new-crate/**" # <-- add here | ||
| carryforward: true | ||
| ``` | ||
|
|
||
| ## Coverage Opt-Out | ||
|
|
||
| Crates that are intentionally excluded from coverage (for example, experimental scaffolding, WASM operators with no host-side test surface, or crates pending refactor) MUST be listed in `codecov.yml` under `ignore`: | ||
|
|
||
| ```yaml | ||
| ignore: | ||
| - "src/500-application/512-avro-to-json/**" | ||
| - "src/500-application/NNN-your-new-crate/**" # <-- opt out here | ||
| - "target/**" | ||
| ``` | ||
|
|
||
| When a crate is listed under `ignore`, it MUST NOT appear in the `rust-tests.yml` matrix or in `flags.rust.paths`. The CI gate treats ignored crates as fully satisfying the registration requirement. | ||
|
|
||
| ## CI Gate | ||
|
|
||
| The workflow `.github/workflows/validate-rust-registration.yml` runs the script `scripts/Validate-RustCrateRegistration.ps1` on every PR that touches `src/500-application/**`, `.github/workflows/rust-tests.yml`, `codecov.yml`, or the validator itself. The gate fails the build with an itemized report when any crate under `src/500-application/**` is neither fully registered (all three locations) nor explicitly opted out. | ||
|
|
||
| ## Local Validation | ||
|
|
||
| Run before opening a PR: | ||
|
|
||
| ```pwsh | ||
| pwsh ./scripts/Validate-RustCrateRegistration.ps1 | ||
| ``` | ||
|
|
||
| Tests live in `scripts/Validate-RustCrateRegistration.Tests.ps1` and are gated by `.github/workflows/validate-rust-registration.yml` on PR. | ||
|
|
||
| ## Example: Adding a New Crate | ||
|
|
||
| For a hypothetical new crate at `src/500-application/520-example-service` (under the existing `src/500-application/` prefix), only the matrix and the Codecov flag paths need updating; the `pr-validation.yml` regex already matches: | ||
|
|
||
| ```diff | ||
| # .github/workflows/rust-tests.yml | ||
| matrix: | ||
| include: | ||
| - crate: src/500-application/503-media-capture-service/services/media-capture-service | ||
| system_deps: ffmpeg | ||
| - crate: src/500-application/507-ai-inference/services/ai-edge-inference | ||
| - crate: src/500-application/507-ai-inference/services/ai-edge-inference-crate | ||
| + - crate: src/500-application/520-example-service/services/example | ||
| ``` | ||
|
|
||
| Also bump the `vuln-scan` job's `matrix.index` array length to match the new `include:` entry count. | ||
|
|
||
| ```diff | ||
| # codecov.yml | ||
| flags: | ||
| rust: | ||
| paths: | ||
| - "src/500-application/503-media-capture-service/**" | ||
| - "src/500-application/507-ai-inference/**" | ||
| + - "src/500-application/520-example-service/**" | ||
| carryforward: true | ||
| ``` | ||
|
|
||
| If a future crate lives outside `src/500-application/`, also extend the rust-change filter in `scripts/build/Detect-Folder-Changes.ps1` so its path triggers the `rust-tests` job via the `matrix-changes` `changesInRust` output. | ||
|
|
||
| To opt out instead, omit both diffs above and add a single `ignore` entry to `codecov.yml`. | ||
|
|
||
| <!-- </rust-crate-registration-instructions> --> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.