Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fa2c21ec8c06
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dd33b2765488
Choose a head ref
  • 2 commits
  • 15 files changed
  • 1 contributor

Commits on Apr 14, 2019

  1. Revert "Evaluation Stats"

    grahamc authored Apr 14, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6c21ae9 View commit details
  2. Merge pull request #353 from NixOS/revert-351-stats

    Revert "Evaluation Stats"
    grahamc authored Apr 14, 2019
    Copy the full SHA
    dd33b27 View commit details
7 changes: 0 additions & 7 deletions ofborg/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions ofborg/Cargo.nix
Original file line number Diff line number Diff line change
@@ -123,7 +123,6 @@ let crates = cratesIO // rec {
(cratesIO.crates."lru_cache"."${deps."ofborg"."0.1.8"."lru_cache"}" deps)
(cratesIO.crates."md5"."${deps."ofborg"."0.1.8"."md5"}" deps)
(cratesIO.crates."nom"."${deps."ofborg"."0.1.8"."nom"}" deps)
(cratesIO.crates."separator"."${deps."ofborg"."0.1.8"."separator"}" deps)
(cratesIO.crates."serde"."${deps."ofborg"."0.1.8"."serde"}" deps)
(cratesIO.crates."serde_derive"."${deps."ofborg"."0.1.8"."serde_derive"}" deps)
(cratesIO.crates."serde_json"."${deps."ofborg"."0.1.8"."serde_json"}" deps)
@@ -146,7 +145,6 @@ let crates = cratesIO // rec {
md5."${deps.ofborg."0.1.8".md5}".default = true;
nom."${deps.ofborg."0.1.8".nom}".default = true;
ofborg."0.1.8".default = (f.ofborg."0.1.8".default or true);
separator."${deps.ofborg."0.1.8".separator}".default = true;
serde."${deps.ofborg."0.1.8".serde}".default = true;
serde_derive."${deps.ofborg."0.1.8".serde_derive}".default = true;
serde_json."${deps.ofborg."0.1.8".serde_json}".default = true;
@@ -169,7 +167,6 @@ let crates = cratesIO // rec {
(cratesIO.features_.lru_cache."${deps."ofborg"."0.1.8"."lru_cache"}" deps)
(cratesIO.features_.md5."${deps."ofborg"."0.1.8"."md5"}" deps)
(cratesIO.features_.nom."${deps."ofborg"."0.1.8"."nom"}" deps)
(cratesIO.features_.separator."${deps."ofborg"."0.1.8"."separator"}" deps)
(cratesIO.features_.serde."${deps."ofborg"."0.1.8"."serde"}" deps)
(cratesIO.features_.serde_derive."${deps."ofborg"."0.1.8"."serde_derive"}" deps)
(cratesIO.features_.serde_json."${deps."ofborg"."0.1.8"."serde_json"}" deps)
@@ -378,7 +375,6 @@ rec {
lru_cache = "0.1.1";
md5 = "0.3.8";
nom = "4.1.1";
separator = "0.4.1";
serde = "1.0.84";
serde_derive = "1.0.84";
serde_json = "1.0.34";
@@ -463,7 +459,6 @@ rec {
core_foundation_sys = "0.2.3";
libc = "0.2.46";
};
deps.separator."0.4.1" = {};
deps.serde."1.0.84" = {};
deps.serde_derive."1.0.84" = {
proc_macro2 = "0.4.24";
1 change: 0 additions & 1 deletion ofborg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ lru-cache = "0.1.1"
nom = "4.0.0-beta3"
sys-info = "0.5.6"
chrono = "0.4.6"
separator = "0.4.1"

[patch.crates-io]
#hubcaps = { path = "../hubcaps" }
1 change: 0 additions & 1 deletion ofborg/crates-io.list
Original file line number Diff line number Diff line change
@@ -73,7 +73,6 @@ safemem-0.3.0
schannel-0.1.14
security-framework-0.1.16
security-framework-sys-0.1.16
separator-0.4.1
serde-1.0.84
serde_derive-1.0.84
serde_json-1.0.34
14 changes: 0 additions & 14 deletions ofborg/crates-io.nix
Original file line number Diff line number Diff line change
@@ -2118,20 +2118,6 @@ rec {
];


# end
# separator-0.4.1

crates.separator."0.4.1" = deps: { features?(features_.separator."0.4.1" deps {}) }: buildRustCrate {
crateName = "separator";
version = "0.4.1";
authors = [ "Saghm Rossi <saghmrossi@gmail.com>" ];
sha256 = "1l7yhf6dy09k9cy0kkwb9wy98rn8mnz72q27wbd6bhiflllwghr7";
};
features_.separator."0.4.1" = deps: f: updateFeatures f (rec {
separator."0.4.1".default = (f.separator."0.4.1".default or true);
}) [];


# end
# serde-1.0.84

1 change: 0 additions & 1 deletion ofborg/src/bin/mass-rebuilder.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,6 @@ fn main() {
cloner,
&nix,
cfg.github(),
cfg.github_app_vendingmachine(),
cfg.acl(),
cfg.runner.identity.clone(),
events,
3 changes: 0 additions & 3 deletions ofborg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ extern crate hyper;
extern crate hyper_native_tls;
extern crate lru_cache;
extern crate md5;
extern crate separator;
extern crate tempfile;
extern crate uuid;

@@ -48,8 +47,6 @@ pub mod locks;
pub mod maintainers;
pub mod message;
pub mod nix;
pub mod nixenv;
pub mod nixstats;
pub mod notifyworker;
pub mod outpathdiff;
pub mod stats;
85 changes: 37 additions & 48 deletions ofborg/src/nix.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ use ofborg::asynccmd::{AsyncCmd, SpawnedAsyncCmd};
use ofborg::partition_result;
use std::collections::HashMap;
use std::env;
use std::ffi::OsStr;
use std::fmt;
use std::fs;
use std::io::BufRead;
@@ -162,7 +161,7 @@ impl Nix {
file: File,
attrs: Vec<String>,
) -> Result<fs::File, fs::File> {
let mut command = self.safe_command::<&OsStr>(&Operation::Instantiate, nixpkgs, &[], &[]);
let mut command = self.safe_command(&Operation::Instantiate, nixpkgs, vec![], &[]);
self.set_attrs_command(&mut command, file, attrs);
self.run(command, true)
}
@@ -183,7 +182,7 @@ impl Nix {
attrargs.push(argstr.to_owned());
}

self.safe_command(&Operation::Evaluate, nixpkgs, &attrargs, &extra_paths)
self.safe_command(&Operation::Evaluate, nixpkgs, attrargs, &extra_paths)
}

pub fn safely_build_attrs(
@@ -192,7 +191,7 @@ impl Nix {
file: File,
attrs: Vec<String>,
) -> Result<fs::File, fs::File> {
let mut command = self.safe_command::<&OsStr>(&Operation::Build, nixpkgs, &[], &[]);
let mut command = self.safe_command(&Operation::Build, nixpkgs, vec![], &[]);
self.set_attrs_command(&mut command, file, attrs);
self.run(command, true)
}
@@ -203,7 +202,7 @@ impl Nix {
file: File,
attrs: Vec<String>,
) -> SpawnedAsyncCmd {
let mut command = self.safe_command::<&OsStr>(&Operation::Build, nixpkgs, &[], &[]);
let mut command = self.safe_command(&Operation::Build, nixpkgs, vec![], &[]);
self.set_attrs_command(&mut command, file, attrs);
AsyncCmd::new(command).spawn()
}
@@ -232,7 +231,7 @@ impl Nix {
args: Vec<String>,
keep_stdout: bool,
) -> Result<fs::File, fs::File> {
self.run(self.safe_command(&op, nixpkgs, &args, &[]), keep_stdout)
self.run(self.safe_command(&op, nixpkgs, args, &[]), keep_stdout)
}

pub fn run(&self, mut cmd: Command, keep_stdout: bool) -> Result<fs::File, fs::File> {
@@ -262,43 +261,13 @@ impl Nix {
}
}

pub fn run_stderr_stdout(&self, mut cmd: Command) -> (bool, fs::File, fs::File) {
let stdout_file = tempfile().expect("Fetching a stdout tempfile");
let mut stdout_reader = stdout_file
.try_clone()
.expect("Cloning stdout to the reader");

let stderr_file = tempfile().expect("Fetching a stderr tempfile");
let mut stderr_reader = stderr_file
.try_clone()
.expect("Cloning stderr to the reader");

let status = cmd
.stdout(Stdio::from(stdout_file))
.stderr(Stdio::from(stderr_file))
.status()
.expect("Running a program ...");

stdout_reader
.seek(SeekFrom::Start(0))
.expect("Seeking dout to Start(0)");
stderr_reader
.seek(SeekFrom::Start(0))
.expect("Seeking stderr to Start(0)");

(status.success(), stdout_reader, stderr_reader)
}

pub fn safe_command<S>(
pub fn safe_command(
&self,
op: &Operation,
nixpkgs: &Path,
args: &[S],
args: Vec<String>,
safe_paths: &[&Path],
) -> Command
where
S: AsRef<OsStr>,
{
) -> Command {
let nixpkgspath = format!("nixpkgs={}", nixpkgs.display());
let mut nixpath: Vec<String> = safe_paths
.iter()
@@ -493,7 +462,12 @@ mod tests {
assert_eq!(op.to_string(), "nix-build");

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command(&op, build_path().as_path(), &["--version"], &[]),
nix.safe_command(
&op,
build_path().as_path(),
vec![String::from("--version")],
&[],
),
true,
);

@@ -511,7 +485,12 @@ mod tests {
assert_eq!(op.to_string(), "nix-instantiate");

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command(&op, build_path().as_path(), &["--version"], &[]),
nix.safe_command(
&op,
build_path().as_path(),
vec![String::from("--version")],
&[],
),
true,
);

@@ -525,7 +504,12 @@ mod tests {
assert_eq!(op.to_string(), "nix-env -qa --json");

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command(&op, build_path().as_path(), &["--version"], &[]),
nix.safe_command(
&op,
build_path().as_path(),
vec![String::from("--version")],
&[],
),
true,
);

@@ -543,7 +527,12 @@ mod tests {
assert_eq!(op.to_string(), "nix-env -qaP --no-name --out-path");

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command(&op, build_path().as_path(), &["--version"], &[]),
nix.safe_command(
&op,
build_path().as_path(),
vec![String::from("--version")],
&[],
),
true,
);

@@ -562,7 +551,7 @@ mod tests {
let nix = nix();

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command::<&OsStr>(&env_noop(), build_path().as_path(), &[], &[]),
nix.safe_command(&env_noop(), build_path().as_path(), vec![], &[]),
true,
);

@@ -589,7 +578,7 @@ mod tests {
);

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command::<&OsStr>(&env_noop(), build_path().as_path(), &[], &[]),
nix.safe_command(&env_noop(), build_path().as_path(), vec![], &[]),
true,
);

@@ -612,7 +601,7 @@ mod tests {
let op = noop(Operation::Build);

let ret: Result<fs::File, fs::File> = nix.run(
nix.safe_command::<&OsStr>(&op, build_path().as_path(), &[], &[]),
nix.safe_command(&op, build_path().as_path(), vec![], &[]),
true,
);

@@ -628,7 +617,7 @@ mod tests {
let nix = nix();
let op = noop(Operation::Build);

let mut command = nix.safe_command::<&OsStr>(&op, build_path().as_path(), &[], &[]);
let mut command = nix.safe_command(&op, build_path().as_path(), vec![], &[]);
nix.set_attrs_command(
&mut command,
File::DefaultNixpkgs,
@@ -645,7 +634,7 @@ mod tests {
let nix = nix();
let op = noop(Operation::Instantiate);

let mut command = nix.safe_command::<&OsStr>(&op, build_path().as_path(), &[], &[]);
let mut command = nix.safe_command(&op, build_path().as_path(), vec![], &[]);
nix.set_attrs_command(
&mut command,
File::ReleaseNixOS,
117 changes: 0 additions & 117 deletions ofborg/src/nixenv.rs

This file was deleted.

549 changes: 0 additions & 549 deletions ofborg/src/nixstats.rs

This file was deleted.

146 changes: 112 additions & 34 deletions ofborg/src/outpathdiff.rs
Original file line number Diff line number Diff line change
@@ -1,57 +1,66 @@
use crate::nixenv::Error as NixEnvError;
use crate::nixenv::HydraNixEnv;
use crate::nixstats::{EvaluationStats, EvaluationStatsDiff};
extern crate amqp;
extern crate env_logger;

use ofborg::nix;
use std::collections::{HashMap, HashSet};
use std::fs;
use std::fs::File;
use std::io::BufRead;

use std::io::BufReader;
use std::io::Write;
use std::path::PathBuf;

pub struct OutPathDiff {
calculator: HydraNixEnv,
pub original: Option<(PackageOutPaths, EvaluationStats)>,
pub current: Option<(PackageOutPaths, EvaluationStats)>,
calculator: OutPaths,
pub original: Option<PackageOutPaths>,
pub current: Option<PackageOutPaths>,
}

impl OutPathDiff {
pub fn new(nix: nix::Nix, path: PathBuf) -> OutPathDiff {
OutPathDiff {
calculator: HydraNixEnv::new(nix, path, false),
calculator: OutPaths::new(nix, path, false),
original: None,
current: None,
}
}

pub fn find_before(&mut self) -> Result<(), NixEnvError> {
self.original = Some(self.run()?);
Ok(())
pub fn find_before(&mut self) -> Result<bool, File> {
let x = self.run();
match x {
Ok(f) => {
self.original = Some(f);
Ok(true)
}
Err(e) => {
info!("Failed to find Before list");
Err(e)
}
}
}

pub fn find_after(&mut self) -> Result<(), NixEnvError> {
if self.original.is_none() {
pub fn find_after(&mut self) -> Result<bool, File> {
if self.original == None {
debug!("Before is None, not bothering with After");
return Ok(());
return Ok(false);
}

self.current = Some(self.run()?);
Ok(())
}

pub fn performance_diff(&self) -> Option<EvaluationStatsDiff> {
if let Some((_, ref cur)) = self.current {
if let Some((_, ref orig)) = self.original {
Some(EvaluationStatsDiff::compare(orig, cur))
} else {
None
let x = self.run();
match x {
Ok(f) => {
self.current = Some(f);
Ok(true)
}
Err(e) => {
info!("Failed to find After list");
Err(e)
}
} else {
None
}
}

pub fn package_diff(&self) -> Option<(Vec<PackageArch>, Vec<PackageArch>)> {
if let Some((ref cur, _)) = self.current {
if let Some((ref orig, _)) = self.original {
if let Some(ref cur) = self.current {
if let Some(ref orig) = self.original {
let orig_set: HashSet<&PackageArch> = orig.keys().collect();
let cur_set: HashSet<&PackageArch> = cur.keys().collect();

@@ -75,8 +84,8 @@ impl OutPathDiff {
pub fn calculate_rebuild(&self) -> Option<Vec<PackageArch>> {
let mut rebuild: Vec<PackageArch> = vec![];

if let Some((ref cur, _)) = self.current {
if let Some((ref orig, _)) = self.original {
if let Some(ref cur) = self.current {
if let Some(ref orig) = self.original {
for key in cur.keys() {
trace!("Checking out {:?}", key);
if cur.get(key) != orig.get(key) {
@@ -94,12 +103,12 @@ impl OutPathDiff {
None
}

fn run(&mut self) -> Result<(PackageOutPaths, EvaluationStats), NixEnvError> {
self.calculator.execute()
fn run(&mut self) -> Result<PackageOutPaths, File> {
self.calculator.find()
}
}

pub type PackageOutPaths = HashMap<PackageArch, OutPath>;
type PackageOutPaths = HashMap<PackageArch, OutPath>;

#[derive(Debug, PartialEq, Hash, Eq, Clone)]
pub struct PackageArch {
@@ -110,7 +119,76 @@ type Package = String;
type Architecture = String;
type OutPath = String;

pub fn parse_lines(data: &mut BufRead) -> PackageOutPaths {
pub struct OutPaths {
path: PathBuf,
nix: nix::Nix,
check_meta: bool,
}

impl OutPaths {
pub fn new(nix: nix::Nix, path: PathBuf, check_meta: bool) -> OutPaths {
OutPaths {
nix,
path,
check_meta,
}
}

pub fn find(&self) -> Result<PackageOutPaths, File> {
self.run()
}

fn run(&self) -> Result<PackageOutPaths, File> {
self.place_nix();
let ret = self.execute();
self.remove_nix();

match ret {
Ok(file) => Ok(parse_lines(&mut BufReader::new(file))),
Err(e) => Err(e),
}
}

fn place_nix(&self) {
let mut file = File::create(self.nix_path()).expect("Failed to create nix out path check");
file.write_all(include_bytes!("outpaths.nix"))
.expect("Failed to place outpaths.nix");
}

fn remove_nix(&self) {
fs::remove_file(self.nix_path()).expect("Failed to delete outpaths.nix");
}

fn nix_path(&self) -> PathBuf {
let mut dest = self.path.clone();
dest.push(".gc-of-borg-outpaths.nix");

dest
}

fn execute(&self) -> Result<File, File> {
let check_meta: String = if self.check_meta {
String::from("true")
} else {
String::from("false")
};

self.nix.safely(
&nix::Operation::QueryPackagesOutputs,
&self.path,
vec![
String::from("-f"),
String::from(".gc-of-borg-outpaths.nix"),
String::from("--arg"),
String::from("checkMeta"),
check_meta,
],
true,
)
}
}

fn parse_lines(data: &mut BufRead) -> PackageOutPaths {
data.lines()
.filter_map(|line| match line {
Ok(line) => Some(line),
7 changes: 4 additions & 3 deletions ofborg/src/tasks/eval/generic.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use ofborg::checkout::CachedProjectCo;
use ofborg::commitstatus::CommitStatus;
use ofborg::evalchecker::EvalChecker;
use ofborg::message::buildjob::BuildJob;
use std::path::Path;
use tasks::eval::{EvaluationComplete, EvaluationStrategy, StepResult};
use tasks::eval::{EvaluationStrategy, StepResult};

#[derive(Default)]
pub struct GenericStrategy {}
@@ -39,7 +40,7 @@ impl EvaluationStrategy for GenericStrategy {
&mut self,
_co: &Path,
_status: &mut CommitStatus,
) -> StepResult<EvaluationComplete> {
Ok(Default::default())
) -> StepResult<Vec<BuildJob>> {
Ok(vec![])
}
}
10 changes: 1 addition & 9 deletions ofborg/src/tasks/eval/mod.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ mod nixpkgs;
pub use self::nixpkgs::NixpkgsStrategy;
mod generic;
pub use self::generic::GenericStrategy;
use hubcaps::checks::CheckRunOptions;
use ofborg::checkout::CachedProjectCo;
use ofborg::commitstatus::CommitStatus;
use ofborg::evalchecker::EvalChecker;
@@ -13,7 +12,6 @@ use std::path::Path;

pub trait EvaluationStrategy {
fn pre_clone(&mut self) -> StepResult<()>;

fn on_target_branch(&mut self, co: &Path, status: &mut CommitStatus) -> StepResult<()>;
fn after_fetch(&mut self, co: &CachedProjectCo) -> StepResult<()>;
fn merge_conflict(&mut self);
@@ -23,17 +21,11 @@ pub trait EvaluationStrategy {
&mut self,
co: &Path,
status: &mut CommitStatus,
) -> StepResult<EvaluationComplete>;
) -> StepResult<Vec<BuildJob>>;
}

pub type StepResult<T> = Result<T, Error>;

#[derive(Default)]
pub struct EvaluationComplete {
pub builds: Vec<BuildJob>,
pub checks: Vec<CheckRunOptions>,
}

#[derive(Debug)]
pub enum Error {
Fail(String),
64 changes: 17 additions & 47 deletions ofborg/src/tasks/eval/nixpkgs.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
use crate::maintainers;
use crate::maintainers::ImpactedMaintainers;
use crate::nixenv::HydraNixEnv;
use chrono::Utc;
use hubcaps::checks::{CheckRunOptions, CheckRunState, Conclusion, Output};
use hubcaps::gists::Gists;
use hubcaps::issues::{Issue, IssueRef};
use hubcaps::repositories::Repository;
use ofborg::checkout::CachedProjectCo;
use ofborg::commentparser::Subset;
use ofborg::commitstatus::CommitStatus;
use ofborg::evalchecker::EvalChecker;
use ofborg::files::file_to_str;
use ofborg::message::buildjob::BuildJob;
use ofborg::message::evaluationjob::EvaluationJob;
use ofborg::nix;
use ofborg::nix::Nix;
use ofborg::outpathdiff::{OutPathDiff, PackageArch};
use ofborg::outpathdiff::{OutPathDiff, OutPaths, PackageArch};
use ofborg::tagger::{MaintainerPRTagger, PathsTagger, RebuildTagger};
use ofborg::tagger::{PkgsAddedRemovedTagger, StdenvTagger};
use ofborg::tasks::eval::{
stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult,
};
use ofborg::tasks::eval::{stdenvs::Stdenvs, Error, EvaluationStrategy, StepResult};
use ofborg::tasks::evaluate::update_labels;
use std::collections::HashMap;
use std::path::Path;
@@ -129,7 +125,7 @@ impl<'a> NixpkgsStrategy<'a> {
fn check_outpaths_before(&mut self, dir: &Path) -> StepResult<()> {
let mut rebuildsniff = OutPathDiff::new(self.nix.clone(), dir.to_path_buf());

if let Err(err) = rebuildsniff.find_before() {
if let Err(mut output) = rebuildsniff.find_before() {
/*
self.events
.notify(Event::TargetBranchFailsEvaluation(target_branch.clone()));
@@ -138,7 +134,7 @@ impl<'a> NixpkgsStrategy<'a> {
Err(Error::FailWithGist(
String::from("The branch this PR will merge in to does not evaluate, and so this PR cannot be checked."),
String::from("Output path comparison"),
err.display(),
file_to_str(&mut output),
))
} else {
self.outpath_diff = Some(rebuildsniff);
@@ -148,11 +144,11 @@ impl<'a> NixpkgsStrategy<'a> {

fn check_outpaths_after(&mut self) -> StepResult<()> {
if let Some(ref mut rebuildsniff) = self.outpath_diff {
if let Err(mut err) = rebuildsniff.find_after() {
if let Err(mut output) = rebuildsniff.find_after() {
Err(Error::FailWithGist(
String::from("This PR breaks listing of package outputs after merging."),
String::from("Output path comparison"),
err.display(),
file_to_str(&mut output),
))
} else {
Ok(())
@@ -164,34 +160,6 @@ impl<'a> NixpkgsStrategy<'a> {
}
}

fn performance_stats(&self) -> Vec<CheckRunOptions> {
if let Some(ref rebuildsniff) = self.outpath_diff {
if let Some(report) = rebuildsniff.performance_diff() {
return vec![CheckRunOptions {
name: "Evaluation Performance Report".to_owned(),
actions: None,
completed_at: Some(
Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
),
started_at: None,
conclusion: Some(Conclusion::Success),
status: Some(CheckRunState::Completed),
details_url: None,
external_id: None,
head_sha: self.job.pr.head_sha.clone(),
output: Some(Output {
title: "Evaluator Performance Report".to_string(),
summary: "".to_string(),
text: Some(report.markdown()),
annotations: None,
images: None,
}),
}];
}
}
vec![]
}

fn update_new_package_labels(&self) {
if let Some(ref rebuildsniff) = self.outpath_diff {
if let Some((removed, added)) = rebuildsniff.package_diff() {
@@ -298,11 +266,10 @@ impl<'a> NixpkgsStrategy<'a> {
);
status.set(hubcaps::statuses::State::Pending);

let nixenv = HydraNixEnv::new(self.nix.clone(), dir.to_path_buf(), true);
match nixenv.execute() {
let checker = OutPaths::new(self.nix.clone(), dir.to_path_buf(), true);
match checker.find() {
Ok(pkgs) => {
let mut try_build: Vec<String> = pkgs
.0
.keys()
.map(|pkgarch| pkgarch.package.clone())
.filter(|pkg| possibly_touched_packages.contains(&pkg))
@@ -332,7 +299,12 @@ impl<'a> NixpkgsStrategy<'a> {
}
}
Err(mut out) => {
status.set_url(make_gist(&self.gists, "Meta Check", None, out.display()));
status.set_url(make_gist(
&self.gists,
"Meta Check",
None,
file_to_str(&mut out),
));
status.set(hubcaps::statuses::State::Failure);
Err(Error::Fail(String::from(
"Failed to validate package metadata.",
@@ -511,7 +483,7 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
&mut self,
dir: &Path,
status: &mut CommitStatus,
) -> StepResult<EvaluationComplete> {
) -> StepResult<Vec<BuildJob>> {
self.update_stdenv_labels();

status.set_with_description(
@@ -521,10 +493,8 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {

self.update_new_package_labels();
self.update_rebuild_labels(&dir, status);
let checks = self.performance_stats();

let builds = self.check_meta_queue_builds(&dir)?;
Ok(EvaluationComplete { builds, checks })
self.check_meta_queue_builds(&dir)
}
}

86 changes: 27 additions & 59 deletions ofborg/src/tasks/evaluate.rs
Original file line number Diff line number Diff line change
@@ -4,13 +4,11 @@ extern crate env_logger;
extern crate uuid;
use amqp::protocol::basic::{BasicProperties, Deliver};
use hubcaps;
use hubcaps::checks::CheckRunOptions;
use hubcaps::gists::Gists;
use hubcaps::issues::Issue;
use ofborg::acl::ACL;
use ofborg::checkout;
use ofborg::commitstatus::CommitStatus;
use ofborg::config::GithubAppVendingMachine;
use ofborg::files::file_to_str;
use ofborg::message::{buildjob, evaluationjob};
use ofborg::nix;
@@ -20,7 +18,6 @@ use ofborg::systems;
use ofborg::worker;
use std::collections::HashMap;
use std::path::Path;
use std::sync::RwLock;
use std::time::Instant;
use tasks::eval;
use tasks::eval::StepResult;
@@ -29,20 +26,17 @@ pub struct EvaluationWorker<E> {
cloner: checkout::CachedCloner,
nix: nix::Nix,
github: hubcaps::Github,
github_vend: RwLock<GithubAppVendingMachine>,
acl: ACL,
identity: String,
events: E,
tag_paths: HashMap<String, Vec<String>>,
}

impl<E: stats::SysEvents> EvaluationWorker<E> {
#[allow(clippy::too_many_arguments)]
pub fn new(
cloner: checkout::CachedCloner,
nix: &nix::Nix,
github: hubcaps::Github,
github_vend: GithubAppVendingMachine,
acl: ACL,
identity: String,
events: E,
@@ -52,7 +46,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
cloner,
nix: nix.without_limited_supported_systems(),
github,
github_vend: RwLock::new(github_vend),
acl,
identity,
events,
@@ -113,14 +106,9 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
}

fn consumer(&mut self, job: &evaluationjob::EvaluationJob) -> worker::Actions {
let mut vending_machine = self
.github_vend
.write()
.expect("Failed to get write lock on github vending machine");
let github_client = vending_machine
.for_repo(&job.repo.owner, &job.repo.name)
.expect("Failed to get a github client token");
let repo = github_client.repo(job.repo.owner.clone(), job.repo.name.clone());
let repo = self
.github
.repo(job.repo.owner.clone(), job.repo.name.clone());
let gists = self.github.gists();
let pulls = repo.pulls();
let pull = pulls.get(job.pr.number);
@@ -332,9 +320,30 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
let ret = evaluation_strategy
.all_evaluations_passed(&Path::new(&refpath), &mut overall_status);
match ret {
Ok(complete) => {
send_check_statuses(complete.checks, &repo);
response.extend(schedule_builds(complete.builds, auto_schedule_build_archs));
Ok(builds) => {
info!(
"Scheduling build jobs {:#?} on arches {:#?}",
builds, auto_schedule_build_archs
);
for buildjob in builds {
for arch in auto_schedule_build_archs.iter() {
let (exchange, routingkey) = arch.as_build_destination();
response.push(worker::publish_serde_action(
exchange, routingkey, &buildjob,
));
}
response.push(worker::publish_serde_action(
Some("build-results".to_string()),
None,
&buildjob::QueuedBuildJobs {
job: buildjob,
architectures: auto_schedule_build_archs
.iter()
.map(|arch| arch.to_string())
.collect(),
},
));
}
}
Err(e) => {
info!("Failed after all the evaluations passed");
@@ -362,47 +371,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
}
}

fn send_check_statuses(checks: Vec<CheckRunOptions>, repo: &hubcaps::repositories::Repository) {
for check in checks {
match repo.checkruns().create(&check) {
Ok(_) => info!("Sent check update"),
Err(e) => info!("Failed to send check update: {:?}", e),
}
}
}

fn schedule_builds(
builds: Vec<buildjob::BuildJob>,
auto_schedule_build_archs: Vec<systems::System>,
) -> Vec<worker::Action> {
let mut response = vec![];
info!(
"Scheduling build jobs {:#?} on arches {:#?}",
builds, auto_schedule_build_archs
);
for buildjob in builds {
for arch in auto_schedule_build_archs.iter() {
let (exchange, routingkey) = arch.as_build_destination();
response.push(worker::publish_serde_action(
exchange, routingkey, &buildjob,
));
}
response.push(worker::publish_serde_action(
Some("build-results".to_string()),
None,
&buildjob::QueuedBuildJobs {
job: buildjob,
architectures: auto_schedule_build_archs
.iter()
.map(|arch| arch.to_string())
.collect(),
},
));
}

response
}

pub fn make_gist<'a>(
gists: &hubcaps::gists::Gists<'a>,
name: &str,