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

Fix pipeline failures showing up as complete #1518

Merged
merged 1 commit into from
Oct 10, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed

- Package subcommand failing to parse API responses
- Packages which cannot be analyzed showing up as having no issues

## 7.1.0 - 2024-09-24

Expand Down
20 changes: 14 additions & 6 deletions cli/src/commands/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::api::PhylumApi;
use crate::commands::{CommandResult, ExitCode};
use crate::filter::{Filter, FilterIssues};
use crate::format::Format;
use crate::print_user_warning;
use crate::types::{PackageSpecifier, PackageSubmitResponse};
use crate::{print_user_failure, print_user_warning};

fn parse_package(matches: &ArgMatches) -> Result<PackageSpecifier> {
// Read required options.
Expand All @@ -36,12 +36,20 @@ pub async fn handle_get_package(api: &PhylumApi, matches: &clap::ArgMatches) ->

match resp {
PackageSubmitResponse::AlreadyProcessed(mut resp) if resp.complete => {
let filter = matches.get_one::<String>("filter").and_then(|v| Filter::from_str(v).ok());
if let Some(filter) = filter {
resp.filter(&filter);
}
match resp.pipeline_error {
Some(_) => print_user_failure!(
"Package analysis failed, please contact Phylum if this package exists."
),
None => {
let filter =
matches.get_one::<String>("filter").and_then(|v| Filter::from_str(v).ok());
if let Some(filter) = filter {
resp.filter(&filter);
}

resp.write_stdout(pretty_print);
resp.write_stdout(pretty_print);
},
}
},
PackageSubmitResponse::New => {
print_user_warning!(
Expand Down
30 changes: 11 additions & 19 deletions cli/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ pub struct Package {
pub complete: bool,
pub release_data: Option<PackageReleaseData>,
pub repo_url: Option<String>,
pub hash: Option<String>,
pub pipeline_error: Option<String>,
pub pipeline_status: Option<PipelineStatus>,
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -243,25 +246,14 @@ pub enum IgnoredReason {
Other,
}

/// One of the authors of a package.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Author {
pub name: String,
pub avatar_url: String,
pub email: String,
pub profile_url: String,
}

/// Stats about how responsive the maintainers of a package are.
#[derive(Serialize, Deserialize)]
pub struct DeveloperResponsiveness {
pub open_issue_count: Option<usize>,
pub total_issue_count: Option<usize>,
pub open_issue_avg_duration: Option<u32>,
pub open_pull_request_count: Option<usize>,
pub total_pull_request_count: Option<usize>,
pub open_pull_request_avg_duration: Option<u32>,
/// Package status in the analysis pipeline.
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Debug)]
pub enum PipelineStatus {
Submitted,
Downloading,
Processing,
Analyzing,
Complete,
}

/// Information about when package releases have happened.
Expand Down