Skip to content
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

🐛 Use proposalCoverage in addition to severityLevel to build correct proposal check messaging #1845

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
})
}
Expand Down
24 changes: 19 additions & 5 deletions crates/rover-client/src/shared/check_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<String>,
pub related_proposals: Vec<RelatedProposal>,
}
Expand All @@ -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(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rover-client/src/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/command/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ mod tests {
shared::{
ChangeSeverity, CheckTaskStatus, CheckWorkflowResponse, Diagnostic, LintCheckResponse,
OperationCheckResponse, ProposalsCheckResponse, ProposalsCheckSeverityLevel,
RelatedProposal, SchemaChange, Sdl, SdlType,
ProposalsCoverage, RelatedProposal, SchemaChange, Sdl, SdlType,
},
};

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -1042,6 +1043,7 @@ mod tests {
"warnings_count": 1
},
"proposals": {
"proposal_coverage": "NONE",
"related_proposals": [
{
"status": "OPEN",
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -1180,6 +1183,7 @@ mod tests {
"warnings_count": 1
},
"proposals": {
"proposal_coverage": "PARTIAL",
"related_proposals": [
{
"status": "OPEN",
Expand Down