Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .changesets/maint_codecov.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Configure Codecov with coverage targets - @DaleSeo PR #337

This PR adds `codecov.yml` to set up Codecov with specific coverage targets and quality standards. It helps define clear expectations for code quality. It also includes some documentation about code coverage in `CONTRIBUTING.md` and adds the Codecov badge to `README.md`.
3 changes: 2 additions & 1 deletion .github/workflows/verify-changeset.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Verify Changeset
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches-ignore:
- main
- release/**
Expand All @@ -19,7 +20,7 @@ on:

jobs:
verify-changeset:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changeset') && !startsWith(github.head_ref, 'sync/') && !startsWith(github.head_ref, 'conflict/') }}
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changeset') && !startsWith(github.head_ref, 'sync/') && !startsWith(github.head_ref, 'conflict/') && !github.event.pull_request.draft }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I often find it difficult to decide what to write when drafting a PR. This will help reduce the comment noises on draft PRs.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, should it have flagged this PR once it was moved out of draft status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this! I'll update the workflow to include the ready_for_review event so it will trigger automatically when a PR is converted from draft to ready for review.

Copy link
Contributor Author

@DaleSeo DaleSeo Sep 9, 2025

Choose a reason for hiding this comment

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

I tested the updated workflow on this PR.

When I removed the changeset and marked the PR as draft, the workflow correctly skipped verifying the changeset.

2025-09-09 at 14 20 28

After marking the PR as ready for review, the verification ran and the expected comment was added.

2025-09-09 at 14 22 46

name: Verify
runs-on: ubuntu-24.04
permissions:
Expand Down
19 changes: 18 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,21 @@ It’s important that every piece of code in Apollo packages is reviewed by at l
2. Simplicity. Is this the simplest way to achieve the intended goal? If there are too many files, redundant functions, or complex lines of code, suggest a simpler way to do the same thing. In particular, avoid implementing an overly general solution when a simple, small, and pragmatic fix will do.
3. Testing. Please make sure that the tests ensure that the code won’t break when other stuff change around it. The error messages in the test should help identify what is broken exactly and how. The tests should test every edge case if possible. Please make sure you get as much coverage as possible.
4. No unnecessary or unrelated changes. PRs shouldn’t come with random formatting changes, especially in unrelated parts of the code. If there is some refactoring that needs to be done, it should be in a separate PR from a bug fix or feature, if possible.
5. Please run `cargo test`, `cargo clippy`, and `cargo fmt` prior to creating a PR.
5. Please run `cargo test`, `cargo clippy`, and `cargo fmt` prior to creating a PR.

### Code Coverage

Apollo MCP Server uses comprehensive code coverage reporting to ensure code quality and test effectiveness.
The project uses [cargo-llvm-cov](https://crates.io/crates/cargo-llvm-cov) for generating code coverage reports and [Codecov](https://www.codecov.io/) for coverage analysis and reporting. Coverage is automatically generated and reported on every pull request through GitHub Actions.

#### Coverage Targets

The project maintains the following coverage targets, configured in `codecov.yml`:

- **Project Coverage**: Automatically maintained - should increase overall coverage on each PR
- **Patch Coverage**: 80% - requires 80% coverage on all new/modified code

These targets help ensure that:

- The overall codebase coverage doesn't decrease over time
- New code is well-tested before being merged
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
![release binaries workflow status](https://img.shields.io/github/actions/workflow/status/apollographql/apollo-mcp-server/release-bins.yml?label=release%20binaries)
![release container workflow status](https://img.shields.io/github/actions/workflow/status/apollographql/apollo-mcp-server/release-container.yml?label=release%20container)
![license](https://img.shields.io/github/license/apollographql/apollo-mcp-server)
[![codecov](https://codecov.io/github/apollographql/apollo-mcp-server/graph/badge.svg?token=6NHuvZQ8ak)](https://codecov.io/github/apollographql/apollo-mcp-server)

# Apollo MCP Server

Expand Down
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
status:
project:
default:
# Should increase overall coverage on each PR
target: auto
patch:
default:
# Require 80% coverage on all new/modified code
target: 80%
Copy link
Contributor Author

@DaleSeo DaleSeo Sep 9, 2025

Choose a reason for hiding this comment

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

I set the patch coverage target at 80% to begin with since that seems to be a reasonable standard in other Apollo projects. If anyone thinks this is too high or not realistic for our codebase, please let me know. Just to clarify, this requirement only applies to new or modified code, not untouched code.

Image

Copy link
Contributor

Choose a reason for hiding this comment

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

80% seems fine to me. Is this possible to be overridden in the case where the SDK makes it near impossible to test, or we are rushing a hotfix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@swcollard We can use the ‎#[coverage(off)] attribute from ‎llvm-cov to exclude specific functions or modules from coverage reporting.

#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

// function
#[cfg_attr(coverage_nightly, coverage(off))]
fn exclude_fn_from_coverage() {
    // ...
}

// module
#[cfg_attr(coverage_nightly, coverage(off))]
mod exclude_mod_from_coverage {
    // ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a Confluence page and added this for future reference.

30 changes: 28 additions & 2 deletions crates/apollo-mcp-registry/src/uplink/schema/event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::uplink::schema::SchemaState;
use super::SchemaState;
use std::fmt::Debug;
use std::fmt::Formatter;
use std::fmt::Result;

/// Schema events
pub enum Event {
Expand All @@ -12,7 +13,7 @@ pub enum Event {
}

impl Debug for Event {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
Event::UpdateSchema(_) => {
write!(f, "UpdateSchema(<redacted>)")
Expand All @@ -23,3 +24,28 @@ impl Debug for Event {
}
}
}

#[cfg(test)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added tests for untested code to verify that the Codecov configuration is working as expected.

Image

https://app.codecov.io/github/apollographql/apollo-mcp-server/pull/337

mod tests {
use super::*;

#[test]
fn test_debug_event_no_more_schema() {
let event = Event::NoMoreSchema;
let output = format!("{:?}", event);
assert_eq!(output, "NoMoreSchema");
}

#[test]
fn test_debug_redacts_update_schema() {
let event = Event::UpdateSchema(SchemaState {
sdl: "type Query { hello: String }".to_string(),
launch_id: Some("test-launch-123".to_string()),
});

let output = format!("{:?}", event);
assert_eq!(output, "UpdateSchema(<redacted>)");
assert!(!output.contains("type Query"));
assert!(!output.contains("test-launch-123"));
}
}