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

Commits on Feb 21, 2020

  1. Update to current nixpkgs-unstable

    This required the introduction of an overlay file since ofBorg still
    requires openssl 1.0.2. Updating to newer version of openssl also
    requires updating the amqp library which requires some more involved
    changes.
    
    The php code is only updated to php 7.2 and not 7.3 (the default in
    nixpkgs) since there seem to been a few syntax changes that aren't yet
    compatible with composer2nix.
    
    In previous versions of the rust infrastructure within nixpkgs we would
    have been able to override all crates during the invocation of the
    target crate. That `override` feature was removed as it caused a huge
    eval overhead for larger projects. We did end up with (n^2)
    instantiations of dependencies since they were being overriden on every
    invocation of every dependency on every level further down the chain.
    The current understanding is that the build tooling that each project is
    using (e.g.  crate2nix, crate2nix, …) that is driving the actual build
    could easily reintroduce that feature without the overhead.
    
    pin to php72
    andir committed Feb 21, 2020
    Copy the full SHA
    41687fe View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    31205e3 View commit details

Commits on Feb 22, 2020

  1. fix new linting issues

    andir committed Feb 22, 2020
    Copy the full SHA
    e3e32bc View commit details

Commits on Mar 4, 2020

  1. Merge pull request #436 from andir/update-nixpkgs

    Update to current nixpkgs-unstable
    grahamc authored Mar 4, 2020
    Copy the full SHA
    ea4b7f8 View commit details
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs ? import ./nix {} }:
{ pkgs ? import ./nix { overlays = [ (import ./nix/overlay.nix) ]; } }:

let
ofborgOverrides = {
6 changes: 3 additions & 3 deletions nix/nixpkgs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"url": "https://github.com/nixos/nixpkgs-channels.git",
"rev": "201d739b0ffbebceb444864d1856babcd1a666a8",
"date": "2018-12-30T01:29:37+00:00",
"sha256": "0mfkzmylglpw84w85zs3djpspcx45bg3s62hk4j44dxl2p0fvggj",
"rev": "e2b4abe3c8f2e09adfc6a52007841d1b96c89371",
"date": "2020-02-19T01:57:21+01:00",
"sha256": "1l3jfr74s7wmx3fk5y76ayazbfclvnr532kg1hypbzydp3n372rz",
"fetchSubmodules": false
}
12 changes: 12 additions & 0 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
@@ -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";
};
};
})

