Skip to content

report private repository error as broken crate #453

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

Merged
merged 3 commits into from
Sep 24, 2019
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
2 changes: 2 additions & 0 deletions src/crates/lists.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::config::Config;
use crate::crates::sources::github::GitHubRepo;
use crate::crates::{Crate, RegistryCrate};
use crate::db::{Database, QueryUtils};
use crate::experiments::CrateSelect;
Expand Down Expand Up @@ -129,6 +130,7 @@ pub(crate) fn get_crates(
CrateSelect::Local => {
crates.append(&mut LocalList::get(db)?);
}
CrateSelect::Dummy => crates.push(Crate::GitHub(GitHubRepo::dummy())),
}

crates.sort();
Expand Down
9 changes: 9 additions & 0 deletions src/crates/sources/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::str::FromStr;

static CACHED_LIST: &str =
"https://github.com/raw/rust-ops/rust-repos/master/data/github.csv";
const DUMMY_ORG: &str = "ghost";
const DUMMY_NAME: &str = "missing";

#[derive(Deserialize)]
struct ListRepo {
Expand Down Expand Up @@ -73,6 +75,13 @@ impl GitHubRepo {
pub(crate) fn slug(&self) -> String {
format!("{}/{}", self.org, self.name)
}

pub(crate) fn dummy() -> GitHubRepo {
GitHubRepo {
org: DUMMY_ORG.to_string(),
name: DUMMY_NAME.to_string(),
}
}
}

impl FromStr for GitHubRepo {
Expand Down
1 change: 1 addition & 0 deletions src/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ string_enum!(pub enum CrateSelect {
SmallRandom => "small-random",
Top100 => "top-100",
Local => "local",
Dummy => "dummy",
});

string_enum!(pub enum CapLints {
Expand Down
1 change: 1 addition & 0 deletions src/report/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl ResultName for BrokenReason {
BrokenReason::Unknown => "broken crate".into(),
BrokenReason::CargoToml => "broken Cargo.toml".into(),
BrokenReason::Yanked => "deps yanked".into(),
BrokenReason::MissingGitRepository => "missing repo".into(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/results/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ string_enum!(pub enum BrokenReason {
Unknown => "unknown",
CargoToml => "cargo-toml",
Yanked => "yanked",
MissingGitRepository => "missing-git-repository",
});

test_result_enum!(pub enum TestResult {
Expand Down
3 changes: 2 additions & 1 deletion src/runner/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::crates::Crate;
use crate::experiments::Experiment;
use crate::prelude::*;
use crate::results::{EncodingType, TestResult, WriteResults};
use crate::runner::test::detect_broken;
use crate::runner::{test, RunnerState};
use crate::toolchain::Toolchain;
use crate::utils;
Expand Down Expand Up @@ -178,7 +179,7 @@ impl Task {
.insert(self.krate.clone(), storage.clone());
logging::capture(&storage, || {
let rustwide_crate = self.krate.to_rustwide();
rustwide_crate.fetch(workspace)?;
detect_broken(rustwide_crate.fetch(workspace))?;

if let Crate::GitHub(repo) = &self.krate {
if let Some(sha) = rustwide_crate.git_commit(workspace) {
Expand Down
24 changes: 14 additions & 10 deletions src/runner/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@ fn failure_reason(err: &Error) -> FailureReason {
FailureReason::Unknown
}

fn detect_broken<T>(res: Result<T, Error>) -> Result<T, Error> {
pub(super) fn detect_broken<T>(res: Result<T, Error>) -> Result<T, Error> {
match res {
Ok(ok) => Ok(ok),
Err(err) => {
let mut reason = None;
for cause in err.iter_chain() {
if let Some(&PrepareError::MissingCargoToml) = cause.downcast_ctx() {
reason = Some(BrokenReason::CargoToml);
} else if let Some(&PrepareError::InvalidCargoTomlSyntax) = cause.downcast_ctx() {
reason = Some(BrokenReason::CargoToml);
} else if let Some(&PrepareError::YankedDependencies) = cause.downcast_ctx() {
reason = Some(BrokenReason::Yanked);
} else {
continue;
if let Some(error) = cause.downcast_ctx() {
reason = match *error {
PrepareError::MissingCargoToml => Some(BrokenReason::CargoToml),
PrepareError::InvalidCargoTomlSyntax => Some(BrokenReason::CargoToml),
PrepareError::YankedDependencies => Some(BrokenReason::Yanked),
PrepareError::PrivateGitRepository => {
Some(BrokenReason::MissingGitRepository)
}
_ => None,
}
}
if reason.is_some() {
break;
}
break;
}
if let Some(reason) = reason {
Err(err
Expand Down
24 changes: 24 additions & 0 deletions tests/minicrater/missing-repo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[server.bot-acl]
rust-teams = true
github = ["pietroalbini"]

[server.labels]
remove = "^S-"
experiment-queued = "S-waiting-on-crater"
experiment-completed = "S-waiting-on-review"

[demo-crates]
crates = []
github-repos = []
local-crates = []

[sandbox]
memory-limit = "512M"
build-log-max-size = "2M"
build-log-max-lines = 1000

[crates]

[github-repos]

[local-crates]
19 changes: 19 additions & 0 deletions tests/minicrater/missing-repo/results.expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"crates": [
{
"name": "ghost.missing",
"res": "broken",
"runs": [
{
"log": "stable/gh/ghost.missing",
"res": "broken:missing-git-repository"
},
{
"log": "beta/gh/ghost.missing",
"res": "broken:missing-git-repository"
}
],
"url": "https://github.com/ghost/missing"
}
]
}
6 changes: 6 additions & 0 deletions tests/minicrater/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ minicrater! {
..Default::default()
},

single_thread_missing_repo {
ex: "missing-repo",
crate_select: "dummy",
..Default::default()
},

#[cfg(not(windows))] // `State.OOMKilled` is not set on Windows
resource_exhaustion {
ex: "resource-exhaustion",
Expand Down