Skip to content

feat(cargo-anvil): coordinate Codecov notifications - #423

Open
Sander Saares (sandersaares) wants to merge 33 commits into
mainfrom
u/sasaares/animated-guacamole
Open

Sander Saares (sandersaares) wants to merge 33 commits into
mainfrom
u/sasaares/animated-guacamole

Conversation

@sandersaares

@sandersaares Sander Saares (sandersaares) commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

[Copilot speaking]

Motivation

cargo-anvil uploads coverage from several independent platform jobs, but Codecov can publish intermediate PR coverage comments before all generated reports arrive. Existing repositories also should not need to configure duplicate project and patch coverage gates themselves.

What this changes

  • Keep the existing per-platform coverage uploads and flags.
  • Derive comment.after_n_builds from the generated PR coverage matrix so Codecov waits for every expected upload before updating the PR comment.
  • Generate a repository-owned codecov.yml policy that keeps Codecov comments informative by disabling duplicate Codecov project and patch merge statuses, while preserving unrelated settings.
  • Refuse ambiguous YAML, merge-key migrations, catalog-owned configuration collisions, and unsynchronized customized workflows without replacing repository content.
  • Release the catalog change as cargo-anvil 0.30.0 and regenerate the repository workflows, snapshots, manifest, README, changelog, and lockfile.

The new behavior remains unpublished until the cargo-anvil 0.30.0 release runs after merge.

Closes #421

Copilot AI balanced review requested due to automatic review settings November 30, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical issues can suppress Codecov notifications for customized workflows and tokenless runs, while default configuration creation can overwrite catalog-owned settings and invalidate manifest checksums.

6 open issues
What changed in this PR

This PR coordinates Codecov reporting across cargo-anvil’s GitHub coverage jobs, keeping Codecov informational while Anvil remains the coverage merge gate.

Changes:

  • Adds final PR and scheduled notification jobs while retaining per-platform uploads.
  • Introduces repository-owned Codecov policy updates, migration safeguards, and regression coverage.
  • Prepares cargo-anvil 0.30.0 with updated documentation and regenerated artifacts; publication follows release after merge.
File Description
crates/​cargo-anvil/​tests/​snapshots/​snapshots__github_backend.snap Records generated notification jobs and default policy.
crates/​cargo-anvil/​templates/​github/​scheduled-impl-workflow.yml Adds notification after scheduled coverage jobs.
crates/​cargo-anvil/​templates/​github/​pr-impl-workflow.yml Adds notification after PR coverage jobs.
crates/​cargo-anvil/​src/​run.rs Plans policy updates and workflow reconciliation safeguards.
crates/​cargo-anvil/​src/​lib.rs Registers the policy module and documents integration.
crates/​cargo-anvil/​src/​codecov.rs Implements source-preserving YAML updates and unit tests.
crates/​cargo-anvil/​src/​anvil/​artifacts/​github.rs Adds notification workflow assertions.
crates/​cargo-anvil/​README.md Regenerates integration documentation and version links.
crates/​cargo-anvil/​docs/​design/​updates.md Documents repository-owned policy patches.
crates/​cargo-anvil/​docs/​design/​github.md Defines notification coordination and migration behavior.
crates/​cargo-anvil/​CHANGELOG.md Adds generated 0.30.0 release notes.
crates/​cargo-anvil/​Cargo.toml Bumps cargo-anvil to 0.30.0.
codecov.yml Enables manual notifications and disables project/patch statuses.
Cargo.lock Synchronizes the cargo-anvil version.
.github/​workflows/​anvil-scheduled-impl.yml Regenerates the scheduled notification job.
.github/​workflows/​anvil-pr-impl.yml Regenerates the PR notification job.
.anvil/​manifest.toml Updates tool version and generated checksums.

Review effort: Balanced

Comment thread crates/cargo-anvil/src/run.rs Resolved
Comment thread crates/cargo-anvil/src/run.rs Resolved
Comment thread crates/cargo-anvil/src/codecov.rs Resolved
Comment thread crates/cargo-anvil/src/codecov.rs Resolved
Comment thread crates/cargo-anvil/src/run.rs Resolved
@sandersaares

Copy link
Copy Markdown
Member Author

