diff --git a/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs b/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs index 8b97a6c82..55a6683c3 100644 --- a/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs +++ b/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs @@ -5,8 +5,8 @@ use crate::blocking::StudioClient; use crate::operations::subgraph::check_workflow::types::QueryResponseData; use crate::shared::{ CheckWorkflowResponse, Diagnostic, DownstreamCheckResponse, GraphRef, LintCheckResponse, - OperationCheckResponse, ProposalsCheckResponse, ProposalsCheckSeverityLevel, RelatedProposal, - SchemaChange, + OperationCheckResponse, ProposalsCheckResponse, ProposalsCheckSeverityLevel, ProposalsCoverage, + RelatedProposal, SchemaChange, }; use crate::RoverClientError; @@ -359,10 +359,25 @@ fn get_proposals_response_from_result( } _ => ProposalsCheckSeverityLevel::OFF, }; + let coverage = match result.proposal_coverage { + subgraph_check_workflow_query::ProposalCoverage::FULL => ProposalsCoverage::FULL, + subgraph_check_workflow_query::ProposalCoverage::PARTIAL => { + ProposalsCoverage::PARTIAL + } + subgraph_check_workflow_query::ProposalCoverage::NONE => ProposalsCoverage::NONE, + subgraph_check_workflow_query::ProposalCoverage::OVERRIDDEN => { + ProposalsCoverage::OVERRIDDEN + } + subgraph_check_workflow_query::ProposalCoverage::PENDING => { + ProposalsCoverage::PENDING + } + _ => ProposalsCoverage::PENDING, + }; Some(ProposalsCheckResponse { target_url, task_status: task_status.into(), severity_level: severity, + proposal_coverage: coverage, related_proposals, }) } diff --git a/crates/rover-client/src/shared/check_response.rs b/crates/rover-client/src/shared/check_response.rs index 671a5dcc6..5c2d740dd 100644 --- a/crates/rover-client/src/shared/check_response.rs +++ b/crates/rover-client/src/shared/check_response.rs @@ -274,13 +274,21 @@ impl LintCheckResponse { } #[derive(Debug, Serialize, Clone, Eq, PartialEq)] - pub enum ProposalsCheckSeverityLevel { ERROR, OFF, WARN, } +#[derive(Debug, Serialize, Clone, Eq, PartialEq)] +pub enum ProposalsCoverage { + FULL, + NONE, + OVERRIDDEN, + PARTIAL, + PENDING, +} + #[derive(Debug, Serialize, Clone, Eq, PartialEq)] pub struct RelatedProposal { pub status: String, @@ -291,6 +299,7 @@ pub struct RelatedProposal { pub struct ProposalsCheckResponse { pub task_status: CheckTaskStatus, pub severity_level: ProposalsCheckSeverityLevel, + pub proposal_coverage: ProposalsCoverage, pub target_url: Option, pub related_proposals: Vec, } @@ -312,10 +321,15 @@ impl ProposalsCheckResponse { } pub fn get_msg(&self) -> String { - match self.severity_level { - ProposalsCheckSeverityLevel::ERROR => "Your check failed because some or all of the diffs in this change are not in an approved Proposal.".to_string(), - ProposalsCheckSeverityLevel::WARN => "Your check passed with warnings because some or all of the diffs in this change are not in an approved Proposal.".to_string(), - ProposalsCheckSeverityLevel::OFF => "Proposal checks are disabled".to_string(), + match self.proposal_coverage { + ProposalsCoverage::FULL => "All of the diffs in this change are associated with an approved Proposal.".to_string(), + ProposalsCoverage::PARTIAL | ProposalsCoverage::NONE => match self.severity_level { + ProposalsCheckSeverityLevel::ERROR => "Your check failed because some or all of the diffs in this change are not in an approved Proposal, and your schema check severity level is set to ERROR.".to_string(), + ProposalsCheckSeverityLevel::WARN => "Your check passed with warnings because some or all of the diffs in this change are not in an approved Proposal, and your schema check severity level is set to WARN.".to_string(), + ProposalsCheckSeverityLevel::OFF => "Proposal checks are disabled".to_string(), + }, + ProposalsCoverage::OVERRIDDEN => "Proposal check results have been overriden in Studio".to_string(), + ProposalsCoverage::PENDING => "Proposal check has not completed".to_string(), } } diff --git a/crates/rover-client/src/shared/mod.rs b/crates/rover-client/src/shared/mod.rs index 9c66a258f..686d78bb5 100644 --- a/crates/rover-client/src/shared/mod.rs +++ b/crates/rover-client/src/shared/mod.rs @@ -9,7 +9,7 @@ pub use async_check_response::CheckRequestSuccessResult; pub use check_response::{ ChangeSeverity, CheckConfig, CheckTaskStatus, CheckWorkflowResponse, DownstreamCheckResponse, LintCheckResponse, OperationCheckResponse, ProposalsCheckResponse, ProposalsCheckSeverityLevel, - RelatedProposal, SchemaChange, ValidationPeriod, + ProposalsCoverage, RelatedProposal, SchemaChange, ValidationPeriod, }; pub use fetch_response::{FetchResponse, Sdl, SdlType}; pub use git_context::GitContext; diff --git a/src/command/output.rs b/src/command/output.rs index 43104758d..f0381e65c 100644 --- a/src/command/output.rs +++ b/src/command/output.rs @@ -664,7 +664,7 @@ mod tests { shared::{ ChangeSeverity, CheckTaskStatus, CheckWorkflowResponse, Diagnostic, LintCheckResponse, OperationCheckResponse, ProposalsCheckResponse, ProposalsCheckSeverityLevel, - RelatedProposal, SchemaChange, Sdl, SdlType, + ProposalsCoverage, RelatedProposal, SchemaChange, Sdl, SdlType, }, }; @@ -990,6 +990,7 @@ mod tests { task_status: CheckTaskStatus::PASSED, target_url: Some("https://studio.apollographql.com/graph/my-graph/variant/current/proposals/1".to_string()), severity_level: ProposalsCheckSeverityLevel::WARN, + proposal_coverage: ProposalsCoverage::NONE, related_proposals: vec![RelatedProposal { status: "OPEN".to_string(), display_name: "Mock Proposal".to_string(), @@ -1042,6 +1043,7 @@ mod tests { "warnings_count": 1 }, "proposals": { + "proposal_coverage": "NONE", "related_proposals": [ { "status": "OPEN", @@ -1117,6 +1119,7 @@ mod tests { task_status: CheckTaskStatus::FAILED, target_url: Some("https://studio.apollographql.com/graph/my-graph/variant/current/proposals/1".to_string()), severity_level: ProposalsCheckSeverityLevel::ERROR, + proposal_coverage: ProposalsCoverage::PARTIAL, related_proposals: vec![RelatedProposal { status: "OPEN".to_string(), display_name: "Mock Proposal".to_string(), @@ -1180,6 +1183,7 @@ mod tests { "warnings_count": 1 }, "proposals": { + "proposal_coverage": "PARTIAL", "related_proposals": [ { "status": "OPEN",