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: a7a4152c153d
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2bebc96be256
Choose a head ref
  • 5 commits
  • 6 files changed
  • 1 contributor

Commits on Apr 14, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d297515 View commit details
  2. Publish evaluation erports

    grahamc committed Apr 14, 2019
    Copy the full SHA
    289dba8 View commit details
  3. fixup: nixenv stdout/stderr

    grahamc committed Apr 14, 2019
    Copy the full SHA
    bc943c2 View commit details
  4. send completed_at time

    grahamc committed Apr 14, 2019
    Copy the full SHA
    4f036ec View commit details
  5. fmt

    grahamc committed Apr 14, 2019
    Copy the full SHA
    2bebc96 View commit details
Showing with 110 additions and 36 deletions.
  1. +1 −0 ofborg/src/bin/mass-rebuilder.rs
  2. +1 −1 ofborg/src/nixenv.rs
  3. +3 −4 ofborg/src/tasks/eval/generic.rs
  4. +9 −1 ofborg/src/tasks/eval/mod.rs
  5. +37 −3 ofborg/src/tasks/eval/nixpkgs.rs
  6. +59 −27 ofborg/src/tasks/evaluate.rs
1 change: 1 addition & 0 deletions ofborg/src/bin/mass-rebuilder.rs
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ fn main() {
cloner,
&nix,
cfg.github(),
cfg.github_app_vendingmachine(),
cfg.acl(),
cfg.runner.identity.clone(),
events,
2 changes: 1 addition & 1 deletion ofborg/src/nixenv.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ impl HydraNixEnv {
let (status, stdout, mut stderr) = self.run_nix_env();
self.remove_nix()?;

if status {
if !status {
Err(Error::Fd(stderr))
} else if let Ok(stats) = serde_json::from_reader(&mut stderr) {
let outpaths = outpathdiff::parse_lines(&mut BufReader::new(stdout));
7 changes: 3 additions & 4 deletions ofborg/src/tasks/eval/generic.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use ofborg::checkout::CachedProjectCo;
use ofborg::commitstatus::CommitStatus;
use ofborg::evalchecker::EvalChecker;
use ofborg::message::buildjob::BuildJob;
use std::path::Path;
use tasks::eval::{EvaluationStrategy, StepResult};
use tasks::eval::{EvaluationComplete, EvaluationStrategy, StepResult};

#[derive(Default)]
pub struct GenericStrategy {}
@@ -40,7 +39,7 @@ impl EvaluationStrategy for GenericStrategy {
&mut self,
_co: &Path,
_status: &mut CommitStatus,
) -> StepResult<Vec<BuildJob>> {
Ok(vec![])
) -> StepResult<EvaluationComplete> {
Ok(Default::default())
}
}
10 changes: 9 additions & 1 deletion ofborg/src/tasks/eval/mod.rs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ 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;
@@ -12,6 +13,7 @@ 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);
@@ -21,11 +23,17 @@ pub trait EvaluationStrategy {
&mut self,
co: &Path,
status: &mut CommitStatus,
) -> StepResult<Vec<BuildJob>>;
) -> StepResult<EvaluationComplete>;
}

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),
40 changes: 37 additions & 3 deletions ofborg/src/tasks/eval/nixpkgs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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;
@@ -15,7 +17,9 @@ use ofborg::nix::Nix;
use ofborg::outpathdiff::{OutPathDiff, PackageArch};
use ofborg::tagger::{MaintainerPRTagger, PathsTagger, RebuildTagger};
use ofborg::tagger::{PkgsAddedRemovedTagger, StdenvTagger};
use ofborg::tasks::eval::{stdenvs::Stdenvs, Error, EvaluationStrategy, StepResult};
use ofborg::tasks::eval::{
stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult,
};
use ofborg::tasks::evaluate::update_labels;
use std::collections::HashMap;
use std::path::Path;
@@ -160,6 +164,34 @@ 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() {
@@ -479,7 +511,7 @@ impl<'a> EvaluationStrategy for NixpkgsStrategy<'a> {
&mut self,
dir: &Path,
status: &mut CommitStatus,
) -> StepResult<Vec<BuildJob>> {
) -> StepResult<EvaluationComplete> {
self.update_stdenv_labels();

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

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

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

86 changes: 59 additions & 27 deletions ofborg/src/tasks/evaluate.rs
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@ 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;
@@ -18,6 +20,7 @@ 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;
@@ -26,17 +29,20 @@ 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,
@@ -46,6 +52,7 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
cloner,
nix: nix.without_limited_supported_systems(),
github,
github_vend: RwLock::new(github_vend),
acl,
identity,
events,
@@ -106,9 +113,14 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
}

fn consumer(&mut self, job: &evaluationjob::EvaluationJob) -> worker::Actions {
let repo = self
.github
.repo(job.repo.owner.clone(), job.repo.name.clone());
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 gists = self.github.gists();
let pulls = repo.pulls();
let pull = pulls.get(job.pr.number);
@@ -320,30 +332,9 @@ 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(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(),
},
));
}
Ok(complete) => {
send_check_statuses(complete.checks, &repo);
response.extend(schedule_builds(complete.builds, auto_schedule_build_archs));
}
Err(e) => {
info!("Failed after all the evaluations passed");
@@ -371,6 +362,47 @@ 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,