127 changes: 64 additions & 63 deletions ofborg/build.rs
Original file line number Diff line number Diff line change
@@ -11,57 +11,57 @@ enum MetricType {
impl MetricType {
fn collector_type(&self) -> String {
match self {
&MetricType::Ticker(_) => String::from("u64"),
&MetricType::Counter(_) => String::from("u64"),
MetricType::Ticker(_) => String::from("u64"),
MetricType::Counter(_) => String::from("u64"),
}
}

fn enum_matcher_types(&self) -> String {
let fields = self.enum_field_types();

if fields.len() > 0 {
if !fields.is_empty() {
format!("{}({})", self.variant(), fields.join(", "))
} else {
format!("{}", self.variant())
self.variant()
}
}

fn variant(&self) -> String {
match self {
&MetricType::Ticker(ref event) => event.variant.clone(),
&MetricType::Counter(ref event) => event.variant.clone(),
MetricType::Ticker(ref event) => event.variant.clone(),
MetricType::Counter(ref event) => event.variant.clone(),
}
}

fn metric_type(&self) -> String {
match self {
&MetricType::Ticker(_) => String::from("counter"),
&MetricType::Counter(_) => String::from("counter"),
MetricType::Ticker(_) => String::from("counter"),
MetricType::Counter(_) => String::from("counter"),
}
}

fn metric_name(&self) -> String {
match self {
&MetricType::Ticker(ref event) => event.metric_name.clone(),
&MetricType::Counter(ref event) => event.metric_name.clone(),
MetricType::Ticker(ref event) => event.metric_name.clone(),
MetricType::Counter(ref event) => event.metric_name.clone(),
}
}

fn description(&self) -> String {
match self {
&MetricType::Ticker(ref event) => event.description.clone(),
&MetricType::Counter(ref event) => event.description.clone(),
MetricType::Ticker(ref event) => event.description.clone(),
MetricType::Counter(ref event) => event.description.clone(),
}
}

fn enum_index_types(&self) -> Vec<String> {
let event: &Metric;

match self {
&MetricType::Ticker(ref i_event) => {
MetricType::Ticker(ref i_event) => {
event = i_event;
}
&MetricType::Counter(ref i_event) => {
MetricType::Counter(ref i_event) => {
event = i_event;
}
}
@@ -72,33 +72,33 @@ impl MetricType {
.map(|&(ref _fieldname, ref fieldtype)| fieldtype.clone())
.collect();

return fields;
fields
}

fn enum_field_types(&self) -> Vec<String> {
let mut extra_fields: Vec<String> = vec![];

match self {
&MetricType::Ticker(_) => {}
&MetricType::Counter(_) => {
MetricType::Ticker(_) => {}
MetricType::Counter(_) => {
extra_fields = vec![self.collector_type()];
}
}

let mut fields: Vec<String> = self.enum_index_types();
fields.append(&mut extra_fields);

return fields;
fields
}

fn enum_index_names(&self) -> Vec<String> {
let event: &Metric;

match self {
&MetricType::Ticker(ref i_event) => {
MetricType::Ticker(ref i_event) => {
event = i_event;
}
&MetricType::Counter(ref i_event) => {
MetricType::Counter(ref i_event) => {
event = i_event;
}
}
@@ -109,29 +109,29 @@ impl MetricType {
.map(|&(ref fieldname, ref _fieldtype)| fieldname.clone())
.collect();

return fields;
fields
}

fn enum_field_names(&self) -> Vec<String> {
let mut extra_fields: Vec<String> = vec![];

match self {
&MetricType::Ticker(_) => {}
&MetricType::Counter(_) => {
MetricType::Ticker(_) => {}
MetricType::Counter(_) => {
extra_fields = vec!["value".to_owned()];
}
}

let mut fields: Vec<String> = self.enum_index_names();
fields.append(&mut extra_fields);

return fields;
fields
}

fn record_value(&self) -> String {
match self {
&MetricType::Ticker(_) => String::from("1"),
&MetricType::Counter(_) => String::from("value"),
MetricType::Ticker(_) => String::from("1"),
MetricType::Counter(_) => String::from("value"),
}
}
}
@@ -147,32 +147,30 @@ fn name_to_parts(name: &str) -> Vec<String> {
let mut parts: Vec<String> = vec![];
let mut buf = String::from("");
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());
buf = String::from("");
}
buf.push_str(&c.to_string());
}
if buf.len() > 0 {
if !buf.is_empty() {
parts.push(buf.to_owned());
std::mem::drop(buf);
}

return parts;
parts
}

impl Metric {
pub fn ticker(name: &str, desc: &str, fields: Option<Vec<(&str, &str)>>) -> MetricType {
let parts = name_to_parts(name);

MetricType::Ticker(Metric {
variant: parts.iter().map(|f| f.clone().to_owned()).collect(),
variant: parts.iter().cloned().collect(),
fields: fields
.unwrap_or(vec![])
.unwrap_or_else(|| vec![])
.iter()
.map(|&(ref fieldname, ref fieldtype)| {
(fieldname.clone().to_owned(), fieldtype.clone().to_owned())
})
.map(|(fieldname, fieldtype)| ((*fieldname).to_string(), (*fieldtype).to_string()))
.collect(),
metric_name: parts.join("_").to_lowercase(),
description: desc.to_owned(),
@@ -183,13 +181,11 @@ impl Metric {
let parts = name_to_parts(name);

MetricType::Counter(Metric {
variant: parts.iter().map(|f| f.clone().to_owned()).collect(),
variant: parts.iter().cloned().collect(),
fields: fields
.unwrap_or(vec![])
.unwrap_or_else(|| vec![])
.iter()
.map(|&(ref fieldname, ref fieldtype)| {
(fieldname.clone().to_owned(), fieldtype.clone().to_owned())
})
.map(|(fieldname, fieldtype)| ((*fieldname).to_string(), (*fieldtype).to_string()))
.collect(),
metric_name: parts.join("_").to_lowercase(),
description: desc.to_owned(),
@@ -391,7 +387,7 @@ pub enum Event {
.collect();

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(
b"pub fn event_metric_name(event: &Event) -> String {
@@ -409,12 +405,11 @@ pub enum Event {
.map(|_| String::from("_"))
.collect();

let variant_match: String;
if fields.len() > 0 {
variant_match = format!("{}({})", &mtype.variant(), fields.join(", "));
let variant_match = if !fields.is_empty() {
format!("{}({})", &mtype.variant(), fields.join(", "))
} else {
variant_match = format!("{}", &mtype.variant());
}
mtype.variant()
};

format!(
" Event::{} => String::from(\"{}\")",
@@ -425,12 +420,12 @@ pub enum Event {
.collect();

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
f.write_all(
b"
#[derive(Default, Debug, Clone)]
#[derive(Default, Clone)]
pub struct MetricCollector {
",
)
@@ -441,18 +436,26 @@ pub struct MetricCollector {
.map(|mtype| {
let mut fields: Vec<String> = mtype.enum_index_types();
fields.push("String".to_owned()); // Instance
let fields_str = {
let s = fields.join(", ");
if fields.len() > 1 {
format!("({})", s)
} else {
s
}
};

format!(
" {}: Arc<Mutex<HashMap<({}),{}>>>",
" {}: Arc<Mutex<HashMap<{},{}>>>",
mtype.metric_name(),
fields.join(", "),
fields_str,
mtype.collector_type(),
)
})
.collect();

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
f.write_all(
@@ -474,10 +477,10 @@ impl MetricCollector {
.map(|mtype| {
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(", "))
} else {
format!("{}", &mtype.variant())
mtype.variant()
};

let mut index_names: Vec<String> = mtype.enum_index_names();
@@ -510,8 +513,8 @@ impl MetricCollector {
.collect();

f.write_all(variants.join(",\n").as_bytes()).unwrap();
f.write_all("\n }\n".as_bytes()).unwrap();
f.write_all("\n }\n".as_bytes()).unwrap();
f.write_all(b"\n }\n").unwrap();
f.write_all(b"\n }\n").unwrap();

f.write_all(
b"pub fn prometheus_output(&self) -> String {
@@ -525,15 +528,13 @@ impl MetricCollector {
.map(|mtype| {
let mut index_fields: Vec<String> = mtype.enum_index_names();
index_fields.push("instance".to_owned());
let ref_index_fields: Vec<String> =
index_fields.iter().map(|m| format!("{}", m)).collect();
let ref_index_fields: Vec<String> = index_fields.clone();

let for_matcher: String;
if index_fields.len() > 1 {
for_matcher = format!("({})", ref_index_fields.join(", "));
let for_matcher = if index_fields.len() > 1 {
format!("({})", ref_index_fields.join(", "))
} else {
for_matcher = ref_index_fields.join(", ");
}
ref_index_fields.join(", ")
};

let key_value_pairs: Vec<String> = index_fields
.iter()
@@ -572,6 +573,6 @@ impl MetricCollector {
.collect();

f.write_all(variants.join("\n").as_bytes()).unwrap();
f.write_all("output\n }".as_bytes()).unwrap();
f.write_all("\n}".as_bytes()).unwrap();
f.write_all(b"output\n }").unwrap();
f.write_all(b"\n}").unwrap();
}
6 changes: 3 additions & 3 deletions ofborg/src/asynccmd.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ pub struct AsyncCmd {
}

pub struct SpawnedAsyncCmd {
waiter: JoinHandle<(Option<Result<ExitStatus, io::Error>>)>,
waiter: JoinHandle<Option<Result<ExitStatus, io::Error>>>,
rx: Receiver<String>,
}

@@ -121,13 +121,13 @@ impl AsyncCmd {
spawn_join(
WaitTarget::Stdout,
monitor_tx.clone(),
reader_tx(child.stdout.take().unwrap(), proc_tx.clone()),
reader_tx(child.stdout.take().unwrap(), proc_tx),
),
);

waiters.insert(
WaitTarget::Child,
child_wait(WaitTarget::Child, monitor_tx.clone(), child),
child_wait(WaitTarget::Child, monitor_tx, child),
);

let head_waiter = thread::spawn(move || {
4 changes: 2 additions & 2 deletions ofborg/src/bin/build-faker.rs
Original file line number Diff line number Diff line change
@@ -44,8 +44,8 @@ fn main() {
let logbackrk = "NixOS/ofborg.42".to_owned();

let msg = buildjob::BuildJob {
repo: repo_msg.clone(),
pr: pr_msg.clone(),
repo: repo_msg,
pr: pr_msg,
subset: Some(commentparser::Subset::Nixpkgs),
attrs: vec!["success".to_owned()],
logs: Some((Some("logs".to_owned()), Some(logbackrk.to_lowercase()))),
Loading