Skip to content

chore(ci): add coverage gates via codecov.yml (#1228) - #1291

Merged
henrypark133 merged 1 commit into
nearai:stagingfrom
CPU-216:ci/codecov-coverage-gates
Mar 18, 2026
Merged

henrypark133 merged 1 commit into
nearai:stagingfrom
CPU-216:ci/codecov-coverage-gates

Conversation

@CPU-216

@CPU-216 CPU-216 commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1228. Tighten coverage gates in codecov.yml to prevent new code from lowering the project's test quality baseline.

Changes

codecov.yml

Setting Before After Rationale
Project target auto 80% Fixed threshold prevents drift (issue rationale)
Project threshold 1% 2% Absorbs timing-dependent coverage fluctuation
Patch target 80% 90% New code should meet a higher bar
Patch threshold 5% (removed) Strict enforcement for new code
Comment layout (none) reach,diff,flags Shows per-flag breakdown
require_changes (none) true Reduces PR comment noise

Design Decisions

  • Fixed 80% vs auto: auto tracks the base branch and can drift downward over time. A fixed target creates a hard floor.
  • 90% patch: New code should be well-tested. Contributors can request exceptions via PR discussion for hard-to-test paths (e.g., error recovery).
  • require_changes: true: Codecov only comments on PRs where coverage actually changes, reducing noise on docs/chore PRs.

Testing

  • YAML syntax validated (python3 -c "import yaml; yaml.safe_load(open('codecov.yml'))")
  • cargo fmt --all -- --check passed
  • cargo clippy --all -- -D warnings passed
  • cargo test passed (3196 passed; 2 pre-existing flaky failures unrelated to this change)
  • Codecov status checks will appear on this PR after CI runs (live validation)

Review Track

Track A (chore) — This PR modifies only the Codecov configuration file (codecov.yml), not CI workflow definitions (.github/workflows/). No rollback plan needed; reverting this single-file change restores previous behavior.

@github-actions github-actions Bot added scope: llm LLM integration scope: workspace Persistent memory / workspace size: L 200-499 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: regular 2-5 merged PRs labels Mar 17, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's CI/CD pipeline by strengthening code quality standards and improving the resilience of API interactions. The updated Codecov configuration establishes higher, fixed coverage targets for both the overall project and new code, aiming to maintain and elevate test quality. Concurrently, a critical fix was applied to various LLM and embedding provider clients to prevent None errors when parsing Retry-After headers, ensuring a consistent retry duration fallback and improving API resilience during rate-limiting scenarios.

Highlights

  • Code Coverage Gates: Tightened Codecov coverage gates by setting a fixed project target of 80% and a stricter patch target of 90% to prevent test quality degradation.
  • Codecov Comment Configuration: Configured Codecov comments to display reach, diff, and flags, and enabled 'require_changes' to reduce comment noise by only posting when coverage actually changes.
  • Retry-After Header Fallback: Implemented a robust fallback mechanism for 'Retry-After' headers in LLM and embedding providers, ensuring a default 60-second retry duration when the header is missing or unparseable, preventing 'retry after None' errors.
  • Unit Test Enhancements: Introduced comprehensive unit tests for 'Retry-After' header parsing and fallback logic across anthropic_oauth, nearai_chat, and embeddings modules, along with a regression test for RateLimited errors.
Changelog
  • codecov.yml
    • Updated project coverage target from 'auto' to '80%'
    • Adjusted project coverage threshold from '1%' to '2%'
    • Increased patch coverage target from '80%' to '90%'
    • Removed patch coverage threshold
    • Added comment layout configuration to show 'reach,diff,flags'
    • Enabled 'require_changes' for comments to reduce noise
  • src/llm/anthropic_oauth.rs
    • Implemented a 60-second fallback for 'Retry-After' header parsing when the header is missing or unparseable
    • Added new unit tests for 'Retry-After' header parsing, including fallback scenarios
  • src/llm/nearai_chat.rs
    • Implemented a 60-second fallback for 'Retry-After' header parsing when the header is missing or unparseable
    • Added new unit tests for 'Retry-After' header parsing, including RFC2822 date format and fallback scenarios
  • src/llm/retry.rs
    • Added a regression test to verify that 'RateLimited' errors always contain a 'retry_after' duration
  • src/workspace/embeddings.rs
    • Implemented a 60-second fallback for 'Retry-After' header parsing in 'OpenAiEmbeddings'
    • Implemented a 60-second fallback for 'Retry-After' header parsing in 'NearAiEmbeddings'
    • Added new unit tests for 'Retry-After' header parsing, including fallback scenarios
Activity
  • YAML syntax validated
  • cargo fmt --all -- --check passed
  • cargo clippy --all -- -D warnings passed
  • cargo test passed (with 2 pre-existing flaky failures unrelated to this change)
  • Codecov status checks are expected to appear on this PR after CI runs for live validation
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request primarily updates the Codecov configuration to enforce stricter coverage gates. It also includes a valuable bugfix across several LLM providers to handle missing Retry-After headers by adding a default fallback duration, preventing potential errors. The fix is applied consistently and is well-tested. My review includes one suggestion to remove a redundant test that doesn't seem to add value.

Comment thread src/llm/retry.rs
Comment on lines +404 to +423
fn rate_limited_error_always_has_duration() {
let err = LlmError::RateLimited {
provider: "test".to_string(),
retry_after: Some(std::time::Duration::from_secs(60)),
};

if let LlmError::RateLimited { retry_after, .. } = err {
assert!(
retry_after.is_some(),
"Rate limited error should always have retry_after duration"
);
assert_eq!(
retry_after,
Some(std::time::Duration::from_secs(60)),
"Fallback should be 60 seconds"
);
} else {
panic!("Expected RateLimited error");
}
}

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.

medium

This test appears to be redundant and doesn't verify the behavior described in its comment. It constructs an LlmError::RateLimited with a Some value for retry_after and then asserts that the value is Some. This is a tautology and doesn't test the fallback logic at the error creation sites.

The new tests added in anthropic_oauth.rs, nearai_chat.rs, and embeddings.rs already cover the fallback logic effectively for each provider. This test in retry.rs doesn't add any further validation and could be misleading.

Consider removing this test to avoid confusion and rely on the provider-specific tests, which are more direct and meaningful.

@CPU-216
CPU-216 changed the base branch from main to staging March 17, 2026 05:31
- Project target: 80% with 2% threshold (was: auto with 1%)
- Patch target: 90% (was: 80% with 5% threshold)
- Add PR comment config with reach/diff/flags layout
- Enable require_changes to reduce comment noise
@CPU-216
CPU-216 force-pushed the ci/codecov-coverage-gates branch from a00821d to cc1f233 Compare March 17, 2026 05:33
@github-actions github-actions Bot added size: S 10-49 changed lines and removed size: L 200-499 changed lines labels Mar 17, 2026

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: Tighten Codecov coverage gates

Reasonable configuration update. Project target 80% with 2% threshold, patch target 90%.

Positives:

  • require_changes: true reduces PR comment noise
  • reach,diff,flags layout is more informative than default
  • Codecov gates are informational (not in required status checks), so won't block legitimate PRs

LGTM.

@henrypark133
henrypark133 merged commit 9286978 into nearai:staging Mar 18, 2026
14 checks passed
bkutasi pushed a commit to bkutasi/ironclaw that referenced this pull request Mar 28, 2026
)

- Project target: 80% with 2% threshold (was: auto with 1%)
- Patch target: 90% (was: 80% with 5% threshold)
- Add PR comment config with reach/diff/flags layout
- Enable require_changes to reduce comment noise
drchirag1991 pushed a commit to drchirag1991/ironclaw that referenced this pull request Apr 8, 2026
)

- Project target: 80% with 2% threshold (was: auto with 1%)
- Patch target: 90% (was: 80% with 5% threshold)
- Add PR comment config with reach/diff/flags layout
- Enable require_changes to reduce comment noise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: regular 2-5 merged PRs risk: low Changes to docs, tests, or low-risk modules scope: llm LLM integration scope: workspace Persistent memory / workspace size: S 10-49 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add coverage gates via codecov.yml configuration

2 participants