Merge pull request #436 from andir/update-nixpkgs

Update to current nixpkgs-unstable
This commit is contained in:
Graham Christensen 2020-03-03 19:26:37 -05:00 committed by GitHub
commit ea4b7f8aab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 157 additions and 132 deletions

View file

@ -1,4 +1,4 @@
{ pkgs ? import ./nix {} }: { pkgs ? import ./nix { overlays = [ (import ./nix/overlay.nix) ]; } }:
let let
ofborgOverrides = { ofborgOverrides = {

View file

@ -1,7 +1,7 @@
{ {
"url": "https://github.com/nixos/nixpkgs-channels.git", "url": "https://github.com/nixos/nixpkgs-channels.git",
"rev": "201d739b0ffbebceb444864d1856babcd1a666a8", "rev": "e2b4abe3c8f2e09adfc6a52007841d1b96c89371",
"date": "2018-12-30T01:29:37+00:00", "date": "2020-02-19T01:57:21+01:00",
"sha256": "0mfkzmylglpw84w85zs3djpspcx45bg3s62hk4j44dxl2p0fvggj", "sha256": "1l3jfr74s7wmx3fk5y76ayazbfclvnr532kg1hypbzydp3n372rz",
"fetchSubmodules": false "fetchSubmodules": false
} }

12
nix/overlay.nix Normal file
View file

@ -0,0 +1,12 @@
(self: super: {
defaultCrateOverrides = super.defaultCrateOverrides // {
openssl-sys = attrs: {
buildInputs = [ self.openssl_1_0_2 ];
nativeBuildInputs = [ self.pkgconfig ];
};
openssl = attrs: {
DEP_OPENSSL_VERSION = "102";
};
};
})

View file

@ -11,46 +11,46 @@ enum MetricType {
impl MetricType { impl MetricType {
fn collector_type(&self) -> String { fn collector_type(&self) -> String {
match self { match self {
&MetricType::Ticker(_) => String::from("u64"), MetricType::Ticker(_) => String::from("u64"),
&MetricType::Counter(_) => String::from("u64"), MetricType::Counter(_) => String::from("u64"),
} }
} }
fn enum_matcher_types(&self) -> String { fn enum_matcher_types(&self) -> String {
let fields = self.enum_field_types(); let fields = self.enum_field_types();
if fields.len() > 0 { if !fields.is_empty() {
format!("{}({})", self.variant(), fields.join(", ")) format!("{}({})", self.variant(), fields.join(", "))
} else { } else {
format!("{}", self.variant()) self.variant()
} }
} }
fn variant(&self) -> String { fn variant(&self) -> String {
match self { match self {
&MetricType::Ticker(ref event) => event.variant.clone(), MetricType::Ticker(ref event) => event.variant.clone(),
&MetricType::Counter(ref event) => event.variant.clone(), MetricType::Counter(ref event) => event.variant.clone(),
} }
} }
fn metric_type(&self) -> String { fn metric_type(&self) -> String {
match self { match self {
&MetricType::Ticker(_) => String::from("counter"), MetricType::Ticker(_) => String::from("counter"),
&MetricType::Counter(_) => String::from("counter"), MetricType::Counter(_) => String::from("counter"),
} }
} }
fn metric_name(&self) -> String { fn metric_name(&self) -> String {
match self { match self {
&MetricType::Ticker(ref event) => event.metric_name.clone(), MetricType::Ticker(ref event) => event.metric_name.clone(),
&MetricType::Counter(ref event) => event.metric_name.clone(), MetricType::Counter(ref event) => event.metric_name.clone(),
} }
} }
fn description(&self) -> String { fn description(&self) -> String {
match self { match self {
&MetricType::Ticker(ref event) => event.description.clone(), MetricType::Ticker(ref event) => event.description.clone(),
&MetricType::Counter(ref event) => event.description.clone(), MetricType::Counter(ref event) => event.description.clone(),
} }
} }
@ -58,10 +58,10 @@ impl MetricType {
let event: &Metric; let event: &Metric;
match self { match self {
&MetricType::Ticker(ref i_event) => { MetricType::Ticker(ref i_event) => {
event = i_event; event = i_event;
} }
&MetricType::Counter(ref i_event) => { MetricType::Counter(ref i_event) => {
event = i_event; event = i_event;
} }
} }
@ -72,15 +72,15 @@ impl MetricType {
.map(|&(ref _fieldname, ref fieldtype)| fieldtype.clone()) .map(|&(ref _fieldname, ref fieldtype)| fieldtype.clone())
.collect(); .collect();
return fields; fields
} }
fn enum_field_types(&self) -> Vec<String> { fn enum_field_types(&self) -> Vec<String> {
let mut extra_fields: Vec<String> = vec![]; let mut extra_fields: Vec<String> = vec![];
match self { match self {
&MetricType::Ticker(_) => {} MetricType::Ticker(_) => {}
&MetricType::Counter(_) => { MetricType::Counter(_) => {
extra_fields = vec![self.collector_type()]; extra_fields = vec![self.collector_type()];
} }
} }
@ -88,17 +88,17 @@ impl MetricType {
let mut fields: Vec<String> = self.enum_index_types(); let mut fields: Vec<String> = self.enum_index_types();
fields.append(&mut extra_fields); fields.append(&mut extra_fields);
return fields; fields
} }
fn enum_index_names(&self) -> Vec<String> { fn enum_index_names(&self) -> Vec<String> {
let event: &Metric; let event: &Metric;
match self { match self {
&MetricType::Ticker(ref i_event) => { MetricType::Ticker(ref i_event) => {
event = i_event; event = i_event;
} }
&MetricType::Counter(ref i_event) => { MetricType::Counter(ref i_event) => {
event = i_event; event = i_event;
} }
} }
@ -109,15 +109,15 @@ impl MetricType {
.map(|&(ref fieldname, ref _fieldtype)| fieldname.clone()) .map(|&(ref fieldname, ref _fieldtype)| fieldname.clone())
.collect(); .collect();
return fields; fields
} }
fn enum_field_names(&self) -> Vec<String> { fn enum_field_names(&self) -> Vec<String> {
let mut extra_fields: Vec<String> = vec![]; let mut extra_fields: Vec<String> = vec![];
match self { match self {
&MetricType::Ticker(_) => {} MetricType::Ticker(_) => {}
&MetricType::Counter(_) => { MetricType::Counter(_) => {
extra_fields = vec!["value".to_owned()]; extra_fields = vec!["value".to_owned()];
} }
} }
@ -125,13 +125,13 @@ impl MetricType {
let mut fields: Vec<String> = self.enum_index_names(); let mut fields: Vec<String> = self.enum_index_names();
fields.append(&mut extra_fields); fields.append(&mut extra_fields);
return fields; fields
} }
fn record_value(&self) -> String { fn record_value(&self) -> String {
match self { match self {
&MetricType::Ticker(_) => String::from("1"), MetricType::Ticker(_) => String::from("1"),
&MetricType::Counter(_) => String::from("value"), MetricType::Counter(_) => String::from("value"),
} }
} }
} }
@ -147,18 +147,18 @@ fn name_to_parts(name: &str) -> Vec<String> {
let mut parts: Vec<String> = vec![]; let mut parts: Vec<String> = vec![];
let mut buf = String::from(""); let mut buf = String::from("");
for c in name.chars() { for c in name.chars() {
if char::is_uppercase(c) && buf.len() > 0 { if char::is_uppercase(c) && !buf.is_empty() {
parts.push(buf.to_owned()); parts.push(buf.to_owned());
buf = String::from(""); buf = String::from("");
} }
buf.push_str(&c.to_string()); buf.push_str(&c.to_string());
} }
if buf.len() > 0 { if !buf.is_empty() {
parts.push(buf.to_owned()); parts.push(buf.to_owned());
std::mem::drop(buf); std::mem::drop(buf);
} }
return parts; parts
} }
impl Metric { impl Metric {
@ -166,13 +166,11 @@ impl Metric {
let parts = name_to_parts(name); let parts = name_to_parts(name);
MetricType::Ticker(Metric { MetricType::Ticker(Metric {
variant: parts.iter().map(|f| f.clone().to_owned()).collect(), variant: parts.iter().cloned().collect(),
fields: fields fields: fields
.unwrap_or(vec![]) .unwrap_or_else(|| vec![])
.iter() .iter()
.map(|&(ref fieldname, ref fieldtype)| { .map(|(fieldname, fieldtype)| ((*fieldname).to_string(), (*fieldtype).to_string()))
(fieldname.clone().to_owned(), fieldtype.clone().to_owned())
})
.collect(), .collect(),
metric_name: parts.join("_").to_lowercase(), metric_name: parts.join("_").to_lowercase(),
description: desc.to_owned(), description: desc.to_owned(),
@ -183,13 +181,11 @@ impl Metric {
let parts = name_to_parts(name); let parts = name_to_parts(name);
MetricType::Counter(Metric { MetricType::Counter(Metric {
variant: parts.iter().map(|f| f.clone().to_owned()).collect(), variant: parts.iter().cloned().collect(),
fields: fields fields: fields
.unwrap_or(vec![]) .unwrap_or_else(|| vec![])
.iter() .iter()
.map(|&(ref fieldname, ref fieldtype)| { .map(|(fieldname, fieldtype)| ((*fieldname).to_string(), (*fieldtype).to_string()))
(fieldname.clone().to_owned(), fieldtype.clone().to_owned())
})
.collect(), .collect(),
metric_name: parts.join("_").to_lowercase(), metric_name: parts.join("_").to_lowercase(),
description: desc.to_owned(), description: desc.to_owned(),
@ -391,7 +387,7 @@ pub enum Event {
.collect(); .collect();
f.write_all(variants.join(",\n").as_bytes()).unwrap(); f.write_all(variants.join(",\n").as_bytes()).unwrap();
f.write_all("\n}\n\n".as_bytes()).unwrap(); f.write_all(b"\n}\n\n").unwrap();
f.write_all( f.write_all(
b"pub fn event_metric_name(event: &Event) -> String { b"pub fn event_metric_name(event: &Event) -> String {
@ -409,12 +405,11 @@ pub enum Event {
.map(|_| String::from("_")) .map(|_| String::from("_"))
.collect(); .collect();
let variant_match: String; let variant_match = if !fields.is_empty() {
if fields.len() > 0 { format!("{}({})", &mtype.variant(), fields.join(", "))
variant_match = format!("{}({})", &mtype.variant(), fields.join(", "));
} else { } else {
variant_match = format!("{}", &mtype.variant()); mtype.variant()
} };
format!( format!(
" Event::{} => String::from(\"{}\")", " Event::{} => String::from(\"{}\")",
@ -425,12 +420,12 @@ pub enum Event {
.collect(); .collect();
f.write_all(variants.join(",\n").as_bytes()).unwrap(); f.write_all(variants.join(",\n").as_bytes()).unwrap();
f.write_all("}\n }".as_bytes()).unwrap(); f.write_all(b"}\n }").unwrap();
// Create a struct to hold all the possible metrics // Create a struct to hold all the possible metrics
f.write_all( f.write_all(
b" b"
#[derive(Default, Debug, Clone)] #[derive(Default, Clone)]
pub struct MetricCollector { pub struct MetricCollector {
", ",
) )
@ -441,18 +436,26 @@ pub struct MetricCollector {
.map(|mtype| { .map(|mtype| {
let mut fields: Vec<String> = mtype.enum_index_types(); let mut fields: Vec<String> = mtype.enum_index_types();
fields.push("String".to_owned()); // Instance fields.push("String".to_owned()); // Instance
let fields_str = {
let s = fields.join(", ");
if fields.len() > 1 {
format!("({})", s)
} else {
s
}
};
format!( format!(
" {}: Arc<Mutex<HashMap<({}),{}>>>", " {}: Arc<Mutex<HashMap<{},{}>>>",
mtype.metric_name(), mtype.metric_name(),
fields.join(", "), fields_str,
mtype.collector_type(), mtype.collector_type(),
) )
}) })
.collect(); .collect();
f.write_all(variants.join(",\n").as_bytes()).unwrap(); f.write_all(variants.join(",\n").as_bytes()).unwrap();
f.write_all("\n}\n\n".as_bytes()).unwrap(); f.write_all(b"\n}\n\n").unwrap();
// Create a struct to hold all the possible metrics // Create a struct to hold all the possible metrics
f.write_all( f.write_all(
@ -474,10 +477,10 @@ impl MetricCollector {
.map(|mtype| { .map(|mtype| {
let fields: Vec<String> = mtype.enum_field_names(); let fields: Vec<String> = mtype.enum_field_names();
let variant_match = if fields.len() > 0 { let variant_match = if !fields.is_empty() {
format!("{}({})", &mtype.variant(), fields.join(", ")) format!("{}({})", &mtype.variant(), fields.join(", "))
} else { } else {
format!("{}", &mtype.variant()) mtype.variant()
}; };
let mut index_names: Vec<String> = mtype.enum_index_names(); let mut index_names: Vec<String> = mtype.enum_index_names();
@ -510,8 +513,8 @@ impl MetricCollector {
.collect(); .collect();
f.write_all(variants.join(",\n").as_bytes()).unwrap(); f.write_all(variants.join(",\n").as_bytes()).unwrap();
f.write_all("\n }\n".as_bytes()).unwrap(); f.write_all(b"\n }\n").unwrap();
f.write_all("\n }\n".as_bytes()).unwrap(); f.write_all(b"\n }\n").unwrap();
f.write_all( f.write_all(
b"pub fn prometheus_output(&self) -> String { b"pub fn prometheus_output(&self) -> String {
@ -525,15 +528,13 @@ impl MetricCollector {
.map(|mtype| { .map(|mtype| {
let mut index_fields: Vec<String> = mtype.enum_index_names(); let mut index_fields: Vec<String> = mtype.enum_index_names();
index_fields.push("instance".to_owned()); index_fields.push("instance".to_owned());
let ref_index_fields: Vec<String> = let ref_index_fields: Vec<String> = index_fields.clone();
index_fields.iter().map(|m| format!("{}", m)).collect();
let for_matcher: String; let for_matcher = if index_fields.len() > 1 {
if index_fields.len() > 1 { format!("({})", ref_index_fields.join(", "))
for_matcher = format!("({})", ref_index_fields.join(", "));
} else { } else {
for_matcher = ref_index_fields.join(", "); ref_index_fields.join(", ")
} };
let key_value_pairs: Vec<String> = index_fields let key_value_pairs: Vec<String> = index_fields
.iter() .iter()
@ -572,6 +573,6 @@ impl MetricCollector {
.collect(); .collect();
f.write_all(variants.join("\n").as_bytes()).unwrap(); f.write_all(variants.join("\n").as_bytes()).unwrap();
f.write_all("output\n }".as_bytes()).unwrap(); f.write_all(b"output\n }").unwrap();
f.write_all("\n}".as_bytes()).unwrap(); f.write_all(b"\n}").unwrap();
} }

View file

@ -28,7 +28,7 @@ pub struct AsyncCmd {
} }
pub struct SpawnedAsyncCmd { pub struct SpawnedAsyncCmd {
waiter: JoinHandle<(Option<Result<ExitStatus, io::Error>>)>, waiter: JoinHandle<Option<Result<ExitStatus, io::Error>>>,
rx: Receiver<String>, rx: Receiver<String>,
} }
@ -121,13 +121,13 @@ impl AsyncCmd {
spawn_join( spawn_join(
WaitTarget::Stdout, WaitTarget::Stdout,
monitor_tx.clone(), monitor_tx.clone(),
reader_tx(child.stdout.take().unwrap(), proc_tx.clone()), reader_tx(child.stdout.take().unwrap(), proc_tx),
), ),
); );
waiters.insert( waiters.insert(
WaitTarget::Child, WaitTarget::Child,
child_wait(WaitTarget::Child, monitor_tx.clone(), child), child_wait(WaitTarget::Child, monitor_tx, child),
); );
let head_waiter = thread::spawn(move || { let head_waiter = thread::spawn(move || {

View file

@ -44,8 +44,8 @@ fn main() {
let logbackrk = "NixOS/ofborg.42".to_owned(); let logbackrk = "NixOS/ofborg.42".to_owned();
let msg = buildjob::BuildJob { let msg = buildjob::BuildJob {
repo: repo_msg.clone(), repo: repo_msg,
pr: pr_msg.clone(), pr: pr_msg,
subset: Some(commentparser::Subset::Nixpkgs), subset: Some(commentparser::Subset::Nixpkgs),
attrs: vec!["success".to_owned()], attrs: vec!["success".to_owned()],
logs: Some((Some("logs".to_owned()), Some(logbackrk.to_lowercase()))), logs: Some((Some("logs".to_owned()), Some(logbackrk.to_lowercase()))),

View file

@ -58,8 +58,8 @@ impl CachedProject {
Ok(CachedProjectCo { Ok(CachedProjectCo {
root: new_root, root: new_root,
id, id,
clone_url: self.clone_from().clone(), clone_url: self.clone_from(),
local_reference: self.clone_to().clone(), local_reference: self.clone_to(),
}) })
} }

View file

@ -308,7 +308,7 @@ pub fn session_from_config(config: &RabbitMQConfig) -> Result<amqp::Session, amq
..amqp::Options::default() ..amqp::Options::default()
}; };
let session = try!(amqp::Session::new(options)); let session = amqp::Session::new(options)?;
info!("Connected to {}", &config.host); info!("Connected to {}", &config.host);
Ok(session) Ok(session)

View file

@ -12,7 +12,7 @@ pub struct MaintainersByPackage(pub HashMap<Package, HashSet<Maintainer>>);
pub struct Maintainer(String); pub struct Maintainer(String);
impl<'a> From<&'a str> for Maintainer { impl<'a> From<&'a str> for Maintainer {
fn from(name: &'a str) -> Maintainer { fn from(name: &'a str) -> Maintainer {
Maintainer(name.to_ascii_lowercase().to_owned()) Maintainer(name.to_ascii_lowercase())
} }
} }
#[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)] #[derive(Deserialize, Clone, Debug, Eq, PartialEq, Hash)]

View file

@ -162,7 +162,12 @@ mod tests {
let result: BuildResult = serde_json::from_str(input).expect("result required"); let result: BuildResult = serde_json::from_str(input).expect("result required");
assert_eq!(result.status(), BuildStatus::Success); assert_eq!(result.status(), BuildStatus::Success);
let output = serde_json::to_string(&result).expect("json required"); let output = serde_json::to_string(&result).expect("json required");
assert_eq!(output, r#"{"tag":"V1","repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":["unpacking sources"],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","status":"Success","skipped_attrs":["AAAAAASomeThingsFailToEvaluate"],"attempted_attrs":["hello"]}"#, "json of: {:?}", result); assert_eq!(
output,
r#"{"tag":"V1","repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":["unpacking sources"],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","status":"Success","skipped_attrs":["AAAAAASomeThingsFailToEvaluate"],"attempted_attrs":["hello"]}"#,
"json of: {:?}",
result
);
} }
#[test] #[test]
@ -171,7 +176,12 @@ mod tests {
let result: BuildResult = serde_json::from_str(input).expect("result required"); let result: BuildResult = serde_json::from_str(input).expect("result required");
assert_eq!(result.status(), BuildStatus::Success); assert_eq!(result.status(), BuildStatus::Success);
let output = serde_json::to_string(&result).expect("json required"); let output = serde_json::to_string(&result).expect("json required");
assert_eq!(output, r#"{"repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":["unpacking sources"],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","success":true,"status":"Success","skipped_attrs":["AAAAAASomeThingsFailToEvaluate"],"attempted_attrs":["hello"]}"#, "json of: {:?}", result); assert_eq!(
output,
r#"{"repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":["unpacking sources"],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","success":true,"status":"Success","skipped_attrs":["AAAAAASomeThingsFailToEvaluate"],"attempted_attrs":["hello"]}"#,
"json of: {:?}",
result
);
} }
#[test] #[test]
@ -180,7 +190,12 @@ mod tests {
let result: BuildResult = serde_json::from_str(input).expect("result required"); let result: BuildResult = serde_json::from_str(input).expect("result required");
assert_eq!(result.status(), BuildStatus::Skipped); assert_eq!(result.status(), BuildStatus::Skipped);
let output = serde_json::to_string(&result).expect("json required"); let output = serde_json::to_string(&result).expect("json required");
assert_eq!(output, r#"{"repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":[],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","success":null,"status":null,"skipped_attrs":null,"attempted_attrs":null}"#, "json of: {:?}", result); assert_eq!(
output,
r#"{"repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":[],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","success":null,"status":null,"skipped_attrs":null,"attempted_attrs":null}"#,
"json of: {:?}",
result
);
} }
#[test] #[test]
@ -189,6 +204,11 @@ mod tests {
let result: BuildResult = serde_json::from_str(input).expect("result required"); let result: BuildResult = serde_json::from_str(input).expect("result required");
assert_eq!(result.status(), BuildStatus::Success); assert_eq!(result.status(), BuildStatus::Success);
let output = serde_json::to_string(&result).expect("json required"); let output = serde_json::to_string(&result).expect("json required");
assert_eq!(output, r#"{"repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":["unpacking sources"],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","success":true,"status":null,"skipped_attrs":["AAAAAASomeThingsFailToEvaluate"],"attempted_attrs":["hello"]}"#, "json of: {:?}", result); assert_eq!(
output,
r#"{"repo":{"owner":"NixOS","name":"nixpkgs","full_name":"NixOS/nixpkgs","clone_url":"https://github.com/nixos/nixpkgs.git"},"pr":{"target_branch":"master","number":42,"head_sha":"0000000000000000000000000000000000000000"},"system":"x86_64-linux","output":["unpacking sources"],"attempt_id":"attempt-id-foo","request_id":"bogus-request-id","success":true,"status":null,"skipped_attrs":["AAAAAASomeThingsFailToEvaluate"],"attempted_attrs":["hello"]}"#,
"json of: {:?}",
result
);
} }
} }

View file

@ -147,8 +147,8 @@ impl Nix {
.into_iter() .into_iter()
.map( .map(
|attr| match self.safely_instantiate_attrs(nixpkgs, file, vec![attr.clone()]) { |attr| match self.safely_instantiate_attrs(nixpkgs, file, vec![attr.clone()]) {
Ok(_) => Ok(attr.clone()), Ok(_) => Ok(attr),
Err(f) => Err((attr.clone(), lines_from_file(f))), Err(f) => Err((attr, lines_from_file(f))),
}, },
) )
.collect(); .collect();

View file

@ -116,31 +116,23 @@ impl<'a> EvaluationStatsDiff<'a> {
diff: String, diff: String,
diff_pct: String, diff_pct: String,
} }
impl Row { impl Row {
fn from_u64(left: u64, right: u64) -> Row { fn from_u64(left: u64, right: u64) -> Row {
let diff: u64; let (diff, direction): (u64, _) = match left.cmp(&right) {
let direction: &str; std::cmp::Ordering::Greater => (left - right, ""),
let diff_pct: String; std::cmp::Ordering::Less => (right - left, ""),
std::cmp::Ordering::Equal => (0, ""),
};
if left > right { let diff_pct: String = if diff > 0 {
diff = left - right; format!(
direction = "";
} else if left < right {
diff = right - left;
direction = "";
} else {
diff = 0;
direction = "";
}
if diff > 0 {
diff_pct = format!(
"{:.2}%", "{:.2}%",
((right as f64) - (left as f64)) / (left as f64) * 100.0 ((right as f64) - (left as f64)) / (left as f64) * 100.0
); )
} else { } else {
diff_pct = String::from(""); String::from("")
} };
Row { Row {
before: left.separated_string(), before: left.separated_string(),
@ -151,29 +143,23 @@ impl<'a> EvaluationStatsDiff<'a> {
} }
fn from_f32(left: f32, right: f32) -> Row { fn from_f32(left: f32, right: f32) -> Row {
let diff: f32; let (diff, direction): (f32, _) = match left
let direction: &str; .partial_cmp(&right)
let diff_pct: String; .unwrap_or(std::cmp::Ordering::Equal)
{
std::cmp::Ordering::Greater => (left - right, ""),
std::cmp::Ordering::Less => (right - left, ""),
std::cmp::Ordering::Equal => (0 as f32, ""),
};
if left > right { let diff_pct: String = if diff > 0 as _ {
diff = left - right; format!(
direction = "";
} else if left < right {
diff = right - left;
direction = "";
} else {
diff = 0.0;
direction = "";
}
if diff > 0.0 {
diff_pct = format!(
"{:.2}%", "{:.2}%",
(f64::from(right) - f64::from(left)) / f64::from(left) * 100.0 ((right as f64) - (left as f64)) / (left as f64) * 100.0
); )
} else { } else {
diff_pct = String::from(""); String::from("")
} };
Row { Row {
before: format!("{:.2}", left), before: format!("{:.2}", left),

View file

@ -216,7 +216,7 @@ impl<'a> NixpkgsStrategy<'a> {
self.record_impacted_maintainers(&dir, &attrs); self.record_impacted_maintainers(&dir, &attrs);
} }
rebuild_tags.parse_attrs(attrs.clone()); rebuild_tags.parse_attrs(attrs);
} }
update_labels( update_labels(

View file

@ -229,7 +229,7 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
target_branch_rebuild_sniff_start.elapsed().as_secs(), target_branch_rebuild_sniff_start.elapsed().as_secs(),
)); ));
self.events self.events
.notify(Event::EvaluationDurationCount(target_branch.clone())); .notify(Event::EvaluationDurationCount(target_branch));
overall_status.set_with_description("Fetching PR", hubcaps::statuses::State::Pending); overall_status.set_with_description("Fetching PR", hubcaps::statuses::State::Pending);

View file

@ -93,8 +93,8 @@ impl worker::SimpleWorker for EvaluationFilterWorker {
}; };
let msg = evaluationjob::EvaluationJob { let msg = evaluationjob::EvaluationJob {
repo: repo_msg.clone(), repo: repo_msg,
pr: pr_msg.clone(), pr: pr_msg,
}; };
return vec![ return vec![

View file

@ -101,7 +101,7 @@ impl worker::SimpleWorker for GitHubCommentWorker {
let pr_msg = Pr { let pr_msg = Pr {
number: job.issue.number, number: job.issue.number,
head_sha: pr.head.sha.clone(), head_sha: pr.head.sha.clone(),
target_branch: Some(pr.base.commit_ref.clone()), target_branch: Some(pr.base.commit_ref),
}; };
let mut response: Vec<worker::Action> = vec![]; let mut response: Vec<worker::Action> = vec![];

View file

@ -196,7 +196,7 @@ impl worker::SimpleWorker for LogMessageCollector {
} else { } else {
let decode_msg: Result<BuildResult, _> = serde_json::from_slice(body); let decode_msg: Result<BuildResult, _> = serde_json::from_slice(body);
if let Ok(msg) = decode_msg { if let Ok(msg) = decode_msg {
attempt_id = msg.legacy().attempt_id.clone(); attempt_id = msg.legacy().attempt_id;
message = MsgType::Finish(Box::new(msg)); message = MsgType::Finish(Box::new(msg));
} else { } else {
return Err(format!("failed to decode job: {:?}", decode_msg)); return Err(format!("failed to decode job: {:?}", decode_msg));

View file

@ -4,10 +4,11 @@
let let
composerEnv = import ./composer-env.nix { composerEnv = import ./composer-env.nix {
inherit (pkgs) stdenv writeTextFile fetchurl php unzip; inherit (pkgs) stdenv writeTextFile fetchurl unzip;
php = pkgs.php72;
}; };
in in
import ./php-packages.nix { import ./php-packages.nix {
inherit composerEnv noDev; inherit composerEnv noDev;
inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn; inherit (pkgs) fetchurl fetchgit fetchhg fetchsvn;
} }

View file

@ -15,7 +15,12 @@ let
(collector: system: (collector: system:
collector // { collector // {
"${system}" = import ./. { "${system}" = import ./. {
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs {
inherit system;
overlays = [
(import ./nix/overlay.nix)
];
};
}; };
} }
) )

View file

@ -41,7 +41,7 @@ let
latest.rustChannels.stable.rust latest.rustChannels.stable.rust
git git
pkgconfig pkgconfig
openssl.dev openssl_1_0_2.dev
] ]
++ stdenv.lib.optional stdenv.isDarwin pkgs.darwin.Security; ++ stdenv.lib.optional stdenv.isDarwin pkgs.darwin.Security;
@ -80,7 +80,7 @@ let
latest.rustChannels.stable.rust latest.rustChannels.stable.rust
#rustfmt #rustfmt
#carnix #carnix
openssl.dev openssl_1_0_2.dev
pkgconfig pkgconfig
git git
] ]