[Copilot speaking]

Generated during preparation, before the review. Completeness questions are preliminary, not verified findings or a merge recommendation. This snapshot is not updated by later review work.

Pull request: #423

Inspected source commit: de0fd60

Inspected merge-base commit: 7a81993

Content overview

Pull request: #423

Mission

Oxidizer Tools provides utilities for building and validating Rust services. cargo-anvil gives Rust repositories a common local verification interface and generates matching CI infrastructure for GitHub Actions and Azure DevOps. Its coverage check evaluates the released library and binary surfaces; Codecov displays coverage data from the GitHub runs.

Substance

This change coordinates Codecov reporting across the GitHub pull request and scheduled coverage matrices. Anvil keeps the individual platform uploads, then asks Codecov to notify once the matrix finishes. It also creates or updates the repository's Codecov policy to request manual notification and disable duplicate project and patch statuses. The local coverage gate still determines the coverage verdict. The Azure DevOps backend is unchanged.

Design changes

  • Coverage notification timing. The previous GitHub coverage design specified best-effort per-platform uploads and an authoritative local gate. The workflows did not explicitly trigger notifications after the matrix. The updated design retains the uploads and adds a best-effort final trigger that can run after matrix failure but not after cancellation or a skipped matrix. This bases notification timing on job completion rather than a fixed upload count.
  • Policy and ownership. Previously, Anvil did not configure Codecov YAML; the repository's own codecov.yml specified a project coverage target. The updated GitHub design specifies one repository-owned YAML file with manual notification enabled and both Codecov statuses disabled, while preserving unrelated settings. The planner enables the policy only when both implementation workflows are in sync or can be written from the catalog; customized workflows can be reconciled via Anvil's proposal mechanism. The update design documents this as a repository-owned policy edit, like the existing Dependabot exclusions, rather than a file tracked by Anvil's ownership manifest.

Significant changes

No separate significant behavior changes beyond those covered by the design changes above.

Structure

  • Update planning and editing: crates/cargo-anvil/src/run.rs discovers the configuration, checks backend and workflow compatibility, and plans the write. The new crates/cargo-anvil/src/codecov.rs supplies the default policy, edits existing YAML, and tests preservation, idempotence, and refusals.
  • CI: The PR and scheduled implementation templates under crates/cargo-anvil/templates/github/ add the notification jobs. Their checked-in copies under .github/workflows/ and the GitHub backend snapshot reflect the same wiring. src/anvil/artifacts/github.rs adds checks for the template wiring, and src/run.rs tests fresh setup, existing policy migration, and customized workflows. Root codecov.yml applies the policy in Oxidizer Tools itself.
  • Documentation and release metadata: The design updates describe the coordination and ownership rules. The crate documentation in src/lib.rs and the generated crate README describe the public behavior. The crate manifest, workspace lockfile, release notes, and .anvil/manifest.toml record version 0.30.0; the Anvil manifest also records the new catalog and implementation-workflow checksums.

Mechanism

On GitHub backend updates, the planner checks that the active catalog manages both implementation workflows and that each is either in sync or planned for writing. It then looks for codecov.yml and .codecov.yml in the root, dev/, and .github/. If none exists, it writes a root default. If exactly one eligible file exists, it plans only the needed edits. Multiple candidates, conflicting catalog ownership, or unsupported YAML produce a refusal instead of an edit to the policy file.

The editor uses parser source spans to change codecov.notify.manual_trigger, coverage.status.project, and coverage.status.patch. It preserves unrelated source text instead of serializing the document, reparses the result, and returns no change when the policy is already present. Anvil does not record a whole-file checksum for this policy write.

Native test matrix (PR or scheduled)
  ├─ Linux, Windows, Linux ARM: upload both LCOV reports if present
  └─ Windows ARM: tests only
                      │ matrix completes
                      ▼
             One Linux notification job
                      │ best-effort trigger
                      ▼
             Codecov coverage display

The notification job calls the pinned Codecov action's send-notifications command using the same CODECOV_TOKEN input as the uploads. The unchanged callers inherit secrets; the workflow does not enable Codecov OIDC. A failed matrix can reach the notification job, but a skipped matrix or canceled workflow does not. The job does not require the matrix to report a successful upload. Neither reporting step supplies the coverage verdict.

Completeness assessment

The diff connects the policy editor, planner, generated workflows, repository configuration, tests, and documentation. No unfinished implementation or missing generated counterpart is apparent. The static evidence does not establish Codecov's live response to the new job. Review should check:

  • Does the pinned action resolve the same commit, repository, and authentication for the standalone notification as for the uploads, including fork PRs, merge groups, and scheduled runs? How does Codecov handle a trigger with no accepted report or with reports still being processed?
  • Does configuration discovery and editing preserve unrelated settings across supported file locations and layout variants, especially document markers, comments next to edited fields, and shared YAML structures?
  • Do upgrades with proposed workflow changes, already-enabled policy, or independent upload jobs preserve the intended ordering? Does disabling either Codecov status require a separate change to any consumer repository's required checks?

Related history

Related work

The previous workflow let separate platform jobs upload as they finished, without a shared notification point. The repository's Codecov project threshold also supplied a coverage status alongside the Anvil gate. The patch addresses both in the GitHub backend. No separate work item or removed TODO is identified in the feature commits or changed implementation.

ℹ️ Replies are not monitored. To discuss the comment, reach out via Teams.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings November 30, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread crates/cargo-anvil/Cargo.toml Resolved
Comment thread crates/cargo-anvil/src/codecov.rs Resolved
Comment thread crates/cargo-anvil/src/run.rs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings November 30, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The upload-count logic treats unsupported matrix conditions as valid, producing after_n_builds: 4 when only one leg uploads and leaving the PR comment waiting indefinitely.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Reject unsupported upload-condition predicates to avoid incorrect build counts

crates/​cargo-anvil/​src/​codecov.rs:73

With the four-platform matrix, a downstream upload condition using matrix.os == 'linux' and the existing report guards returns Some(4) here, although only one leg uploads. Anvil consequently writes after_n_builds: 4, leaving the PR comment waiting for uploads that cannot arrive. Validate every condition clause against a supported grammar and return None for unknown predicates; add regressions for equality restrictions and disjunctions.

3 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings November 30, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because condition parsing can make Codecov wait for uploads that cannot arrive, while bare-CR YAML handling can silently leave statuses enabled.

No open issues 🎉

Review effort: Balanced

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo-gamma found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.38776% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.5%. Comparing base (bc0d1de) to head (eae6f14).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/cargo-anvil/src/run.rs 97.5% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #423     +/-   ##
=======================================
- Coverage   99.5%   99.5%   -0.1%     
=======================================
  Files        378     379      +1     
  Lines      72896   73385    +489     
=======================================
+ Hits       72539   73025    +486     
- Misses       357     360      +3     
Flag Coverage Δ
linux 99.5% <99.3%> (-0.1%) ⬇️
linux-arm 99.5% <99.3%> (-0.1%) ⬇️
scheduled ?
windows 99.5% <99.3%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings November 30, 2026 16:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because platform-restricted conditions can overcount expected uploads and leave Codecov waiting indefinitely, while negative tests do not verify the intended failure causes.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings November 30, 2026 17:23
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Replacing a nested flow mapping leaves trailing braces, producing a YAML string instead of boolean false and failing to disable the status.

1 open issue

Review effort: Balanced

Comment thread crates/cargo-anvil/src/codecov.rs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because an interaction between configuration ownership and workflow validation can make dry runs fail even when all artifacts are synchronized.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the coordinated Codecov reporting changes.

No open issues 🎉

Review effort: Balanced

Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Comment thread crates/cargo-anvil/src/codecov.rs Fixed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because merge or duplicate keys in coverage can abort the update instead of returning the documented refusal.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the Codecov reporting coordination changes.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test’s substring and idempotence assertions can pass even when unrelated settings move between mappings, leaving the source-preservation contract insufficiently verified.

1 open issue

Review effort: Balanced

Comment thread crates/cargo-anvil/src/codecov.rs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37fa148259947a0981c95d8eaf22b4a
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because unpublished findings identify persistent dry-run failures for catalog-owned policies and empty Codecov files that subsequent updates refuse.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cargo-anvil): make Codecov reporting informative-only by default

4 participants