From 0778ce7d9a26fd144236171705da142851458c92 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sat, 10 Feb 2018 19:09:57 -0500 Subject: [PATCH 01/47] Only set a gist on the overall status for changed paths if at least one path changed --- ofborg/src/tasks/massrebuilder.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 949651e..155143b 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -476,19 +476,22 @@ impl worker::SimpleWorker for MassRebuildWorker { let mut rebuild_tags = RebuildTagger::new(); if let Some(attrs) = rebuildsniff.calculate_rebuild() { - let gist_url = make_gist( - &gists, - String::from("Changed Paths"), - None, - attrs - .iter() - .map(|attr| format!("{}\t{}", &attr.architecture, &attr.package)) - .collect::>() - .join("\n"), - ); + if attrs.len() > 0 { + let gist_url = make_gist( + &gists, + String::from("Changed Paths"), + Some("".to_owned()), + attrs + .iter() + .map(|attr| format!("{}\t{}", &attr.architecture, &attr.package)) + .collect::>() + .join("\n"), + ); + + overall_status.set_url(gist_url); + } rebuild_tags.parse_attrs(attrs); - overall_status.set_url(gist_url); } update_labels( From 71a7bb3e33088186c84fb82f02701c0156187a5c Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sat, 10 Feb 2018 19:10:49 -0500 Subject: [PATCH 02/47] Nix.ci --- ofborg/src/tasks/githubcommentposter.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ofborg/src/tasks/githubcommentposter.rs b/ofborg/src/tasks/githubcommentposter.rs index ae93ce0..f39be55 100644 --- a/ofborg/src/tasks/githubcommentposter.rs +++ b/ofborg/src/tasks/githubcommentposter.rs @@ -75,7 +75,7 @@ fn result_to_comment(result: &BuildResult) -> String { let mut reply: Vec = vec![]; reply.push(format!( - "{} on {} [(full log)](https://logs.nix.gsc.io/?key={}/{}.{}&attempt_id={})", + "{} on {} [(full log)](https://logs.nix.ci/?key={}/{}.{}&attempt_id={})", (match result.success { true => "Success", false => "Failure", @@ -142,7 +142,7 @@ mod tests { assert_eq!( &result_to_comment(&result), - "Success on x86_64-linux [(full log)](https://logs.nix.gsc.io/?key=nixos/nixpkgs.2345&attempt_id=neatattemptid) + "Success on x86_64-linux [(full log)](https://logs.nix.ci/?key=nixos/nixpkgs.2345&attempt_id=neatattemptid)
Partial log (click to expand)

@@ -197,7 +197,7 @@ patching script interpreter paths in /nix/store/pcja75y9isdvgz5i00pkrpif9rxzxc29 assert_eq!( &result_to_comment(&result), - "Failure on x86_64-linux [(full log)](https://logs.nix.gsc.io/?key=nixos/nixpkgs.2345&attempt_id=neatattemptid) + "Failure on x86_64-linux [(full log)](https://logs.nix.ci/?key=nixos/nixpkgs.2345&attempt_id=neatattemptid)

Partial log (click to expand)

@@ -252,7 +252,7 @@ patching script interpreter paths in /nix/store/pcja75y9isdvgz5i00pkrpif9rxzxc29 assert_eq!( &result_to_comment(&result), - "Failure on x86_64-linux [(full log)](https://logs.nix.gsc.io/?key=nixos/nixpkgs.2345&attempt_id=none) + "Failure on x86_64-linux [(full log)](https://logs.nix.ci/?key=nixos/nixpkgs.2345&attempt_id=none)

Partial log (click to expand)

From 7d16879d6300fe9a6f1d74450d65b4d542ae7485 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 4 Feb 2018 18:38:38 -0500 Subject: [PATCH 03/47] Add prometheus to ofborg --- nix/ofborg-carnix.nix | 127 +++++++++++++++++++++++++++++++++++++++++- ofborg/Cargo.lock | 39 +++++++++++++ ofborg/Cargo.toml | 1 + 3 files changed, 165 insertions(+), 2 deletions(-) diff --git a/nix/ofborg-carnix.nix b/nix/ofborg-carnix.nix index de062a2..a27a016 100644 --- a/nix/ofborg-carnix.nix +++ b/nix/ofborg-carnix.nix @@ -210,6 +210,14 @@ rec { sha256 = "1xxbzd8cjlpzsb9fsih7mdnndhzrvykj0w77yg90qc85az1xwy5z"; inherit dependencies buildDependencies features; }; + fnv_1_0_6_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + crateName = "fnv"; + version = "1.0.6"; + authors = [ "Alex Crichton " ]; + sha256 = "128mlh23y3gg6ag5h8iiqlcbl59smisdzraqy88ldrf75kbw27ip"; + libPath = "lib.rs"; + inherit dependencies buildDependencies features; + }; foreign_types_0_3_2_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "foreign-types"; version = "0.3.2"; @@ -444,6 +452,28 @@ rec { sha256 = "06k8fxgrsrxj8mjpjcq1n7mn2p1shpxif4zg9y5h09c7vy20s146"; inherit dependencies buildDependencies features; }; + prometheus_0_3_11_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + crateName = "prometheus"; + version = "0.3.11"; + authors = [ "overvenus@gmail.com" "siddontang@gmail.com" ]; + sha256 = "1c5vcy771cwpd14adgknf7pmf603p8nf4q90ik7ry083vxrvbmbg"; + inherit dependencies buildDependencies features; + }; + protobuf_1_4_3_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + crateName = "protobuf"; + version = "1.4.3"; + authors = [ "Stepan Koltsov " ]; + sha256 = "093fczpx523lm6d7xr5d4mqs88891ay6wk951yck3cavsz35z00b"; + crateBin = [ { name = "protoc-gen-rust"; path = "protoc-gen-rust.rs"; } { name = "protobuf-bin-gen-rust-do-not-use"; path = "protobuf-bin-gen-rust-do-not-use.rs"; } ]; + inherit dependencies buildDependencies features; + }; + quick_error_0_2_2_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + crateName = "quick-error"; + version = "0.2.2"; + authors = [ "Paul Colomiets " "Colin Kiegel " ]; + sha256 = "0r1f4ps998y779qwvnmmxhjq00qh5wxg3m5inswfawg0vr2732db"; + inherit dependencies buildDependencies features; + }; quote_0_3_15_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "quote"; version = "0.3.15"; @@ -559,6 +589,13 @@ rec { sha256 = "1pcclssyndz54cncsizkqrblmqqr1p2g6xhkpwldbk6qc95m4yw3"; inherit dependencies buildDependencies features; }; + spin_0_4_6_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + crateName = "spin"; + version = "0.4.6"; + authors = [ "Mathijs van de Nes " "John Ericson " ]; + sha256 = "1mp30r3pxb38m6mszcgn6136d1r162fwcidg3y4d9rym21hmialj"; + inherit dependencies buildDependencies features; + }; syn_0_11_11_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "syn"; version = "0.11.11"; @@ -1025,6 +1062,10 @@ rec { (f.error_chain_0_10_0.default or false) || (error_chain_0_10_0.default or false); }) [ backtrace_0_3_5_features ]; + fnv_1_0_6 = { features?(fnv_1_0_6_features {}) }: fnv_1_0_6_ {}; + fnv_1_0_6_features = f: updateFeatures f (rec { + fnv_1_0_6.default = (f.fnv_1_0_6.default or true); + }) []; foreign_types_0_3_2 = { features?(foreign_types_0_3_2_features {}) }: foreign_types_0_3_2_ { dependencies = mapFeatures features ([ foreign_types_shared_0_1_1 ]); }; @@ -1324,7 +1365,7 @@ rec { num_cpus_1_8_0.default = (f.num_cpus_1_8_0.default or true); }) [ libc_0_2_36_features ]; ofborg_0_1_1 = { features?(ofborg_0_1_1_features {}) }: ofborg_0_1_1_ { - dependencies = mapFeatures features ([ amqp_0_1_0 env_logger_0_4_3 fs2_0_4_3 hubcaps_0_3_16 hyper_0_10_13 hyper_native_tls_0_2_4 log_0_3_8 lru_cache_0_1_1 md5_0_3_6 serde_1_0_27 serde_derive_1_0_27 serde_json_1_0_9 tempfile_2_2_0 uuid_0_4_0 ]); + dependencies = mapFeatures features ([ amqp_0_1_0 env_logger_0_4_3 fs2_0_4_3 hubcaps_0_3_16 hyper_0_10_13 hyper_native_tls_0_2_4 log_0_3_8 lru_cache_0_1_1 md5_0_3_6 prometheus_0_3_11 serde_1_0_27 serde_derive_1_0_27 serde_json_1_0_9 tempfile_2_2_0 uuid_0_4_0 ]); }; ofborg_0_1_1_features = f: updateFeatures f (rec { amqp_0_1_0.default = true; @@ -1337,13 +1378,14 @@ rec { lru_cache_0_1_1.default = true; md5_0_3_6.default = true; ofborg_0_1_1.default = (f.ofborg_0_1_1.default or true); + prometheus_0_3_11.default = true; serde_1_0_27.default = true; serde_derive_1_0_27.default = true; serde_json_1_0_9.default = true; tempfile_2_2_0.default = true; uuid_0_4_0.default = true; uuid_0_4_0.v4 = true; - }) [ amqp_0_1_0_features env_logger_0_4_3_features fs2_0_4_3_features hubcaps_0_3_16_features hyper_0_10_13_features hyper_native_tls_0_2_4_features log_0_3_8_features lru_cache_0_1_1_features md5_0_3_6_features serde_1_0_27_features serde_derive_1_0_27_features serde_json_1_0_9_features tempfile_2_2_0_features uuid_0_4_0_features ]; + }) [ amqp_0_1_0_features env_logger_0_4_3_features fs2_0_4_3_features hubcaps_0_3_16_features hyper_0_10_13_features hyper_native_tls_0_2_4_features log_0_3_8_features lru_cache_0_1_1_features md5_0_3_6_features prometheus_0_3_11_features serde_1_0_27_features serde_derive_1_0_27_features serde_json_1_0_9_features tempfile_2_2_0_features uuid_0_4_0_features ]; openssl_0_9_23 = { features?(openssl_0_9_23_features {}) }: openssl_0_9_23_ { dependencies = mapFeatures features ([ bitflags_0_9_1 foreign_types_0_3_2 lazy_static_1_0_0 libc_0_2_36 openssl_sys_0_9_24 ]); features = mkFeatures (features.openssl_0_9_23 or {}); @@ -1375,6 +1417,59 @@ rec { pkg_config_0_3_9_features = f: updateFeatures f (rec { pkg_config_0_3_9.default = (f.pkg_config_0_3_9.default or true); }) []; + prometheus_0_3_11 = { features?(prometheus_0_3_11_features {}) }: prometheus_0_3_11_ { + dependencies = mapFeatures features ([ cfg_if_0_1_2 fnv_1_0_6 lazy_static_0_2_11 protobuf_1_4_3 quick_error_0_2_2 spin_0_4_6 ]) + ++ (if kernel == "linux" then mapFeatures features ([]) else []); + features = mkFeatures (features.prometheus_0_3_11 or {}); + }; + prometheus_0_3_11_features = f: updateFeatures f (rec { + cfg_if_0_1_2.default = true; + fnv_1_0_6.default = true; + lazy_static_0_2_11.default = true; + prometheus_0_3_11.clippy = + (f.prometheus_0_3_11.clippy or false) || + (f.prometheus_0_3_11.dev or false) || + (prometheus_0_3_11.dev or false); + prometheus_0_3_11.default = (f.prometheus_0_3_11.default or true); + prometheus_0_3_11.hyper = + (f.prometheus_0_3_11.hyper or false) || + (f.prometheus_0_3_11.push or false) || + (prometheus_0_3_11.push or false); + prometheus_0_3_11.libc = + (f.prometheus_0_3_11.libc or false) || + (f.prometheus_0_3_11.nightly or false) || + (prometheus_0_3_11.nightly or false) || + (f.prometheus_0_3_11.process or false) || + (prometheus_0_3_11.process or false) || + (f.prometheus_0_3_11.push or false) || + (prometheus_0_3_11.push or false); + prometheus_0_3_11.procinfo = + (f.prometheus_0_3_11.procinfo or false) || + (f.prometheus_0_3_11.process or false) || + (prometheus_0_3_11.process or false); + protobuf_1_4_3.default = true; + quick_error_0_2_2.default = true; + spin_0_4_6.default = (f.spin_0_4_6.default or false); + spin_0_4_6.unstable = + (f.spin_0_4_6.unstable or false) || + (prometheus_0_3_11.nightly or false) || + (f.prometheus_0_3_11.nightly or false); + }) [ cfg_if_0_1_2_features fnv_1_0_6_features lazy_static_0_2_11_features protobuf_1_4_3_features quick_error_0_2_2_features spin_0_4_6_features ]; + protobuf_1_4_3 = { features?(protobuf_1_4_3_features {}) }: protobuf_1_4_3_ { + dependencies = mapFeatures features ([]); + features = mkFeatures (features.protobuf_1_4_3 or {}); + }; + protobuf_1_4_3_features = f: updateFeatures f (rec { + protobuf_1_4_3.bytes = + (f.protobuf_1_4_3.bytes or false) || + (f.protobuf_1_4_3.with-bytes or false) || + (protobuf_1_4_3.with-bytes or false); + protobuf_1_4_3.default = (f.protobuf_1_4_3.default or true); + }) []; + quick_error_0_2_2 = { features?(quick_error_0_2_2_features {}) }: quick_error_0_2_2_ {}; + quick_error_0_2_2_features = f: updateFeatures f (rec { + quick_error_0_2_2.default = (f.quick_error_0_2_2.default or true); + }) []; quote_0_3_15 = { features?(quote_0_3_15_features {}) }: quote_0_3_15_ {}; quote_0_3_15_features = f: updateFeatures f (rec { quote_0_3_15.default = (f.quote_0_3_15.default or true); @@ -1588,6 +1683,34 @@ rec { (f.serde_json_1_0_9.preserve_order or false) || (serde_json_1_0_9.preserve_order or false); }) [ dtoa_0_4_2_features itoa_0_3_4_features num_traits_0_1_41_features serde_1_0_27_features ]; + spin_0_4_6 = { features?(spin_0_4_6_features {}) }: spin_0_4_6_ { + features = mkFeatures (features.spin_0_4_6 or {}); + }; + spin_0_4_6_features = f: updateFeatures f (rec { + spin_0_4_6.asm = + (f.spin_0_4_6.asm or false) || + (f.spin_0_4_6.unstable or false) || + (spin_0_4_6.unstable or false); + spin_0_4_6.const_fn = + (f.spin_0_4_6.const_fn or false) || + (f.spin_0_4_6.once or false) || + (spin_0_4_6.once or false) || + (f.spin_0_4_6.unstable or false) || + (spin_0_4_6.unstable or false); + spin_0_4_6.core_intrinsics = + (f.spin_0_4_6.core_intrinsics or false) || + (f.spin_0_4_6.unstable or false) || + (spin_0_4_6.unstable or false); + spin_0_4_6.default = (f.spin_0_4_6.default or true); + spin_0_4_6.once = + (f.spin_0_4_6.once or false) || + (f.spin_0_4_6.unstable or false) || + (spin_0_4_6.unstable or false); + spin_0_4_6.unstable = + (f.spin_0_4_6.unstable or false) || + (f.spin_0_4_6.default or false) || + (spin_0_4_6.default or false); + }) []; syn_0_11_11 = { features?(syn_0_11_11_features {}) }: syn_0_11_11_ { dependencies = mapFeatures features ([ ] ++ (if features.syn_0_11_11.quote or false then [ quote_0_3_15 ] else []) diff --git a/ofborg/Cargo.lock b/ofborg/Cargo.lock index e766847..092422c 100644 --- a/ofborg/Cargo.lock +++ b/ofborg/Cargo.lock @@ -166,6 +166,11 @@ dependencies = [ "backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "foreign-types" version = "0.3.2" @@ -385,6 +390,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "md5 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "prometheus 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -425,6 +431,29 @@ name = "pkg-config" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "prometheus" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "protobuf" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quick-error" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.3.15" @@ -552,6 +581,11 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "spin" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syn" version = "0.11.11" @@ -765,6 +799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" +"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" @@ -796,6 +831,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum openssl-sys 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "14ba54ac7d5a4eabd1d5f2c1fdeb7e7c14debfa669d94b983d01b465e767ba9e" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" +"checksum prometheus 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "71a963c5a59b4459a8133e60f8170df6fd29b67c0e6de5d45521d3056465bbfc" +"checksum protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bec26e67194b7d991908145fdf21b7cae8b08423d96dcb9e860cd31f854b9506" +"checksum quick-error 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ac990ab4e038dd8481a5e3fd00641067fcfc674ad663f3222752ed5284e05d4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "512870020642bb8c221bf68baa1b2573da814f6ccfe5c9699b1c303047abe9b1" "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" @@ -812,6 +850,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" "checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" "checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" +"checksum spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4deb3c2455c73779e6d3eebceae9599fc70957e54c69fe88f93aa48e62f432" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index 5e4aade..2966039 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -23,6 +23,7 @@ hubcaps = { git = "https://github.com/grahamc/hubcaps.git" } hyper = "0.10.*" hyper-native-tls = "0.2.4" lru-cache = "0.1.1" +prometheus = "0.3.11" #[patch.crates-io] From fd54190f00e8b6d19ba1edd4026fa2c99d45aa05 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 8 Feb 2018 10:04:40 -0500 Subject: [PATCH 04/47] Initial stats work --- ofborg/Cargo.lock | 4 +- ofborg/Cargo.toml | 3 +- ofborg/src/bin/mass-rebuilder.rs | 5 +- ofborg/src/bin/stats.rs | 83 ++++++++++ ofborg/src/lib.rs | 4 + ofborg/src/stats.rs | 35 ++++- ofborg/src/tasks/massrebuilder.rs | 13 +- ofborg/src/tasks/mod.rs | 1 + ofborg/src/tasks/statscollector.rs | 241 +++++++++++++++++++++++++++++ ofborg/src/worker.rs | 4 +- 10 files changed, 374 insertions(+), 19 deletions(-) create mode 100644 ofborg/src/bin/stats.rs create mode 100644 ofborg/src/tasks/statscollector.rs diff --git a/ofborg/Cargo.lock b/ofborg/Cargo.lock index 092422c..56a1a46 100644 --- a/ofborg/Cargo.lock +++ b/ofborg/Cargo.lock @@ -390,7 +390,7 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "md5 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "prometheus 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "prometheus 0.3.11", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -434,7 +434,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "prometheus" version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -831,7 +830,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum openssl-sys 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "14ba54ac7d5a4eabd1d5f2c1fdeb7e7c14debfa669d94b983d01b465e767ba9e" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" -"checksum prometheus 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "71a963c5a59b4459a8133e60f8170df6fd29b67c0e6de5d45521d3056465bbfc" "checksum protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bec26e67194b7d991908145fdf21b7cae8b08423d96dcb9e860cd31f854b9506" "checksum quick-error 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ac990ab4e038dd8481a5e3fd00641067fcfc674ad663f3222752ed5284e05d4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index 2966039..9fa8429 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -23,7 +23,8 @@ hubcaps = { git = "https://github.com/grahamc/hubcaps.git" } hyper = "0.10.*" hyper-native-tls = "0.2.4" lru-cache = "0.1.1" -prometheus = "0.3.11" +# prometheus = "0.3.11" +prometheus = { path = "../rust-prometheus/" } # for testing patches #[patch.crates-io] diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index 8f0a5a5..d98d870 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -30,7 +30,10 @@ fn main() { let cloner = checkout::cached_cloner(Path::new(&cfg.checkout.root)); let nix = cfg.nix(); - let events = stats::RabbitMQ::new(session.open_channel(3).unwrap()); + let events = stats::RabbitMQ::new( + &format!("{}-{}", cfg.runner.identity.clone(), cfg.nix.system.clone()), + session.open_channel(3).unwrap() + ); let mrw = tasks::massrebuilder::MassRebuildWorker::new( cloner, diff --git a/ofborg/src/bin/stats.rs b/ofborg/src/bin/stats.rs new file mode 100644 index 0000000..257e819 --- /dev/null +++ b/ofborg/src/bin/stats.rs @@ -0,0 +1,83 @@ +extern crate hyper; +extern crate prometheus; +extern crate amqp; +extern crate ofborg; + +use std::env; +use ofborg::{easyamqp, tasks, worker, config, stats}; + +use amqp::Basic; +use ofborg::easyamqp::TypedWrappers; +use hyper::header::ContentType; +use hyper::mime::Mime; +use hyper::server::{Request, Response, Server}; +use prometheus::{Counter, Encoder, Gauge, HistogramVec, TextEncoder}; + +use std::thread; +use std::time::Duration; + +fn main() { + let cfg = config::load(env::args().nth(1).unwrap().as_ref()); + ofborg::setup_log(); + + println!("Hello, world!"); + + + let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); + println!("Connected to rabbitmq"); + + let events = stats::RabbitMQ::new( + &format!("{}-{}", cfg.runner.identity.clone(), cfg.nix.system.clone()), + session.open_channel(3).unwrap() + ); + + let collector = tasks::statscollector::StatCollectorWorker::new( + events + ); + + let mut channel = session.open_channel(1).unwrap(); + + channel.basic_prefetch(1).unwrap(); + channel + .consume( + worker::new(collector), + easyamqp::ConsumeConfig { + queue: "sample-stats-events".to_owned(), + consumer_tag: format!("{}-prometheus-stats-collector", cfg.whoami()), + no_local: false, + no_ack: false, + no_wait: false, + exclusive: false, + arguments: None, + }, + ) + .unwrap(); + + + thread::spawn(||{ + let encoder = TextEncoder::new(); + let addr = "127.0.0.1:9898"; + println!("listening addr {:?}", addr); + Server::http(addr) + .unwrap() + .handle(move |_: Request, mut res: Response| { + let metric_familys = prometheus::gather(); + let mut buffer = vec![]; + encoder.encode(&metric_familys, &mut buffer).unwrap(); + res.headers_mut() + .set(ContentType(encoder.format_type().parse::().unwrap())); + res.send(&buffer).unwrap(); + }) + .unwrap(); + }); + + + channel.start_consuming(); + + println!("Finished consuming?"); + + channel.close(200, "Bye").unwrap(); + println!("Closed the channel"); + session.close(200, "Good Bye"); + println!("Closed the session... EOF"); +} diff --git a/ofborg/src/lib.rs b/ofborg/src/lib.rs index bda70db..12f3430 100644 --- a/ofborg/src/lib.rs +++ b/ofborg/src/lib.rs @@ -1,3 +1,7 @@ +#[macro_use] +extern crate prometheus; + + #[macro_use] extern crate serde_derive; extern crate serde; diff --git a/ofborg/src/stats.rs b/ofborg/src/stats.rs index 87c8dc0..3c779a4 100644 --- a/ofborg/src/stats.rs +++ b/ofborg/src/stats.rs @@ -1,23 +1,43 @@ +use serde_json; use amqp::Channel; use amqp::protocol::basic::BasicProperties; use amqp::Basic; -pub trait SysEvents { - fn tick(&mut self, name: &str); +pub trait SysEvents: Send { + fn notify(&mut self, event: Event); +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all="kebab-case")] +pub enum Event { + StatCollectorLegacyEvent, + StatCollectorBogusEvent, + JobReceived, + JobDecodeSuccess, + JobDecodeFailure, + IssueAlreadyClosed, + IssueFetchFailed, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct EventMessage { + pub sender: String, + pub events: Vec, } pub struct RabbitMQ { + identity: String, channel: Channel, } impl RabbitMQ { - pub fn new(channel: Channel) -> RabbitMQ { - RabbitMQ { channel: channel } + pub fn new(identity: &str, channel: Channel) -> RabbitMQ { + RabbitMQ { identity: identity.to_owned(), channel: channel } } } impl SysEvents for RabbitMQ { - fn tick(&mut self, name: &str) { + fn notify(&mut self, event: Event) { let props = BasicProperties { ..Default::default() }; self.channel .basic_publish( @@ -26,7 +46,10 @@ impl SysEvents for RabbitMQ { false, false, props, - String::from(name).into_bytes(), + serde_json::to_string(&EventMessage { + sender: self.identity.clone(), + events: vec![event], + }).unwrap().into_bytes(), ) .unwrap(); } diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 155143b..0266bdf 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -14,6 +14,7 @@ use ofborg::nix::Nix; use ofborg::acl::ACL; use ofborg::stats; +use ofborg::stats::Event; use ofborg::worker; use ofborg::tagger::{StdenvTagger, RebuildTagger, PathsTagger, PkgsAddedRemovedTagger}; use ofborg::outpathdiff::{OutPaths, OutPathDiff}; @@ -73,7 +74,7 @@ impl MassRebuildWorker { } } -impl worker::SimpleWorker for MassRebuildWorker { +impl worker::SimpleWorker for MassRebuildWorker { type J = massrebuildjob::MassRebuildJob; fn msg_to_job( @@ -82,14 +83,14 @@ impl worker::SimpleWorker for MassRebuildWorker { _: &BasicProperties, body: &Vec, ) -> Result { - self.events.tick("job-received"); + self.events.notify(Event::JobReceived); return match massrebuildjob::from(body) { Ok(e) => { - self.events.tick("job-decode-success"); + self.events.notify(Event::JobDecodeSuccess); Ok(e) } Err(e) => { - self.events.tick("job-decode-failure"); + self.events.notify(Event::JobDecodeFailure); error!( "Failed to decode message: {:?}, Err: {:?}", String::from_utf8(body.clone()), @@ -113,7 +114,7 @@ impl worker::SimpleWorker for MassRebuildWorker { match issue.get() { Ok(iss) => { if iss.state == "closed" { - self.events.tick("issue-already-closed"); + self.events.notify(Event::IssueAlreadyClosed); info!("Skipping {} because it is closed", job.pr.number); return self.actions().skip(&job); } @@ -128,7 +129,7 @@ impl worker::SimpleWorker for MassRebuildWorker { } } Err(e) => { - self.events.tick("issue-fetch-failed"); + self.events.notify(Event::IssueFetchFailed); info!("Error fetching {}!", job.pr.number); info!("E: {:?}", e); return self.actions().skip(&job); diff --git a/ofborg/src/tasks/mod.rs b/ofborg/src/tasks/mod.rs index d735e60..663bab6 100644 --- a/ofborg/src/tasks/mod.rs +++ b/ofborg/src/tasks/mod.rs @@ -3,4 +3,5 @@ pub mod build; pub mod massrebuilder; pub mod githubcommentfilter; pub mod githubcommentposter; +pub mod statscollector; pub mod log_message_collector; diff --git a/ofborg/src/tasks/statscollector.rs b/ofborg/src/tasks/statscollector.rs new file mode 100644 index 0000000..94b988c --- /dev/null +++ b/ofborg/src/tasks/statscollector.rs @@ -0,0 +1,241 @@ +extern crate prometheus; +extern crate amqp; +extern crate env_logger; + +use serde_json; +use std::str::FromStr; +use ofborg::worker; +use ofborg::stats; +use amqp::protocol::basic::{Deliver, BasicProperties}; +use std::collections::HashMap; +use std::mem; +use std::thread; +use std::time::Duration; +use std::sync::Arc; +use std::sync::Mutex; + +pub struct StatCollectorWorker { + events: E, + counter_collectors: HashMap, +} + +impl StatCollectorWorker { + pub fn new(events: E) -> StatCollectorWorker { + let mut worker = StatCollectorWorker { + events: events, + counter_collectors: HashMap::new(), + }; + + let initial_events: Vec = vec![ + stats::Event::StatCollectorLegacyEvent, + stats::Event::StatCollectorBogusEvent, + stats::Event::JobReceived, + stats::Event::JobDecodeSuccess, + stats::Event::JobDecodeFailure, + stats::Event::IssueAlreadyClosed, + stats::Event::IssueFetchFailed, + ]; + for initial_event in initial_events { + match initial_event { + // WARNING + // BEFORE YOU ADD A NEW VARIANT HERE, ADD IT + // TO THE LIST ABOVE! + // + // EACH VARIANT MUST BE INITIALIZED PRIOR + // TO REPORTING STATS + stats::Event::StatCollectorLegacyEvent => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "stats_collector".to_owned(), + name: "legacy_event".to_owned(), + help: "Number of received legacy events".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + ); + }, + stats::Event::StatCollectorBogusEvent => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "stats_collector".to_owned(), + name: "bogus_event".to_owned(), + help: "Number of received unparseable events".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + ); + }, + stats::Event::JobReceived => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "generic_worker".to_owned(), + name: "job_received".to_owned(), + help: "Number of received worker jobs".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + ); + }, + stats::Event::JobDecodeSuccess => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "generic_worker".to_owned(), + name: "job_decode_successful".to_owned(), + help: "Number of successfully decoded jobs".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + ); + }, + stats::Event::JobDecodeFailure => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "generic_worker".to_owned(), + name: "job_decode_failure".to_owned(), + help: "Number of jobs which failed to parse".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + ); + }, + stats::Event::IssueAlreadyClosed => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "github".to_owned(), + name: "issue_closed".to_owned(), + help: "Number of jobs for issues which are already closed".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + + ); + }, + stats::Event::IssueFetchFailed => { + worker.register_counter( + &initial_event, + prometheus::Opts { + namespace: "ofborg".to_owned(), + subsystem: "github".to_owned(), + name: "issue_fetch_fail".to_owned(), + help: "Number of failed fetches for GitHub issues".to_owned(), + const_labels: HashMap::new(), + variable_labels: vec!["instance".to_owned()], + } + ); + }, + }; + } + + return worker; + } + + pub fn counter(&self, event: &stats::Event) -> prometheus::CounterVec { + let disc = format!("{:?}", mem::discriminant(event)); + self.counter_collectors.get(&disc).unwrap().clone() + } + + pub fn register_counter( + &mut self, + event: &stats::Event, + opts: prometheus::Opts, + ) { + let disc = format!("{:?}", mem::discriminant(event)); + let orig_labels = opts.variable_labels.clone(); + let labels: Vec<&str> = orig_labels + .iter() + .map(|v| v.as_ref()) + .collect(); + + let counter = register_counter_vec!( + opts, labels.as_ref() + ).unwrap(); + counter.with_label_values(&[""]).inc_by(0.0); + + self.counter_collectors.insert( + disc, + counter + ); + } +} + +impl worker::SimpleWorker for StatCollectorWorker { + type J = stats::EventMessage; + + fn msg_to_job( + &mut self, + _: &Deliver, + _: &BasicProperties, + body: &Vec, + ) -> Result { + return match serde_json::from_slice(body) { + Ok(e) => Ok(e), + Err(_) => { + let mut modified_body: Vec = vec!["\"".as_bytes()[0]]; + modified_body.append(&mut body.clone()); + modified_body.push("\"".as_bytes()[0]); + + match serde_json::from_slice(&modified_body) { + Ok(e) => { + self.events.notify(stats::Event::StatCollectorLegacyEvent); + Ok(stats::EventMessage { + sender: "".to_owned(), + events: vec![e], + }) + }, + Err(e) => { + self.events.notify(stats::Event::StatCollectorBogusEvent); + error!( + "Failed to decode message: {:?}, Err: {:?}", + String::from_utf8(body.clone()), + e + ); + Err("Failed to decode message".to_owned()) + } + } + } + }; + } + + fn consumer(&mut self, job: &stats::EventMessage) -> worker::Actions { + let sender = job.sender.clone(); + for event in job.events.iter() { + match *event { + stats::Event::StatCollectorLegacyEvent => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + stats::Event::StatCollectorBogusEvent => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + stats::Event::JobReceived => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + stats::Event::JobDecodeSuccess => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + stats::Event::JobDecodeFailure => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + stats::Event::IssueAlreadyClosed => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + stats::Event::IssueFetchFailed => { + self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); + }, + } + } + + return vec![worker::Action::Ack]; + } +} diff --git a/ofborg/src/worker.rs b/ofborg/src/worker.rs index 0b18e2c..62922ae 100644 --- a/ofborg/src/worker.rs +++ b/ofborg/src/worker.rs @@ -54,8 +54,8 @@ where }); } -pub trait SimpleWorker { - type J; +pub trait SimpleWorker: Send + 'static { + type J: Send; fn consumer(&mut self, job: &Self::J) -> Actions; From d749fe5f4dc1f1af2c3d4935abd940a918939bcc Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 12 Feb 2018 08:20:43 -0500 Subject: [PATCH 05/47] Implement a nicer stats API but with gross code gen --- nix/ofborg-carnix.nix | 130 +------ ofborg/Cargo.lock | 37 -- ofborg/Cargo.toml | 7 +- ofborg/build.rs | 597 +++++++++++++++++++++++++++++ ofborg/src/bin/stats.rs | 19 +- ofborg/src/lib.rs | 4 - ofborg/src/stats.rs | 19 +- ofborg/src/tasks/statscollector.rs | 185 +-------- 8 files changed, 624 insertions(+), 374 deletions(-) create mode 100644 ofborg/build.rs diff --git a/nix/ofborg-carnix.nix b/nix/ofborg-carnix.nix index a27a016..ae804a3 100644 --- a/nix/ofborg-carnix.nix +++ b/nix/ofborg-carnix.nix @@ -210,14 +210,6 @@ rec { sha256 = "1xxbzd8cjlpzsb9fsih7mdnndhzrvykj0w77yg90qc85az1xwy5z"; inherit dependencies buildDependencies features; }; - fnv_1_0_6_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { - crateName = "fnv"; - version = "1.0.6"; - authors = [ "Alex Crichton " ]; - sha256 = "128mlh23y3gg6ag5h8iiqlcbl59smisdzraqy88ldrf75kbw27ip"; - libPath = "lib.rs"; - inherit dependencies buildDependencies features; - }; foreign_types_0_3_2_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "foreign-types"; version = "0.3.2"; @@ -418,7 +410,8 @@ rec { crateName = "ofborg"; version = "0.1.1"; authors = [ "Graham Christensen " ]; - src = include [ "Cargo.toml" "Cargo.lock" "src" "test-srcs" ] ./../ofborg; + src = include [ "Cargo.toml" "Cargo.lock" "src" "test-srcs" "build.rs" ] ./../ofborg; + build = "build.rs"; inherit dependencies buildDependencies features; }; openssl_0_9_23_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { @@ -452,28 +445,6 @@ rec { sha256 = "06k8fxgrsrxj8mjpjcq1n7mn2p1shpxif4zg9y5h09c7vy20s146"; inherit dependencies buildDependencies features; }; - prometheus_0_3_11_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { - crateName = "prometheus"; - version = "0.3.11"; - authors = [ "overvenus@gmail.com" "siddontang@gmail.com" ]; - sha256 = "1c5vcy771cwpd14adgknf7pmf603p8nf4q90ik7ry083vxrvbmbg"; - inherit dependencies buildDependencies features; - }; - protobuf_1_4_3_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { - crateName = "protobuf"; - version = "1.4.3"; - authors = [ "Stepan Koltsov " ]; - sha256 = "093fczpx523lm6d7xr5d4mqs88891ay6wk951yck3cavsz35z00b"; - crateBin = [ { name = "protoc-gen-rust"; path = "protoc-gen-rust.rs"; } { name = "protobuf-bin-gen-rust-do-not-use"; path = "protobuf-bin-gen-rust-do-not-use.rs"; } ]; - inherit dependencies buildDependencies features; - }; - quick_error_0_2_2_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { - crateName = "quick-error"; - version = "0.2.2"; - authors = [ "Paul Colomiets " "Colin Kiegel " ]; - sha256 = "0r1f4ps998y779qwvnmmxhjq00qh5wxg3m5inswfawg0vr2732db"; - inherit dependencies buildDependencies features; - }; quote_0_3_15_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "quote"; version = "0.3.15"; @@ -589,13 +560,6 @@ rec { sha256 = "1pcclssyndz54cncsizkqrblmqqr1p2g6xhkpwldbk6qc95m4yw3"; inherit dependencies buildDependencies features; }; - spin_0_4_6_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { - crateName = "spin"; - version = "0.4.6"; - authors = [ "Mathijs van de Nes " "John Ericson " ]; - sha256 = "1mp30r3pxb38m6mszcgn6136d1r162fwcidg3y4d9rym21hmialj"; - inherit dependencies buildDependencies features; - }; syn_0_11_11_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "syn"; version = "0.11.11"; @@ -1062,10 +1026,6 @@ rec { (f.error_chain_0_10_0.default or false) || (error_chain_0_10_0.default or false); }) [ backtrace_0_3_5_features ]; - fnv_1_0_6 = { features?(fnv_1_0_6_features {}) }: fnv_1_0_6_ {}; - fnv_1_0_6_features = f: updateFeatures f (rec { - fnv_1_0_6.default = (f.fnv_1_0_6.default or true); - }) []; foreign_types_0_3_2 = { features?(foreign_types_0_3_2_features {}) }: foreign_types_0_3_2_ { dependencies = mapFeatures features ([ foreign_types_shared_0_1_1 ]); }; @@ -1365,7 +1325,7 @@ rec { num_cpus_1_8_0.default = (f.num_cpus_1_8_0.default or true); }) [ libc_0_2_36_features ]; ofborg_0_1_1 = { features?(ofborg_0_1_1_features {}) }: ofborg_0_1_1_ { - dependencies = mapFeatures features ([ amqp_0_1_0 env_logger_0_4_3 fs2_0_4_3 hubcaps_0_3_16 hyper_0_10_13 hyper_native_tls_0_2_4 log_0_3_8 lru_cache_0_1_1 md5_0_3_6 prometheus_0_3_11 serde_1_0_27 serde_derive_1_0_27 serde_json_1_0_9 tempfile_2_2_0 uuid_0_4_0 ]); + dependencies = mapFeatures features ([ amqp_0_1_0 env_logger_0_4_3 fs2_0_4_3 hubcaps_0_3_16 hyper_0_10_13 hyper_native_tls_0_2_4 log_0_3_8 lru_cache_0_1_1 md5_0_3_6 serde_1_0_27 serde_derive_1_0_27 serde_json_1_0_9 tempfile_2_2_0 uuid_0_4_0 ]); }; ofborg_0_1_1_features = f: updateFeatures f (rec { amqp_0_1_0.default = true; @@ -1378,14 +1338,13 @@ rec { lru_cache_0_1_1.default = true; md5_0_3_6.default = true; ofborg_0_1_1.default = (f.ofborg_0_1_1.default or true); - prometheus_0_3_11.default = true; serde_1_0_27.default = true; serde_derive_1_0_27.default = true; serde_json_1_0_9.default = true; tempfile_2_2_0.default = true; uuid_0_4_0.default = true; uuid_0_4_0.v4 = true; - }) [ amqp_0_1_0_features env_logger_0_4_3_features fs2_0_4_3_features hubcaps_0_3_16_features hyper_0_10_13_features hyper_native_tls_0_2_4_features log_0_3_8_features lru_cache_0_1_1_features md5_0_3_6_features prometheus_0_3_11_features serde_1_0_27_features serde_derive_1_0_27_features serde_json_1_0_9_features tempfile_2_2_0_features uuid_0_4_0_features ]; + }) [ amqp_0_1_0_features env_logger_0_4_3_features fs2_0_4_3_features hubcaps_0_3_16_features hyper_0_10_13_features hyper_native_tls_0_2_4_features log_0_3_8_features lru_cache_0_1_1_features md5_0_3_6_features serde_1_0_27_features serde_derive_1_0_27_features serde_json_1_0_9_features tempfile_2_2_0_features uuid_0_4_0_features ]; openssl_0_9_23 = { features?(openssl_0_9_23_features {}) }: openssl_0_9_23_ { dependencies = mapFeatures features ([ bitflags_0_9_1 foreign_types_0_3_2 lazy_static_1_0_0 libc_0_2_36 openssl_sys_0_9_24 ]); features = mkFeatures (features.openssl_0_9_23 or {}); @@ -1417,59 +1376,6 @@ rec { pkg_config_0_3_9_features = f: updateFeatures f (rec { pkg_config_0_3_9.default = (f.pkg_config_0_3_9.default or true); }) []; - prometheus_0_3_11 = { features?(prometheus_0_3_11_features {}) }: prometheus_0_3_11_ { - dependencies = mapFeatures features ([ cfg_if_0_1_2 fnv_1_0_6 lazy_static_0_2_11 protobuf_1_4_3 quick_error_0_2_2 spin_0_4_6 ]) - ++ (if kernel == "linux" then mapFeatures features ([]) else []); - features = mkFeatures (features.prometheus_0_3_11 or {}); - }; - prometheus_0_3_11_features = f: updateFeatures f (rec { - cfg_if_0_1_2.default = true; - fnv_1_0_6.default = true; - lazy_static_0_2_11.default = true; - prometheus_0_3_11.clippy = - (f.prometheus_0_3_11.clippy or false) || - (f.prometheus_0_3_11.dev or false) || - (prometheus_0_3_11.dev or false); - prometheus_0_3_11.default = (f.prometheus_0_3_11.default or true); - prometheus_0_3_11.hyper = - (f.prometheus_0_3_11.hyper or false) || - (f.prometheus_0_3_11.push or false) || - (prometheus_0_3_11.push or false); - prometheus_0_3_11.libc = - (f.prometheus_0_3_11.libc or false) || - (f.prometheus_0_3_11.nightly or false) || - (prometheus_0_3_11.nightly or false) || - (f.prometheus_0_3_11.process or false) || - (prometheus_0_3_11.process or false) || - (f.prometheus_0_3_11.push or false) || - (prometheus_0_3_11.push or false); - prometheus_0_3_11.procinfo = - (f.prometheus_0_3_11.procinfo or false) || - (f.prometheus_0_3_11.process or false) || - (prometheus_0_3_11.process or false); - protobuf_1_4_3.default = true; - quick_error_0_2_2.default = true; - spin_0_4_6.default = (f.spin_0_4_6.default or false); - spin_0_4_6.unstable = - (f.spin_0_4_6.unstable or false) || - (prometheus_0_3_11.nightly or false) || - (f.prometheus_0_3_11.nightly or false); - }) [ cfg_if_0_1_2_features fnv_1_0_6_features lazy_static_0_2_11_features protobuf_1_4_3_features quick_error_0_2_2_features spin_0_4_6_features ]; - protobuf_1_4_3 = { features?(protobuf_1_4_3_features {}) }: protobuf_1_4_3_ { - dependencies = mapFeatures features ([]); - features = mkFeatures (features.protobuf_1_4_3 or {}); - }; - protobuf_1_4_3_features = f: updateFeatures f (rec { - protobuf_1_4_3.bytes = - (f.protobuf_1_4_3.bytes or false) || - (f.protobuf_1_4_3.with-bytes or false) || - (protobuf_1_4_3.with-bytes or false); - protobuf_1_4_3.default = (f.protobuf_1_4_3.default or true); - }) []; - quick_error_0_2_2 = { features?(quick_error_0_2_2_features {}) }: quick_error_0_2_2_ {}; - quick_error_0_2_2_features = f: updateFeatures f (rec { - quick_error_0_2_2.default = (f.quick_error_0_2_2.default or true); - }) []; quote_0_3_15 = { features?(quote_0_3_15_features {}) }: quote_0_3_15_ {}; quote_0_3_15_features = f: updateFeatures f (rec { quote_0_3_15.default = (f.quote_0_3_15.default or true); @@ -1683,34 +1589,6 @@ rec { (f.serde_json_1_0_9.preserve_order or false) || (serde_json_1_0_9.preserve_order or false); }) [ dtoa_0_4_2_features itoa_0_3_4_features num_traits_0_1_41_features serde_1_0_27_features ]; - spin_0_4_6 = { features?(spin_0_4_6_features {}) }: spin_0_4_6_ { - features = mkFeatures (features.spin_0_4_6 or {}); - }; - spin_0_4_6_features = f: updateFeatures f (rec { - spin_0_4_6.asm = - (f.spin_0_4_6.asm or false) || - (f.spin_0_4_6.unstable or false) || - (spin_0_4_6.unstable or false); - spin_0_4_6.const_fn = - (f.spin_0_4_6.const_fn or false) || - (f.spin_0_4_6.once or false) || - (spin_0_4_6.once or false) || - (f.spin_0_4_6.unstable or false) || - (spin_0_4_6.unstable or false); - spin_0_4_6.core_intrinsics = - (f.spin_0_4_6.core_intrinsics or false) || - (f.spin_0_4_6.unstable or false) || - (spin_0_4_6.unstable or false); - spin_0_4_6.default = (f.spin_0_4_6.default or true); - spin_0_4_6.once = - (f.spin_0_4_6.once or false) || - (f.spin_0_4_6.unstable or false) || - (spin_0_4_6.unstable or false); - spin_0_4_6.unstable = - (f.spin_0_4_6.unstable or false) || - (f.spin_0_4_6.default or false) || - (spin_0_4_6.default or false); - }) []; syn_0_11_11 = { features?(syn_0_11_11_features {}) }: syn_0_11_11_ { dependencies = mapFeatures features ([ ] ++ (if features.syn_0_11_11.quote or false then [ quote_0_3_15 ] else []) diff --git a/ofborg/Cargo.lock b/ofborg/Cargo.lock index 56a1a46..e766847 100644 --- a/ofborg/Cargo.lock +++ b/ofborg/Cargo.lock @@ -166,11 +166,6 @@ dependencies = [ "backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "foreign-types" version = "0.3.2" @@ -390,7 +385,6 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "md5 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "prometheus 0.3.11", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -431,28 +425,6 @@ name = "pkg-config" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "prometheus" -version = "0.3.11" -dependencies = [ - "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "protobuf" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quick-error" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "0.3.15" @@ -580,11 +552,6 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "spin" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "syn" version = "0.11.11" @@ -798,7 +765,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" -"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" @@ -830,8 +796,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum openssl-sys 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "14ba54ac7d5a4eabd1d5f2c1fdeb7e7c14debfa669d94b983d01b465e767ba9e" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" -"checksum protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bec26e67194b7d991908145fdf21b7cae8b08423d96dcb9e860cd31f854b9506" -"checksum quick-error 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ac990ab4e038dd8481a5e3fd00641067fcfc674ad663f3222752ed5284e05d4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "512870020642bb8c221bf68baa1b2573da814f6ccfe5c9699b1c303047abe9b1" "checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" @@ -848,7 +812,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" "checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" "checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" -"checksum spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4deb3c2455c73779e6d3eebceae9599fc70957e54c69fe88f93aa48e62f432" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index 9fa8429..9607cc4 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -2,8 +2,8 @@ name = "ofborg" version = "0.1.1" authors = ["Graham Christensen "] -include = ["Cargo.toml", "Cargo.lock", "src", "test-srcs"] - +include = ["Cargo.toml", "Cargo.lock", "src", "test-srcs", "build.rs"] +build = "build.rs" [dependencies] @@ -23,9 +23,6 @@ hubcaps = { git = "https://github.com/grahamc/hubcaps.git" } hyper = "0.10.*" hyper-native-tls = "0.2.4" lru-cache = "0.1.1" -# prometheus = "0.3.11" -prometheus = { path = "../rust-prometheus/" } # for testing patches - #[patch.crates-io] #amq-proto = { path = "rust-amq-proto" } \ No newline at end of file diff --git a/ofborg/build.rs b/ofborg/build.rs new file mode 100644 index 0000000..e458dcf --- /dev/null +++ b/ofborg/build.rs @@ -0,0 +1,597 @@ + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::Path; + +enum MetricType { + Ticker(Metric), + Counter(Metric), +} + +impl MetricType { + fn collector_type(&self) -> String { + match self { + &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 { + format!("{}({})", self.variant(), fields.join(", ")) + } else { + format!("{}", self.variant()) + } + } + + fn variant(&self) -> String { + match self { + &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") + } + } + } + + fn metric_name(&self) -> String { + match self { + &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() + } + } + } + + fn enum_index_types(&self) -> Vec { + let event: &Metric; + + match self { + &MetricType::Ticker(ref i_event) => { + event = i_event; + } + &MetricType::Counter(ref i_event) => { + event = i_event; + } + } + + let fields: Vec = event.fields + .iter() + .map(|&(ref _fieldname, ref fieldtype)| fieldtype.clone()) + .collect(); + + return fields + } + + fn enum_field_types(&self) -> Vec { + let mut extra_fields: Vec = vec![]; + + match self { + &MetricType::Ticker(_) => {} + &MetricType::Counter(_) => { + extra_fields = vec![self.collector_type()]; + } + } + + let mut fields: Vec = self.enum_index_types(); + fields.append(&mut extra_fields); + + return fields + } + + fn enum_index_names(&self) -> Vec { + let event: &Metric; + + match self { + &MetricType::Ticker(ref i_event) => { + event = i_event; + } + &MetricType::Counter(ref i_event) => { + event = i_event; + } + } + + let fields: Vec = event.fields + .iter() + .map(|&(ref fieldname, ref _fieldtype)| fieldname.clone()) + .collect(); + + return fields + } + + fn enum_field_names(&self) -> Vec { + let mut extra_fields: Vec = vec![]; + + match self { + &MetricType::Ticker(_) => {} + &MetricType::Counter(_) => { + extra_fields = vec!["value".to_owned()]; + } + } + + let mut fields: Vec = self.enum_index_names(); + fields.append(&mut extra_fields); + + return fields + } + + fn record_value(&self) -> String { + match self { + &MetricType::Ticker(_) => { + String::from("1") + } + &MetricType::Counter(_) => { + String::from("value") + } + } + } +} + +struct Metric { + variant: String, + fields: Vec<(String,String)>, // Vec because it is sorted + metric_name: String, + description: String, +} + + +fn name_to_parts(name: &str) -> Vec { + let mut parts: Vec = vec![]; + let mut buf = String::from(""); + for c in name.chars() { + if char::is_uppercase(c) && buf.len() > 0 { + parts.push(buf.to_owned()); + buf = String::from(""); + } + buf.push_str(&c.to_string()); + } + if buf.len() > 0 { + parts.push(buf.to_owned()); + std::mem::drop(buf); + } + + + return parts; +} + +impl Metric { + pub fn ticker(name: &str, desc: &str, fields: Option>) -> MetricType { + let parts = name_to_parts(name); + + MetricType::Ticker(Metric { + variant: parts + .iter() + .map(|f| f.clone().to_owned()) + .collect(), + fields: fields + .unwrap_or(vec![]) + .iter() + .map(|&(ref fieldname, ref fieldtype)| (fieldname.clone().to_owned(), fieldtype.clone().to_owned())) + .collect(), + metric_name: parts.join("_").to_lowercase(), + description: desc.to_owned(), + }) + } + + pub fn counter(name: &str, desc: &str, fields: Option>) -> MetricType { + let parts = name_to_parts(name); + + MetricType::Counter(Metric { + variant: parts + .iter() + .map(|f| f.clone().to_owned()) + .collect(), + fields: fields + .unwrap_or(vec![]) + .iter() + .map(|&(ref fieldname, ref fieldtype)| (fieldname.clone().to_owned(), fieldtype.clone().to_owned())) + .collect(), + metric_name: parts.join("_").to_lowercase(), + description: desc.to_owned(), + }) + } +} + +fn events() -> Vec { + return vec![ + Metric::ticker( + "StatCollectorLegacyEvent", + "Number of received legacy events", + Some(vec![("event", "String")]), + ), + Metric::ticker( + "StatCollectorBogusEvent", + "Number of received unparseable events", + None, + ), + Metric::ticker( + "JobReceived", + "Number of received worker jobs", + None, + ), + Metric::counter( + "EvaluationDuration", + "Amount of time spent running evaluations", + None + ), + Metric::ticker( + "JobDecodeSuccess", + "Number of successfully decoded jobs", + None, + ), + Metric::ticker( + "JobDecodeFailure", + "Number of jobs which failed to parse", + None, + ), + Metric::ticker( + "IssueAlreadyClosed", + "Number of jobs for issues which are already closed", + None, + ), + Metric::ticker( + "IssueFetchFailed", + "Number of failed fetches for GitHub issues", + None, + ), + /* + Metric::counter( + "TimeElapsed", + "", + None + ), + Metric::counter( + "EnvironmentsAllocatedCount", + "", + None + ), + Metric::counter( + "EnvironmentsAllocatedBytes", + "", + None + ), + Metric::counter( + "ListElementsCount", + "", + None + ), + Metric::counter( + "ListElementsBytes", + "", + None + ), + Metric::counter( + "ListConcatenations", + "", + None + ), + Metric::counter( + "ValuesAllocatedCount", + "", + None + ), + Metric::counter( + "ValuesAllocatedBytes", + "", + None + ), + Metric::counter( + "SetsAllocatedCount", + "", + None + ), + Metric::counter( + "SetsAllocatedBytes", + "", + None + ), + Metric::counter( + "RightBiasedUnions", + "", + None + ), + Metric::counter( + "ValuesCopiedInRightBiasedUnions", + "", + None + ), + Metric::counter( + "SymbolsInSymbolTable", + "", + None + ), + Metric::counter( + "SizeOfSymbolTable", + "", + None + ), + Metric::counter( + "NumberOfThunks", + "", + None + ), + Metric::counter( + "NumberOfThunksAvoided", + "", + None + ), + Metric::counter( + "NumberOfAttrLookups", + "", + None + ), + Metric::counter( + "NumberOfPrimopCalls", + "", + None + ), + Metric::counter( + "NumberOfFunctionCalls", + "", + None + ), + Metric::counter( + "TotalAllocations", + "", + None + ), + Metric::counter( + "CurrentBoehmHeapSizeBytes", + "", + None + ), + Metric::counter( + "TotalBoehmHeapAllocationsBytes", + "", + None + ), + */ + ]; +} + +fn main() { + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("events.rs"); + let mut f = File::create(&dest_path).unwrap(); + + println!("cargo:rerun-if-changed=build.rs"); + + // Write the Event enum, which contains all possible event types + f.write_all(b" +use std::collections::HashMap; +use std::sync::Arc; +use std::sync::Mutex; +#[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(rename_all=\"kebab-case\")] +pub enum Event { +").unwrap(); + + let variants: Vec = events() + .iter() + .map(|mtype| format!(" {}", mtype.enum_matcher_types()) ) + .collect(); + + + f.write_all(variants.join(",\n").as_bytes()).unwrap(); + f.write_all("\n}\n\n".as_bytes()).unwrap(); + + f.write_all(b"pub fn event_metric_name(event: &Event) -> String { + match event { +").unwrap(); + + let variants: Vec = events() + .iter() + .map(|mtype| { + let fields: Vec = mtype.enum_field_names() + .iter() + .map(|_| String::from("_")) + .collect(); + + let variant_match: String; + if fields.len() > 0 { + variant_match = format!( + "{}({})", + &mtype.variant(), + fields + .join(", ")); + } else { + variant_match = format!("{}", &mtype.variant()); + } + + + format!(" &Event::{} => String::from(\"{}\")", + &variant_match, + &mtype.metric_name(), + ) + }).collect(); + + + f.write_all(variants.join(",\n").as_bytes()).unwrap(); + f.write_all("}\n }".as_bytes()).unwrap(); + + // Create a struct to hold all the possible metrics + f.write_all(b" +#[derive(Debug, Clone)] +pub struct MetricCollector { +").unwrap(); + + let variants: Vec = events() + .iter() + .map(|mtype| { + let mut fields: Vec = mtype.enum_index_types(); + fields.push("String".to_owned()); // Instance + + format!(" {}: Arc>>", + mtype.metric_name(), + fields.join(", "), + mtype.collector_type(), + ) + }).collect(); + + + f.write_all(variants.join(",\n").as_bytes()).unwrap(); + f.write_all("\n}\n\n".as_bytes()).unwrap(); + + // Create a struct to hold all the possible metrics + f.write_all(b" +impl MetricCollector { + pub fn new() -> MetricCollector { + MetricCollector { +").unwrap(); + + let variants: Vec = events() + .iter() + .map(|mtype| { + let mut fields: Vec = mtype.enum_field_types(); + fields.push("String".to_owned()); // Instance + + format!(" {}: Arc::new(Mutex::new(HashMap::new()))", + &mtype.metric_name(), + ) + }).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" + pub fn record(&self, instance: String, event: Event) { + match event { +").unwrap(); + + let variants: Vec = events() + .iter() + .map(|mtype| { + let fields: Vec = mtype.enum_field_names(); + + let variant_match: String; + if fields.len() > 0 { + variant_match = format!("{}({})", &mtype.variant(), fields.join(", ")); + } else { + variant_match = format!("{}", &mtype.variant()); + } + + let mut index_fields: Vec = mtype.enum_index_names(); + index_fields.push("instance".to_owned()); + + + format!(" + Event::{} => {{ + let mut accum_table = self.{} + .lock() + .expect(\"Failed to unwrap metric mutex for {}\"); + let accum = accum_table + .entry(({})) + .or_insert(0); + *accum += {}; + }} + ", + variant_match, + &mtype.metric_name(), + &mtype.metric_name(), + index_fields.join(", "), + &mtype.record_value(), + ) + }).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"pub fn prometheus_output(&self) -> String { + let mut output = String::new(); +").unwrap(); + + let variants: Vec = events() + .iter() + .map(|mtype| { + let mut index_fields: Vec = mtype.enum_index_names(); + index_fields.push("instance".to_owned()); + let ref_index_fields: Vec = index_fields + .iter() + .map(|m| format!("ref {}", m)) + .collect(); + + let for_matcher: String; + if index_fields.len() > 1 { + for_matcher = format!("({})", + ref_index_fields.join(", ")); + } else { + for_matcher = ref_index_fields.join(", "); + } + + let key_value_pairs: Vec = index_fields + .iter() + .map(|name| format!(" format!(\"{}=\\\"{{}}\\\"\", {})", &name, &name)) + .collect(); + format!(" + output.push_str(\"# HELP ofborg_{} {}\n\"); + output.push_str(\"# TYPE ofborg_{} {}\n\"); + + let table = self.{}.lock() + .expect(\"Failed to unwrap metric mutex for {}\"); + let values: Vec = (*table) + .iter() + .map(|(&{}, value)| {{ + let kvs: Vec = vec![ +{} + ]; + format!(\"ofborg_{}{{{{{{}}}}}} {{}}\", kvs.join(\",\"), value) + }}) + .collect(); + output.push_str(&values.join(\"\n\")); + output.push_str(\"\n\"); + ", + &mtype.metric_name(), + &mtype.description(), + &mtype.metric_name(), + &mtype.metric_type(), + &mtype.metric_name(), + &mtype.metric_name(), + for_matcher, + &key_value_pairs.join(",\n"), + &mtype.metric_name(), + ) + }).collect(); + + + f.write_all(variants.join("\n").as_bytes()).unwrap(); + f.write_all("return output;\n }".as_bytes()).unwrap(); + f.write_all("\n}".as_bytes()).unwrap(); + +} diff --git a/ofborg/src/bin/stats.rs b/ofborg/src/bin/stats.rs index 257e819..9d7ce78 100644 --- a/ofborg/src/bin/stats.rs +++ b/ofborg/src/bin/stats.rs @@ -1,5 +1,4 @@ extern crate hyper; -extern crate prometheus; extern crate amqp; extern crate ofborg; @@ -8,10 +7,7 @@ use ofborg::{easyamqp, tasks, worker, config, stats}; use amqp::Basic; use ofborg::easyamqp::TypedWrappers; -use hyper::header::ContentType; -use hyper::mime::Mime; use hyper::server::{Request, Response, Server}; -use prometheus::{Counter, Encoder, Gauge, HistogramVec, TextEncoder}; use std::thread; use std::time::Duration; @@ -31,8 +27,11 @@ fn main() { session.open_channel(3).unwrap() ); + let metrics = stats::MetricCollector::new(); + let collector = tasks::statscollector::StatCollectorWorker::new( - events + events, + metrics.clone(), ); let mut channel = session.open_channel(1).unwrap(); @@ -55,18 +54,12 @@ fn main() { thread::spawn(||{ - let encoder = TextEncoder::new(); let addr = "127.0.0.1:9898"; println!("listening addr {:?}", addr); Server::http(addr) .unwrap() - .handle(move |_: Request, mut res: Response| { - let metric_familys = prometheus::gather(); - let mut buffer = vec![]; - encoder.encode(&metric_familys, &mut buffer).unwrap(); - res.headers_mut() - .set(ContentType(encoder.format_type().parse::().unwrap())); - res.send(&buffer).unwrap(); + .handle(move |_: Request, res: Response| { + res.send(metrics.prometheus_output().as_bytes()).unwrap(); }) .unwrap(); }); diff --git a/ofborg/src/lib.rs b/ofborg/src/lib.rs index 12f3430..bda70db 100644 --- a/ofborg/src/lib.rs +++ b/ofborg/src/lib.rs @@ -1,7 +1,3 @@ -#[macro_use] -extern crate prometheus; - - #[macro_use] extern crate serde_derive; extern crate serde; diff --git a/ofborg/src/stats.rs b/ofborg/src/stats.rs index 3c779a4..f30e1d3 100644 --- a/ofborg/src/stats.rs +++ b/ofborg/src/stats.rs @@ -3,21 +3,18 @@ use amqp::Channel; use amqp::protocol::basic::BasicProperties; use amqp::Basic; +include!(concat!(env!("OUT_DIR"), "/events.rs")); + +#[macro_use] +mod macros { + #[macro_export] + macro_rules! my_macro(() => (FooBar)); +} + pub trait SysEvents: Send { fn notify(&mut self, event: Event); } -#[derive(Serialize, Deserialize, Debug)] -#[serde(rename_all="kebab-case")] -pub enum Event { - StatCollectorLegacyEvent, - StatCollectorBogusEvent, - JobReceived, - JobDecodeSuccess, - JobDecodeFailure, - IssueAlreadyClosed, - IssueFetchFailed, -} #[derive(Serialize, Deserialize, Debug)] pub struct EventMessage { diff --git a/ofborg/src/tasks/statscollector.rs b/ofborg/src/tasks/statscollector.rs index 94b988c..35f2d36 100644 --- a/ofborg/src/tasks/statscollector.rs +++ b/ofborg/src/tasks/statscollector.rs @@ -1,172 +1,22 @@ -extern crate prometheus; extern crate amqp; extern crate env_logger; use serde_json; -use std::str::FromStr; use ofborg::worker; use ofborg::stats; use amqp::protocol::basic::{Deliver, BasicProperties}; -use std::collections::HashMap; -use std::mem; -use std::thread; -use std::time::Duration; -use std::sync::Arc; -use std::sync::Mutex; pub struct StatCollectorWorker { events: E, - counter_collectors: HashMap, + collector: stats::MetricCollector, } impl StatCollectorWorker { - pub fn new(events: E) -> StatCollectorWorker { - let mut worker = StatCollectorWorker { + pub fn new(events: E, collector: stats::MetricCollector) -> StatCollectorWorker { + StatCollectorWorker { events: events, - counter_collectors: HashMap::new(), - }; - - let initial_events: Vec = vec![ - stats::Event::StatCollectorLegacyEvent, - stats::Event::StatCollectorBogusEvent, - stats::Event::JobReceived, - stats::Event::JobDecodeSuccess, - stats::Event::JobDecodeFailure, - stats::Event::IssueAlreadyClosed, - stats::Event::IssueFetchFailed, - ]; - for initial_event in initial_events { - match initial_event { - // WARNING - // BEFORE YOU ADD A NEW VARIANT HERE, ADD IT - // TO THE LIST ABOVE! - // - // EACH VARIANT MUST BE INITIALIZED PRIOR - // TO REPORTING STATS - stats::Event::StatCollectorLegacyEvent => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "stats_collector".to_owned(), - name: "legacy_event".to_owned(), - help: "Number of received legacy events".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - ); - }, - stats::Event::StatCollectorBogusEvent => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "stats_collector".to_owned(), - name: "bogus_event".to_owned(), - help: "Number of received unparseable events".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - ); - }, - stats::Event::JobReceived => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "generic_worker".to_owned(), - name: "job_received".to_owned(), - help: "Number of received worker jobs".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - ); - }, - stats::Event::JobDecodeSuccess => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "generic_worker".to_owned(), - name: "job_decode_successful".to_owned(), - help: "Number of successfully decoded jobs".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - ); - }, - stats::Event::JobDecodeFailure => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "generic_worker".to_owned(), - name: "job_decode_failure".to_owned(), - help: "Number of jobs which failed to parse".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - ); - }, - stats::Event::IssueAlreadyClosed => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "github".to_owned(), - name: "issue_closed".to_owned(), - help: "Number of jobs for issues which are already closed".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - - ); - }, - stats::Event::IssueFetchFailed => { - worker.register_counter( - &initial_event, - prometheus::Opts { - namespace: "ofborg".to_owned(), - subsystem: "github".to_owned(), - name: "issue_fetch_fail".to_owned(), - help: "Number of failed fetches for GitHub issues".to_owned(), - const_labels: HashMap::new(), - variable_labels: vec!["instance".to_owned()], - } - ); - }, - }; + collector: collector, } - - return worker; - } - - pub fn counter(&self, event: &stats::Event) -> prometheus::CounterVec { - let disc = format!("{:?}", mem::discriminant(event)); - self.counter_collectors.get(&disc).unwrap().clone() - } - - pub fn register_counter( - &mut self, - event: &stats::Event, - opts: prometheus::Opts, - ) { - let disc = format!("{:?}", mem::discriminant(event)); - let orig_labels = opts.variable_labels.clone(); - let labels: Vec<&str> = orig_labels - .iter() - .map(|v| v.as_ref()) - .collect(); - - let counter = register_counter_vec!( - opts, labels.as_ref() - ).unwrap(); - counter.with_label_values(&[""]).inc_by(0.0); - - self.counter_collectors.insert( - disc, - counter - ); } } @@ -188,7 +38,7 @@ impl worker::SimpleWorker for StatCollectorWorker match serde_json::from_slice(&modified_body) { Ok(e) => { - self.events.notify(stats::Event::StatCollectorLegacyEvent); + self.events.notify(stats::Event::StatCollectorLegacyEvent(stats::event_metric_name(&e))); Ok(stats::EventMessage { sender: "".to_owned(), events: vec![e], @@ -209,31 +59,10 @@ impl worker::SimpleWorker for StatCollectorWorker } fn consumer(&mut self, job: &stats::EventMessage) -> worker::Actions { + let sender = job.sender.clone(); for event in job.events.iter() { - match *event { - stats::Event::StatCollectorLegacyEvent => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - stats::Event::StatCollectorBogusEvent => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - stats::Event::JobReceived => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - stats::Event::JobDecodeSuccess => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - stats::Event::JobDecodeFailure => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - stats::Event::IssueAlreadyClosed => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - stats::Event::IssueFetchFailed => { - self.counter(&event).with_label_values(&[sender.as_ref()]).inc(); - }, - } + self.collector.record(sender.clone(), event.clone()); } return vec![worker::Action::Ack]; From cdb88316b946986a225436ad1ef9b7435c24623f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 12 Feb 2018 08:21:14 -0500 Subject: [PATCH 06/47] Tick m evaluation completes in the mass rebuildere --- ofborg/build.rs | 5 +++++ ofborg/src/tasks/massrebuilder.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ofborg/build.rs b/ofborg/build.rs index e458dcf..9c282d6 100644 --- a/ofborg/build.rs +++ b/ofborg/build.rs @@ -266,6 +266,11 @@ fn events() -> Vec { "Number of failed fetches for GitHub issues", None, ), + Metric::ticker( + "TaskEvaluationCheckComplete", + "Number of completed evaluation tasks", + None, + ), /* Metric::counter( "TimeElapsed", diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 0266bdf..b5fb03e 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -510,6 +510,8 @@ impl worker::SimpleWorker for MassRebuildWorker Date: Mon, 12 Feb 2018 08:35:52 -0500 Subject: [PATCH 07/47] Report stats on evaluation duration per-branch --- ofborg/build.rs | 4 +++- ofborg/src/tasks/massrebuilder.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ofborg/build.rs b/ofborg/build.rs index 9c282d6..e510f9c 100644 --- a/ofborg/build.rs +++ b/ofborg/build.rs @@ -244,7 +244,9 @@ fn events() -> Vec { Metric::counter( "EvaluationDuration", "Amount of time spent running evaluations", - None + Some(vec![ + ("branch", "String"), + ]), ), Metric::ticker( "JobDecodeSuccess", diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index b5fb03e..ed35114 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -11,7 +11,7 @@ use std::path::PathBuf; use ofborg::checkout; use ofborg::message::{massrebuildjob, buildjob}; use ofborg::nix::Nix; - +use std::time::Instant; use ofborg::acl::ACL; use ofborg::stats; use ofborg::stats::Event; @@ -186,6 +186,8 @@ impl worker::SimpleWorker for MassRebuildWorker worker::SimpleWorker for MassRebuildWorker Date: Mon, 12 Feb 2018 08:36:25 -0500 Subject: [PATCH 08/47] Track how often target branches evaluate, to setup a potential alert for it. --- ofborg/build.rs | 7 +++++++ ofborg/src/tasks/massrebuilder.rs | 1 + 2 files changed, 8 insertions(+) diff --git a/ofborg/build.rs b/ofborg/build.rs index e510f9c..1c30cbd 100644 --- a/ofborg/build.rs +++ b/ofborg/build.rs @@ -248,6 +248,13 @@ fn events() -> Vec { ("branch", "String"), ]), ), + Metric::ticker( + "TargetBranchFailsEvaluation", + "Number of PR evaluations which failed because the target branch failed", + Some(vec![ + ("branch", "String"), + ]), + ), Metric::ticker( "JobDecodeSuccess", "Number of successfully decoded jobs", diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index ed35114..88abdb0 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -196,6 +196,7 @@ impl worker::SimpleWorker for MassRebuildWorker Date: Mon, 12 Feb 2018 20:16:59 -0500 Subject: [PATCH 09/47] Emit a counter for each timed duration --- ofborg/build.rs | 7 +++++++ ofborg/src/tasks/massrebuilder.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/ofborg/build.rs b/ofborg/build.rs index 1c30cbd..4881c36 100644 --- a/ofborg/build.rs +++ b/ofborg/build.rs @@ -248,6 +248,13 @@ fn events() -> Vec { ("branch", "String"), ]), ), + Metric::ticker( + "EvaluationDurationCount", + "Number of timed evaluations performed", + Some(vec![ + ("branch", "String"), + ]), + ), Metric::ticker( "TargetBranchFailsEvaluation", "Number of PR evaluations which failed because the target branch failed", diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 88abdb0..136f2f8 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -210,6 +210,11 @@ impl worker::SimpleWorker for MassRebuildWorker Date: Wed, 14 Feb 2018 19:57:15 +0100 Subject: [PATCH 10/47] fix tests when using nix >=1.12 --- ofborg/src/nix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index 4ad4958..6183c47 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -344,7 +344,7 @@ mod tests { assert_run( ret, Expect::Pass, - vec!["-success.drv", "building path(s)", "hi", "-success"], + vec!["-success.drv", "building ", "hi", "-success"], ); } @@ -363,7 +363,7 @@ mod tests { Expect::Fail, vec![ "-failed.drv", - "building path(s)", + "building ", "hi", "failed to produce output path", ], From 73a3acf8df61c0407ab5b5da1d344e1afc38cc63 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Fri, 16 Feb 2018 19:52:14 +0100 Subject: [PATCH 11/47] massrebuilder: don't depend on nixos channel in tests --- ofborg/src/tasks/massrebuilder.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 155143b..0826a0c 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -740,14 +740,24 @@ fn parse_commit_messages(messages: Vec) -> Vec { mod tests { use super::*; + use std::process::Command; #[test] fn stdenv_checking() { + let output = Command::new("nix-instantiate") + .args(&["--eval", "-E", ""]) + .output() + .expect("nix-instantiate required"); + + let nixpkgs = String::from_utf8(output.stdout) + .expect("nixpkgs required"); + let nix = Nix::new(String::from("x86_64-linux"), String::from("daemon"), 1200, None); + let mut stdenv = Stdenvs::new( nix.clone(), - PathBuf::from("/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs"), + PathBuf::from(nixpkgs.trim_right()), ); stdenv.identify(System::X8664Linux, StdenvFrom::Before); stdenv.identify(System::X8664Darwin, StdenvFrom::Before); From 655cb9d960a131cbca04cde103c2f4ae1341860b Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 17 Feb 2018 21:18:05 +0100 Subject: [PATCH 12/47] massrebuilder: add darwin label based on title --- ofborg/src/tasks/massrebuilder.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 155143b..741ab07 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -58,6 +58,20 @@ impl MassRebuildWorker { return massrebuildjob::Actions {}; } + fn tag_from_title(&self, issue: &hubcaps::issues::IssueRef) { + let darwin = issue.get() + .map(|iss| iss.title.to_lowercase().contains("darwin")) + .unwrap_or(false); + + if darwin { + update_labels( + &issue, + vec![String::from("6.topic: darwin")], + vec![], + ); + } + } + fn tag_from_paths(&self, issue: &hubcaps::issues::IssueRef, paths: Vec) { let mut tagger = PathsTagger::new(self.tag_paths.clone()); @@ -135,6 +149,8 @@ impl worker::SimpleWorker for MassRebuildWorker { } } + self.tag_from_title(&issue); + let mut overall_status = CommitStatus::new( repo.statuses(), job.pr.head_sha.clone(), From 26e33371a598e636d7e412eb924f07cfeec226cd Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Sun, 18 Feb 2018 18:13:49 -0500 Subject: [PATCH 13/47] update users --- config.extra-known-users.json | 3 +-- config.known-users.json | 2 ++ config.public.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config.extra-known-users.json b/config.extra-known-users.json index 6e856fc..22a7dc7 100644 --- a/config.extra-known-users.json +++ b/config.extra-known-users.json @@ -2,6 +2,5 @@ "bhipple", "dotlambda", "dywedir", - "unode", - "nlewo" + "unode" ] diff --git a/config.known-users.json b/config.known-users.json index aae17db..bdc3a85 100644 --- a/config.known-users.json +++ b/config.known-users.json @@ -34,6 +34,7 @@ "disassembler", "domenkozar", "dotlambda", + "dywedir", "edolstra", "edwtjo", "ehmry", @@ -73,6 +74,7 @@ "ndowens", "nequissimus", "nicolaspetton", + "nlewo", "obadz", "ocharles", "offlinehacker", diff --git a/config.public.json b/config.public.json index f074ff5..1b2a5da 100644 --- a/config.public.json +++ b/config.public.json @@ -14,6 +14,7 @@ "aneeshusa", "aszlig", "copumpkin", + "dezgeg", "disassembler", "domenkozar", "dtzwill", From ca7f94b36b74c83141183e06d4ae8b2f73d0c534 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Wed, 14 Feb 2018 22:08:04 +0100 Subject: [PATCH 14/47] add operation type for nix commands --- ofborg/src/evalchecker.rs | 10 +++--- ofborg/src/nix.rs | 55 +++++++++++++++++++++++-------- ofborg/src/outpathdiff.rs | 2 +- ofborg/src/tasks/massrebuilder.rs | 27 ++++++++------- 4 files changed, 61 insertions(+), 33 deletions(-) diff --git a/ofborg/src/evalchecker.rs b/ofborg/src/evalchecker.rs index f485d77..096d188 100644 --- a/ofborg/src/evalchecker.rs +++ b/ofborg/src/evalchecker.rs @@ -7,16 +7,16 @@ use ofborg::nix; pub struct EvalChecker { name: String, - cmd: String, + op: nix::Operation, args: Vec, nix: nix::Nix, } impl EvalChecker { - pub fn new(name: &str, cmd: &str, args: Vec, nix: nix::Nix) -> EvalChecker { + pub fn new(name: &str, op: nix::Operation, args: Vec, nix: nix::Nix) -> EvalChecker { EvalChecker { name: name.to_owned(), - cmd: cmd.to_owned(), + op: op, args: args, nix: nix, } @@ -27,11 +27,11 @@ impl EvalChecker { } pub fn execute(&self, path: &Path) -> Result { - self.nix.safely(&self.cmd, path, self.args.clone(), false) + self.nix.safely(self.op.clone(), path, self.args.clone(), false) } pub fn cli_cmd(&self) -> String { - let mut cli = vec![self.cmd.clone()]; + let mut cli = vec![self.op.to_string()]; cli.append(&mut self.args.clone()); return cli.join(" "); } diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index 6183c47..aaeac78 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -1,5 +1,5 @@ use std::env; -use std::ffi::OsString; +use std::fmt; use std::fs::File; use std::io::Seek; use std::io::SeekFrom; @@ -7,6 +7,37 @@ use std::path::Path; use std::process::{Command, Stdio}; use tempfile::tempfile; +#[derive(Clone, Debug)] +pub enum Operation { + Build, + Instantiate, + Unknown { program: String }, +} + +impl Operation { + pub fn new(program: &str) -> Operation { + Operation::Unknown { program: program.to_owned() } + } + + fn command(&self) -> Command { + match *self { + Operation::Build => Command::new("nix-build"), + Operation::Instantiate => Command::new("nix-instantiate"), + Operation::Unknown { ref program } => Command::new(program), + } + } +} + +impl fmt::Display for Operation { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Operation::Build => write!(f, "{}", "nix-build"), + Operation::Instantiate => write!(f, "{}", "nix-instantiate"), + Operation::Unknown { ref program } => write!(f, "{}", program), + } + } +} + #[derive(Clone, Debug, PartialEq)] pub struct Nix { system: String, @@ -71,17 +102,17 @@ impl Nix { attrargs.push(attr); } - return self.safe_command("nix-build", nixpkgs, attrargs); + return self.safe_command(Operation::Build, nixpkgs, attrargs); } pub fn safely( &self, - cmd: &str, + op: Operation, nixpkgs: &Path, args: Vec, keep_stdout: bool, ) -> Result { - return self.run(self.safe_command(cmd, nixpkgs, args), keep_stdout); + return self.run(self.safe_command(op, nixpkgs, args), keep_stdout); } pub fn run(&self, mut cmd: Command, keep_stdout: bool) -> Result { @@ -113,12 +144,10 @@ impl Nix { } } - pub fn safe_command(&self, cmd: &str, nixpkgs: &Path, args: Vec) -> Command { - let mut nixpath = OsString::new(); - nixpath.push("nixpkgs="); - nixpath.push(nixpkgs.as_os_str()); + pub fn safe_command(&self, op: Operation, nixpkgs: &Path, args: Vec) -> Command { + let nixpath = format!("nixpkgs={}", nixpkgs.display()); - let mut command = Command::new(cmd); + let mut command = op.command(); command.env_clear(); command.current_dir(nixpkgs); command.env("HOME", "/homeless-shelter"); @@ -276,7 +305,7 @@ mod tests { let ret: Result = nix.run( - nix.safe_command("./environment.sh", build_path().as_path(), vec![]), + nix.safe_command(Operation::new("./environment.sh"), build_path().as_path(), vec![]), true, ); @@ -298,7 +327,7 @@ mod tests { let ret: Result = nix.run( - nix.safe_command("./environment.sh", build_path().as_path(), vec![]), + nix.safe_command(Operation::new("./environment.sh"), build_path().as_path(), vec![]), true, ); @@ -320,7 +349,7 @@ mod tests { let nix = nix(); let ret: Result = nix.run( - nix.safe_command("echo", build_path().as_path(), vec![]), + nix.safe_command(Operation::new("echo"), build_path().as_path(), vec![]), true, ); @@ -393,7 +422,7 @@ mod tests { #[test] fn instantiation() { let ret: Result = nix().safely( - "nix-instantiate", + Operation::Instantiate, passing_eval_path().as_path(), vec![], true, diff --git a/ofborg/src/outpathdiff.rs b/ofborg/src/outpathdiff.rs index f3e56c7..27c2e3b 100644 --- a/ofborg/src/outpathdiff.rs +++ b/ofborg/src/outpathdiff.rs @@ -170,7 +170,7 @@ impl OutPaths { } self.nix.safely( - "nix-env", + nix::Operation::new("nix-env"), &self.path, vec![ String::from("-f"), diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 389f920..8d29875 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -10,7 +10,7 @@ use std::path::Path; use std::path::PathBuf; use ofborg::checkout; use ofborg::message::{massrebuildjob, buildjob}; -use ofborg::nix::Nix; +use ofborg::nix; use ofborg::acl::ACL; use ofborg::stats; @@ -25,7 +25,7 @@ use hubcaps; pub struct MassRebuildWorker { cloner: checkout::CachedCloner, - nix: Nix, + nix: nix::Nix, github: hubcaps::Github, acl: ACL, identity: String, @@ -36,7 +36,7 @@ pub struct MassRebuildWorker { impl MassRebuildWorker { pub fn new( cloner: checkout::CachedCloner, - nix: Nix, + nix: nix::Nix, github: hubcaps::Github, acl: ACL, identity: String, @@ -291,7 +291,7 @@ impl worker::SimpleWorker for MassRebuildWorker { let eval_checks = vec![ EvalChecker::new( "package-list", - "nix-env", + nix::Operation::new("nix-env"), vec![ String::from("--file"), String::from("."), @@ -304,7 +304,7 @@ impl worker::SimpleWorker for MassRebuildWorker { EvalChecker::new( "nixos-options", - "nix-instantiate", + nix::Operation::Instantiate, vec![ String::from("./nixos/release.nix"), String::from("-A"), @@ -315,7 +315,7 @@ impl worker::SimpleWorker for MassRebuildWorker { EvalChecker::new( "nixos-manual", - "nix-instantiate", + nix::Operation::Instantiate, vec![ String::from("./nixos/release.nix"), String::from("-A"), @@ -326,7 +326,7 @@ impl worker::SimpleWorker for MassRebuildWorker { EvalChecker::new( "nixpkgs-manual", - "nix-instantiate", + nix::Operation::Instantiate, vec![ String::from("./pkgs/top-level/release.nix"), String::from("-A"), @@ -337,7 +337,7 @@ impl worker::SimpleWorker for MassRebuildWorker { EvalChecker::new( "nixpkgs-tarball", - "nix-instantiate", + nix::Operation::Instantiate, vec![ String::from("./pkgs/top-level/release.nix"), String::from("-A"), @@ -348,7 +348,7 @@ impl worker::SimpleWorker for MassRebuildWorker { EvalChecker::new( "nixpkgs-unstable-jobset", - "nix-instantiate", + nix::Operation::Instantiate, vec![ String::from("./pkgs/top-level/release.nix"), String::from("-A"), @@ -542,7 +542,7 @@ pub enum System { #[derive(Debug, PartialEq)] struct Stdenvs { - nix: Nix, + nix: nix::Nix, co: PathBuf, linux_stdenv_before: Option, @@ -553,7 +553,7 @@ struct Stdenvs { } impl Stdenvs { - fn new(nix: Nix, co: PathBuf) -> Stdenvs { + fn new(nix: nix::Nix, co: PathBuf) -> Stdenvs { return Stdenvs { nix: nix, co: co, @@ -615,7 +615,7 @@ impl Stdenvs { fn evalstdenv(&self, system: &str) -> Option { let result = self.nix.with_system(system.to_owned()).safely( - "nix-instantiate", + nix::Operation::Instantiate, &self.co, vec![ String::from("."), @@ -768,8 +768,7 @@ mod tests { let nixpkgs = String::from_utf8(output.stdout) .expect("nixpkgs required"); - let nix = Nix::new(String::from("x86_64-linux"), String::from("daemon"), 1200, None); - + let nix = nix::Nix::new(String::from("x86_64-linux"), String::from("daemon"), 1200, None); let mut stdenv = Stdenvs::new( nix.clone(), From be82a649ddae0cfcb9493157224648481c77257f Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Wed, 14 Feb 2018 22:22:34 +0100 Subject: [PATCH 15/47] add basic test for nix operations --- ofborg/src/nix.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index aaeac78..eed4883 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -299,6 +299,46 @@ mod tests { use std::path::PathBuf; use std::env; + #[test] + fn test_build_operation() { + let nix = nix(); + let op = Operation::Build; + + assert_eq!(op.to_string(), "nix-build"); + + let ret: Result = + nix.run( + nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]), + true, + ); + + assert_run( + ret, + Expect::Pass, + vec!["nix-build (Nix)"], + ); + } + + #[test] + fn test_instantiate_operation() { + let nix = nix(); + let op = Operation::Instantiate; + + assert_eq!(op.to_string(), "nix-instantiate"); + + let ret: Result = + nix.run( + nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]), + true, + ); + + assert_run( + ret, + Expect::Pass, + vec!["nix-instantiate (Nix)"], + ); + } + #[test] fn safe_command_environment() { let nix = nix(); From 893ee714bc7c53c5757a7d328f9e02c8fa49050d Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Thu, 15 Feb 2018 01:30:14 +0100 Subject: [PATCH 16/47] move operation specific flags --- ofborg/src/nix.rs | 106 ++++++++++++++++++++++++------ ofborg/src/outpathdiff.rs | 5 +- ofborg/src/tasks/massrebuilder.rs | 5 +- 3 files changed, 89 insertions(+), 27 deletions(-) diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index eed4883..207320a 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -9,23 +9,41 @@ use tempfile::tempfile; #[derive(Clone, Debug)] pub enum Operation { - Build, Instantiate, + Build, + QueryPackagesJSON, + QueryPackagesOutputs, + NoOp { operation: Box }, Unknown { program: String }, } impl Operation { - pub fn new(program: &str) -> Operation { - Operation::Unknown { program: program.to_owned() } - } - fn command(&self) -> Command { match *self { - Operation::Build => Command::new("nix-build"), Operation::Instantiate => Command::new("nix-instantiate"), + Operation::Build => Command::new("nix-build"), + Operation::QueryPackagesJSON => Command::new("nix-env"), + Operation::QueryPackagesOutputs => Command::new("nix-env"), + Operation::NoOp { operation: _ } => Command::new("echo"), Operation::Unknown { ref program } => Command::new(program), } } + + fn args(&self, command: &mut Command) { + match *self { + Operation::Build => { + command.args(&["--no-out-link", "--keep-going"]); + }, + Operation::QueryPackagesJSON => { + command.args(&["--query", "--available", "--json"]); + }, + Operation::QueryPackagesOutputs => { + command.args(&["--query", "--available", "--no-name", "--attr-path", "--out-path"]); + }, + Operation::NoOp { ref operation } => { operation.args(command); }, + _ => (), + }; + } } impl fmt::Display for Operation { @@ -33,6 +51,9 @@ impl fmt::Display for Operation { match *self { Operation::Build => write!(f, "{}", "nix-build"), Operation::Instantiate => write!(f, "{}", "nix-instantiate"), + Operation::QueryPackagesJSON => write!(f, "{}", "nix-env -qa --json"), + Operation::QueryPackagesOutputs => write!(f, "{}", "nix-env -qaP --no-name --out-path"), + Operation::NoOp { ref operation } => operation.fmt(f), Operation::Unknown { ref program } => write!(f, "{}", program), } } @@ -95,8 +116,6 @@ impl Nix { ) -> Command { let mut attrargs: Vec = Vec::with_capacity(3 + (attrs.len() * 2)); attrargs.push(file.to_owned()); - attrargs.push(String::from("--no-out-link")); - attrargs.push(String::from("--keep-going")); for attr in attrs { attrargs.push(String::from("-A")); attrargs.push(attr); @@ -148,6 +167,8 @@ impl Nix { let nixpath = format!("nixpkgs={}", nixpkgs.display()); let mut command = op.command(); + op.args(&mut command); + command.env_clear(); command.current_dir(nixpkgs); command.env("HOME", "/homeless-shelter"); @@ -194,6 +215,14 @@ mod tests { Nix::new("x86_64-linux".to_owned(), "daemon".to_owned(), 1800, None) } + fn noop(operation: Operation) -> Operation { + Operation::NoOp { operation: Box::new(operation) } + } + + fn env_noop() -> Operation { + Operation::Unknown { program: "./environment.sh".to_owned() } + } + fn build_path() -> PathBuf { let mut cwd = env::current_dir().unwrap(); cwd.push(Path::new("./test-srcs/build")); @@ -300,10 +329,9 @@ mod tests { use std::env; #[test] - fn test_build_operation() { + fn test_build_operations() { let nix = nix(); - let op = Operation::Build; - + let op = noop(Operation::Build); assert_eq!(op.to_string(), "nix-build"); let ret: Result = @@ -315,15 +343,14 @@ mod tests { assert_run( ret, Expect::Pass, - vec!["nix-build (Nix)"], + vec!["--no-out-link --keep-going", "--version"], ); } #[test] fn test_instantiate_operation() { let nix = nix(); - let op = Operation::Instantiate; - + let op = noop(Operation::Instantiate); assert_eq!(op.to_string(), "nix-instantiate"); let ret: Result = @@ -335,7 +362,48 @@ mod tests { assert_run( ret, Expect::Pass, - vec!["nix-instantiate (Nix)"], + vec!["--version"], + ); + } + + #[test] + fn test_query_packages_json() { + let nix = nix(); + let op = noop(Operation::QueryPackagesJSON); + assert_eq!(op.to_string(), "nix-env -qa --json"); + + let ret: Result = + nix.run( + nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]), + true, + ); + + assert_run( + ret, + Expect::Pass, + vec!["--query --available --json", "--version"], + ); + } + + #[test] + fn test_query_packages_outputs() { + let nix = nix(); + let op = noop(Operation::QueryPackagesOutputs); + assert_eq!(op.to_string(), "nix-env -qaP --no-name --out-path"); + + let ret: Result = + nix.run( + nix.safe_command(op, build_path().as_path(), vec![String::from("--version")]), + true, + ); + + assert_run( + ret, + Expect::Pass, + vec![ + "--query --available --no-name --attr-path --out-path", + "--version" + ], ); } @@ -345,7 +413,7 @@ mod tests { let ret: Result = nix.run( - nix.safe_command(Operation::new("./environment.sh"), build_path().as_path(), vec![]), + nix.safe_command(env_noop(), build_path().as_path(), vec![]), true, ); @@ -367,7 +435,7 @@ mod tests { let ret: Result = nix.run( - nix.safe_command(Operation::new("./environment.sh"), build_path().as_path(), vec![]), + nix.safe_command(env_noop(), build_path().as_path(), vec![]), true, ); @@ -387,9 +455,10 @@ mod tests { #[test] fn safe_command_options() { let nix = nix(); + let op = noop(Operation::Build); let ret: Result = nix.run( - nix.safe_command(Operation::new("echo"), build_path().as_path(), vec![]), + nix.safe_command(op, build_path().as_path(), vec![]), true, ); @@ -458,7 +527,6 @@ mod tests { ); } - #[test] fn instantiation() { let ret: Result = nix().safely( diff --git a/ofborg/src/outpathdiff.rs b/ofborg/src/outpathdiff.rs index 27c2e3b..2f7ce9e 100644 --- a/ofborg/src/outpathdiff.rs +++ b/ofborg/src/outpathdiff.rs @@ -170,14 +170,11 @@ impl OutPaths { } self.nix.safely( - nix::Operation::new("nix-env"), + nix::Operation::QueryPackagesOutputs, &self.path, vec![ String::from("-f"), String::from(".gc-of-borg-outpaths.nix"), - String::from("-qaP"), - String::from("--no-name"), - String::from("--out-path"), String::from("--arg"), String::from("checkMeta"), check_meta, diff --git a/ofborg/src/tasks/massrebuilder.rs b/ofborg/src/tasks/massrebuilder.rs index 8d29875..147b259 100644 --- a/ofborg/src/tasks/massrebuilder.rs +++ b/ofborg/src/tasks/massrebuilder.rs @@ -291,13 +291,10 @@ impl worker::SimpleWorker for MassRebuildWorker { let eval_checks = vec![ EvalChecker::new( "package-list", - nix::Operation::new("nix-env"), + nix::Operation::QueryPackagesJSON, vec![ String::from("--file"), String::from("."), - String::from("--query"), - String::from("--available"), - String::from("--json"), ], self.nix.clone() ), From 6c21811f0176643a58ccbeb057f2693172a79676 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Tue, 20 Feb 2018 20:22:11 +0100 Subject: [PATCH 17/47] config: remove darwin topic paths This is not accurate enough, causing the label to be removed for all other darwin related changes. --- config.public.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config.public.json b/config.public.json index 1b2a5da..5d868a0 100644 --- a/config.public.json +++ b/config.public.json @@ -44,10 +44,6 @@ ] }, "tag_paths": { - "6.topic: darwin": [ - "pkgs/top-level/darwin-packages.nix", - "pkgs/stdenv/darwin" - ], "6.topic: emacs": [ "nixos/modules/services/editors/emacs.nix", "nixos/modules/services/editors/emacs.xml", From aba3ad04e57962eec6c5890ae6c17d127bd1e0e2 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 21 Feb 2018 21:36:27 -0500 Subject: [PATCH 18/47] Store metadata with logs --- nix/ofborg-carnix.nix | 23 +++- ofborg/Cargo.lock | 7 ++ ofborg/Cargo.toml | 1 + ofborg/src/lib.rs | 2 +- ofborg/src/message/buildlogmsg.rs | 4 +- ofborg/src/tasks/log_message_collector.rs | 138 +++++++++++++++++----- 6 files changed, 138 insertions(+), 37 deletions(-) diff --git a/nix/ofborg-carnix.nix b/nix/ofborg-carnix.nix index ae804a3..b22d24e 100644 --- a/nix/ofborg-carnix.nix +++ b/nix/ofborg-carnix.nix @@ -182,6 +182,13 @@ rec { sha256 = "1bxsh6fags7nr36vlz07ik2a1rzyipc8x1y30kjk832hf2pzadmw"; inherit dependencies buildDependencies features; }; + either_1_4_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + crateName = "either"; + version = "1.4.0"; + authors = [ "bluss" ]; + sha256 = "04kpfd84lvyrkb2z4sljlz2d3d5qczd0sb1yy37fgijq2yx3vb37"; + inherit dependencies buildDependencies features; + }; enum_primitive_0_1_1_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "enum_primitive"; version = "0.1.1"; @@ -974,6 +981,17 @@ rec { dtoa_0_4_2_features = f: updateFeatures f (rec { dtoa_0_4_2.default = (f.dtoa_0_4_2.default or true); }) []; + either_1_4_0 = { features?(either_1_4_0_features {}) }: either_1_4_0_ { + dependencies = mapFeatures features ([]); + features = mkFeatures (features.either_1_4_0 or {}); + }; + either_1_4_0_features = f: updateFeatures f (rec { + either_1_4_0.default = (f.either_1_4_0.default or true); + either_1_4_0.use_std = + (f.either_1_4_0.use_std or false) || + (f.either_1_4_0.default or false) || + (either_1_4_0.default or false); + }) []; enum_primitive_0_1_1 = { features?(enum_primitive_0_1_1_features {}) }: enum_primitive_0_1_1_ { dependencies = mapFeatures features ([ num_traits_0_1_41 ]); }; @@ -1325,10 +1343,11 @@ rec { num_cpus_1_8_0.default = (f.num_cpus_1_8_0.default or true); }) [ libc_0_2_36_features ]; ofborg_0_1_1 = { features?(ofborg_0_1_1_features {}) }: ofborg_0_1_1_ { - dependencies = mapFeatures features ([ amqp_0_1_0 env_logger_0_4_3 fs2_0_4_3 hubcaps_0_3_16 hyper_0_10_13 hyper_native_tls_0_2_4 log_0_3_8 lru_cache_0_1_1 md5_0_3_6 serde_1_0_27 serde_derive_1_0_27 serde_json_1_0_9 tempfile_2_2_0 uuid_0_4_0 ]); + dependencies = mapFeatures features ([ amqp_0_1_0 either_1_4_0 env_logger_0_4_3 fs2_0_4_3 hubcaps_0_3_16 hyper_0_10_13 hyper_native_tls_0_2_4 log_0_3_8 lru_cache_0_1_1 md5_0_3_6 serde_1_0_27 serde_derive_1_0_27 serde_json_1_0_9 tempfile_2_2_0 uuid_0_4_0 ]); }; ofborg_0_1_1_features = f: updateFeatures f (rec { amqp_0_1_0.default = true; + either_1_4_0.default = true; env_logger_0_4_3.default = true; fs2_0_4_3.default = true; hubcaps_0_3_16.default = true; @@ -1344,7 +1363,7 @@ rec { tempfile_2_2_0.default = true; uuid_0_4_0.default = true; uuid_0_4_0.v4 = true; - }) [ amqp_0_1_0_features env_logger_0_4_3_features fs2_0_4_3_features hubcaps_0_3_16_features hyper_0_10_13_features hyper_native_tls_0_2_4_features log_0_3_8_features lru_cache_0_1_1_features md5_0_3_6_features serde_1_0_27_features serde_derive_1_0_27_features serde_json_1_0_9_features tempfile_2_2_0_features uuid_0_4_0_features ]; + }) [ amqp_0_1_0_features either_1_4_0_features env_logger_0_4_3_features fs2_0_4_3_features hubcaps_0_3_16_features hyper_0_10_13_features hyper_native_tls_0_2_4_features log_0_3_8_features lru_cache_0_1_1_features md5_0_3_6_features serde_1_0_27_features serde_derive_1_0_27_features serde_json_1_0_9_features tempfile_2_2_0_features uuid_0_4_0_features ]; openssl_0_9_23 = { features?(openssl_0_9_23_features {}) }: openssl_0_9_23_ { dependencies = mapFeatures features ([ bitflags_0_9_1 foreign_types_0_3_2 lazy_static_1_0_0 libc_0_2_36 openssl_sys_0_9_24 ]); features = mkFeatures (features.openssl_0_9_23 or {}); diff --git a/ofborg/Cargo.lock b/ofborg/Cargo.lock index e766847..beaf34a 100644 --- a/ofborg/Cargo.lock +++ b/ofborg/Cargo.lock @@ -132,6 +132,11 @@ name = "dtoa" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "either" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "enum_primitive" version = "0.1.1" @@ -377,6 +382,7 @@ name = "ofborg" version = "0.1.1" dependencies = [ "amqp 0.1.0 (git+https://github.com/grahamc/rust-amqp.git)", + "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "hubcaps 0.3.16 (git+https://github.com/grahamc/hubcaps.git)", @@ -761,6 +767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum core-foundation 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" "checksum core-foundation-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index 9607cc4..d7e3f78 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -7,6 +7,7 @@ build = "build.rs" [dependencies] +either = "1.4.0" log = "= 0.3.8" env_logger = "= 0.4.3" # amqp = { path = "./rust-amqp/" } # for testing patches diff --git a/ofborg/src/lib.rs b/ofborg/src/lib.rs index bda70db..509efa1 100644 --- a/ofborg/src/lib.rs +++ b/ofborg/src/lib.rs @@ -9,7 +9,7 @@ extern crate log; extern crate hubcaps; extern crate hyper; extern crate hyper_native_tls; - +extern crate either; extern crate lru_cache; extern crate tempfile; extern crate amqp; diff --git a/ofborg/src/message/buildlogmsg.rs b/ofborg/src/message/buildlogmsg.rs index e88379b..00f44dc 100644 --- a/ofborg/src/message/buildlogmsg.rs +++ b/ofborg/src/message/buildlogmsg.rs @@ -1,5 +1,5 @@ -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct BuildLogMsg { pub system: String, pub identity: String, @@ -8,7 +8,7 @@ pub struct BuildLogMsg { pub output: String, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct BuildLogStart { pub system: String, pub identity: String, diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 64d1e81..623c36a 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -1,14 +1,16 @@ extern crate amqp; extern crate env_logger; +use either::{Either, Left, Right}; use lru_cache::LruCache; use serde_json; use std::fs; use std::fs::{OpenOptions, File}; use std::path::{Component, PathBuf}; +use std::io::Write; use ofborg::writetoline::LineWriter; -use ofborg::message::buildlogmsg::BuildLogMsg; +use ofborg::message::buildlogmsg::{BuildLogStart, BuildLogMsg}; use ofborg::worker; use amqp::protocol::basic::{Deliver, BasicProperties}; @@ -26,7 +28,7 @@ pub struct LogMessageCollector { #[derive(Debug)] pub struct LogMessage { from: LogFrom, - message: BuildLogMsg, + message: Either, } fn validate_path_segment(segment: &PathBuf) -> Result<(), String> { @@ -58,14 +60,32 @@ impl LogMessageCollector { }; } + pub fn write_metadata(&mut self, from: &LogFrom, data: &BuildLogStart) -> Result<(), String>{ + let metapath = self.path_for_metadata(&from)?; + let mut fp = self.open_file(metapath)?; + + match serde_json::to_string(data) { + Ok(data) => { + if let Err(e) = fp.write(&data.as_bytes()) { + Err(format!("Failed to write metadata: {:?}", e)) + } else { + Ok(()) + } + }, + Err(e) => { + Err(format!("Failed to stringify metadata: {:?}", e)) + } + } + } + pub fn handle_for(&mut self, from: &LogFrom) -> Result<&mut LineWriter, String> { if self.handles.contains_key(&from) { return Ok(self.handles.get_mut(&from).expect( "handles just contained the key", )); } else { - let logpath = self.path_for(&from)?; - let fp = self.open_log(logpath)?; + let logpath = self.path_for_log(&from)?; + let fp = self.open_file(logpath)?; let writer = LineWriter::new(fp); self.handles.insert(from.clone(), writer); if let Some(handle) = self.handles.get_mut(&from) { @@ -78,7 +98,13 @@ impl LogMessageCollector { } } - fn path_for(&self, from: &LogFrom) -> Result { + fn path_for_metadata(&self, from: &LogFrom) -> Result { + let mut path = self.path_for_log(from)?; + path.set_extension("metadata.json"); + return Ok(path); + } + + fn path_for_log(&self, from: &LogFrom) -> Result { let mut location = self.log_root.clone(); let routing_key = PathBuf::from(from.routing_key.clone()); @@ -100,7 +126,7 @@ impl LogMessageCollector { } } - fn open_log(&self, path: PathBuf) -> Result { + fn open_file(&self, path: PathBuf) -> Result { let dir = path.parent().unwrap(); fs::create_dir_all(dir).unwrap(); @@ -114,7 +140,7 @@ impl LogMessageCollector { match attempt { Ok(handle) => Ok(handle), Err(e) => Err(format!( - "Failed to open the log file for {:?}, err: {:?}", + "Failed to open the file for {:?}, err: {:?}", &path, e )), @@ -144,14 +170,22 @@ impl worker::SimpleWorker for LogMessageCollector { routing_key: deliver.routing_key.clone(), attempt_id: message.attempt_id.clone(), }, - message: message, + message: Right(message), }) } fn consumer(&mut self, job: &LogMessage) -> worker::Actions { - let handle = self.handle_for(&job.from).unwrap(); + match job.message { + Left(ref start) => { + self.write_metadata(&job.from, &start).expect("failed to write metadata"); + }, + Right(ref message) => { + let handle = self.handle_for(&job.from).unwrap(); - handle.write_to_line((job.message.line_number - 1) as usize, &job.message.output); + handle.write_to_line((message.line_number - 1) as usize, + &message.output); + } + } return vec![worker::Action::Ack]; } @@ -194,12 +228,29 @@ mod tests { } #[test] - fn test_path_for() { - let p = TestScratch::new_dir("log-message-collector-path_for"); + fn test_path_for_metadata() { + let p = TestScratch::new_dir("log-message-collector-path_for_metadata"); let worker = make_worker(p.path()); let path = worker - .path_for(&LogFrom { + .path_for_metadata(&LogFrom { + attempt_id: String::from("my-attempt-id"), + routing_key: String::from("my-routing-key"), + }) + .expect("the path should be valid"); + + + assert!(path.starts_with(p.path())); + assert!(path.as_os_str().to_string_lossy().ends_with("my-routing-key/my-attempt-id.metadata.json")); + } + + #[test] + fn test_path_for_log() { + let p = TestScratch::new_dir("log-message-collector-path_for_log"); + let worker = make_worker(p.path()); + + let path = worker + .path_for_log(&LogFrom { attempt_id: String::from("my-attempt-id"), routing_key: String::from("my-routing-key"), }) @@ -211,11 +262,11 @@ mod tests { } #[test] - fn test_path_for_malicious() { + fn test_path_for_log_malicious() { let p = TestScratch::new_dir("log-message-collector-for_malicious"); let worker = make_worker(p.path()); - let path = worker.path_for(&LogFrom { + let path = worker.path_for_log(&LogFrom { attempt_id: String::from("./../../"), routing_key: String::from("./../../foobar"), }); @@ -242,52 +293,75 @@ mod tests { #[test] - fn test_open_log() { - let p = TestScratch::new_dir("log-message-collector-open_log"); + fn test_open_file() { + let p = TestScratch::new_dir("log-message-collector-open_file"); let worker = make_worker(p.path()); assert!( worker - .open_log(worker.path_for(&make_from("a")).unwrap()) + .open_file(worker.path_for_log(&make_from("a")).unwrap()) .is_ok() ); assert!( worker - .open_log(worker.path_for(&make_from("b.foo/123")).unwrap()) + .open_file(worker.path_for_log(&make_from("b.foo/123")).unwrap()) .is_ok() ); } #[test] pub fn test_logs_collect() { + let mut logmsg = BuildLogMsg { + attempt_id: String::from("my-attempt-id"), + identity: String::from("my-identity"), + system: String::from("foobar-x8664"), + line_number: 1, + output: String::from("line-1"), + }; let mut job = LogMessage { from: make_from("foo"), - message: BuildLogMsg { - attempt_id: String::from("my-attempt-id"), - identity: String::from("my-identity"), - system: String::from("foobar-x8664"), - line_number: 1, - output: String::from("line-1"), - }, + message: Right(logmsg.clone()), }; - let p = TestScratch::new_dir("log-message-collector-path_for"); + let p = TestScratch::new_dir("log-message-collector-path_for_log"); { let mut worker = make_worker(p.path()); + assert_eq!(vec![worker::Action::Ack], + worker.consumer(& + LogMessage { + from: make_from("foo"), + message: Left(BuildLogStart { + attempt_id: String::from("my-attempt-id"), + identity: String::from("my-identity"), + system: String::from("foobar-x8664"), + }) + } + ) + ); + assert_eq!(vec![worker::Action::Ack], worker.consumer(&job)); - job.message.line_number = 5; - job.message.output = String::from("line-5"); + logmsg.line_number = 5; + logmsg.output = String::from("line-5"); + job.message = Right(logmsg.clone()); assert_eq!(vec![worker::Action::Ack], worker.consumer(&job)); job.from.attempt_id = String::from("my-other-attempt"); - job.message.attempt_id = String::from("my-other-attempt"); - job.message.line_number = 3; - job.message.output = String::from("line-3"); + logmsg.attempt_id = String::from("my-other-attempt"); + logmsg.line_number = 3; + logmsg.output = String::from("line-3"); + job.message = Right(logmsg.clone()); assert_eq!(vec![worker::Action::Ack], worker.consumer(&job)); } + let mut pr = p.path(); + let mut s = String::new(); + pr.push("routing-key-foo/attempt-id-foo.metadata.json"); + File::open(pr).unwrap().read_to_string(&mut s).unwrap(); + assert_eq!(&s, "{\"system\":\"foobar-x8664\",\"identity\":\"my-identity\",\"attempt_id\":\"my-attempt-id\"}"); + + let mut pr = p.path(); let mut s = String::new(); pr.push("routing-key-foo/attempt-id-foo"); From 10ecd201b37399bc940b8a9e384945ba12eec191 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 21 Feb 2018 22:42:35 -0500 Subject: [PATCH 19/47] Provide metadata in the log api --- log-api/index.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/log-api/index.php b/log-api/index.php index 9712067..fa1e5e7 100644 --- a/log-api/index.php +++ b/log-api/index.php @@ -42,7 +42,19 @@ if ($handle = opendir($req)) { } if (is_file($req . '/' . $entry)) { - $d['attempts'][$entry] = [ "log_url" => "$serve_root/$entry" ]; + if (substr($entry, -strlen(".metadata.json"),strlen(".metadata.json")) == ".metadata.json") { + $metadata = json_decode(file_get_contents($req . '/' . $entry), JSON_OBJECT_AS_ARRAY); + $attempt = $metadata['attempt_id']; + if (!isset($d['attempts'][$attempt])) { + $d['attempts'][$attempt] = []; + } + $d['attempts'][$attempt]['metadata'] = $metadata; + } else { + if (!isset($d['attempts'][$entry])) { + $d['attempts'][$entry] = []; + } + $d['attempts'][$entry]['log_url'] = "$serve_root/$entry"; + } } } } From 2ad0edc741e74e73dd22d42334e6f6deb92a128e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 21 Feb 2018 22:42:52 -0500 Subject: [PATCH 20/47] Actually collect metadata in the log collector... --- ofborg/src/tasks/log_message_collector.rs | 28 +++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 623c36a..551970e 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -158,20 +158,30 @@ impl worker::SimpleWorker for LogMessageCollector { body: &Vec, ) -> Result { - let decode = serde_json::from_slice(body); - if let Err(e) = decode { - return Err(format!("failed to decode job: {:?}", e)); + let message: Either; + let attempt_id: String; + + let decode_msg: Result = serde_json::from_slice(body); + if let Ok(msg) = decode_msg { + attempt_id = msg.attempt_id.clone(); + message = Right(msg); + } else { + let decode_msg: Result = serde_json::from_slice(body); + if let Ok(msg) = decode_msg { + attempt_id = msg.attempt_id.clone(); + message = Left(msg); + } else { + return Err(format!("failed to decode job: {:?}", decode_msg)); + } } - let message: BuildLogMsg = decode.unwrap(); - - Ok(LogMessage { + return Ok(LogMessage { from: LogFrom { routing_key: deliver.routing_key.clone(), - attempt_id: message.attempt_id.clone(), + attempt_id: attempt_id, }, - message: Right(message), - }) + message: message + }); } fn consumer(&mut self, job: &LogMessage) -> worker::Actions { From 4bd956207575b5429f9caba436f25c3378ebadaa Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 17:10:56 -0500 Subject: [PATCH 21/47] Update users, merge the scripts --- config.known-users.json | 1 + scripts/merge-config.sh | 4 ---- scripts/update-known-users.sh | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 100755 scripts/merge-config.sh diff --git a/config.known-users.json b/config.known-users.json index bdc3a85..2c0d4e8 100644 --- a/config.known-users.json +++ b/config.known-users.json @@ -34,6 +34,7 @@ "disassembler", "domenkozar", "dotlambda", + "dtzwill", "dywedir", "edolstra", "edwtjo", diff --git a/scripts/merge-config.sh b/scripts/merge-config.sh deleted file mode 100755 index e697a6a..0000000 --- a/scripts/merge-config.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -p bash -p jq -p curl -i bash - -jq -s '.[0] * .[1] * .[2]' ./config.public.json ./config.known-users.json ./config.private.json > ./config.prod.json diff --git a/scripts/update-known-users.sh b/scripts/update-known-users.sh index 2bccf0d..903510c 100755 --- a/scripts/update-known-users.sh +++ b/scripts/update-known-users.sh @@ -33,3 +33,5 @@ done jq -s '{ "runner": { "known_users": .[0]}}' "$accumulator" > "$dest" rm -f "$result" "$scratch" "$accumulator" + +jq -s '.[0] * .[1] * .[2]' ./config.public.json ./config.known-users.json ./config.private.json > ./config.prod.json From e7023dfc951eef661ea21e3d61c6f04b1117c2ec Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 17:16:57 -0500 Subject: [PATCH 22/47] Duration not used in Stats --- ofborg/src/bin/stats.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/ofborg/src/bin/stats.rs b/ofborg/src/bin/stats.rs index 9d7ce78..ad3ada0 100644 --- a/ofborg/src/bin/stats.rs +++ b/ofborg/src/bin/stats.rs @@ -10,7 +10,6 @@ use ofborg::easyamqp::TypedWrappers; use hyper::server::{Request, Response, Server}; use std::thread; -use std::time::Duration; fn main() { let cfg = config::load(env::args().nth(1).unwrap().as_ref()); From febbe1fe94631b72b724e6188a01d82ef1c63237 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 17:17:39 -0500 Subject: [PATCH 23/47] PullRequest was never used on an Issue --- ofborg/src/ghevent/common.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/ofborg/src/ghevent/common.rs b/ofborg/src/ghevent/common.rs index a1d6c98..049ca0a 100644 --- a/ofborg/src/ghevent/common.rs +++ b/ofborg/src/ghevent/common.rs @@ -20,7 +20,6 @@ pub struct Repository { #[derive(Serialize, Deserialize, Debug)] pub struct Issue { pub number: u64, - pub pull_request: Option, } #[derive(Serialize, Deserialize, Debug)] From ca321101e6f07504d8fcdceeb559fe3e4b5d1cf0 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 17:55:35 -0500 Subject: [PATCH 24/47] Bump nixpkgs --- nix/nixpkgs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json index d953cc8..18ce7f6 100644 --- a/nix/nixpkgs.json +++ b/nix/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/nixos/nixpkgs-channels.git", - "rev": "e860b651d6e297658e960c165fd231dbc0de1f9b", - "date": "2018-02-08T13:54:43+08:00", - "sha256": "0bsnarxm8g1r9qhk388as78cajidd5sqmmyvhmpsqqlzb3bn7ryv", + "rev": "c2fbd472a4ebaae739257a3df93aef25f19dd04f", + "date": "2018-02-23T08:08:30+00:00", + "sha256": "07mir6nqb98mbykabppgj4dli66h18qsyi4zqp640x22k6bkp2vp", "fetchSubmodules": true } From c9f3cf368a792468289283c4c29a6e6610eaf755 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 18:11:58 -0500 Subject: [PATCH 25/47] Make PullRequestEvent more thorough, with a test --- ofborg/src/ghevent/common.rs | 3 - ofborg/src/ghevent/mod.rs | 4 +- ofborg/src/ghevent/pullrequestevent.rs | 537 +++++++++++++++++++++++++ ofborg/src/lib.rs | 6 + 4 files changed, 546 insertions(+), 4 deletions(-) create mode 100644 ofborg/src/ghevent/pullrequestevent.rs diff --git a/ofborg/src/ghevent/common.rs b/ofborg/src/ghevent/common.rs index 049ca0a..4f22abc 100644 --- a/ofborg/src/ghevent/common.rs +++ b/ofborg/src/ghevent/common.rs @@ -21,6 +21,3 @@ pub struct Repository { pub struct Issue { pub number: u64, } - -#[derive(Serialize, Deserialize, Debug)] -pub struct PullRequest {} diff --git a/ofborg/src/ghevent/mod.rs b/ofborg/src/ghevent/mod.rs index 41f184a..622fda7 100644 --- a/ofborg/src/ghevent/mod.rs +++ b/ofborg/src/ghevent/mod.rs @@ -1,5 +1,7 @@ mod common; mod issuecomment; +mod pullrequestevent; pub use self::issuecomment::IssueComment; -pub use self::common::{Issue, Repository, User, Comment, PullRequest}; +pub use self::pullrequestevent::{PullRequest,PullRequestEvent}; +pub use self::common::{Issue, Repository, User, Comment}; diff --git a/ofborg/src/ghevent/pullrequestevent.rs b/ofborg/src/ghevent/pullrequestevent.rs new file mode 100644 index 0000000..a78a242 --- /dev/null +++ b/ofborg/src/ghevent/pullrequestevent.rs @@ -0,0 +1,537 @@ +use ofborg::ghevent::{Repository}; + +#[derive(Serialize, Deserialize)] +pub struct PullRequestEvent { + pub action: PullRequestAction, + pub number: u64, + pub repository: Repository, + pub pull_request: PullRequest, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all="snake_case")] +pub enum PullRequestAction { + Assigned, + Unassigned, + ReviewRequested, + ReviewRequestRemoved, + Labeled, + Unlabeled, + Opened, + Edited, + Closed, + Reopened, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct PullRequestRef { + #[serde(rename="ref")] + pub git_ref: String, + pub sha: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct PullRequest { + pub base: PullRequestRef, + pub head: PullRequestRef, + pub patch_url: String, +} + + +#[cfg(test)] +mod tests { + use super::*; + use serde_json; + + #[test] + fn test_parse_pr_event() { + let data = json!({ + "action": "edited", + "number": 33299, + "pull_request": { + "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299", + "id": 160662893, + "html_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299", + "diff_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299.diff", + "patch_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299.patch", + "issue_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299", + "number": 33299, + "state": "open", + "locked": false, + "title": "NixOS Tests: record an flv of the test", + "user": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/grahamc", + "html_url": "https:\\/\\/github.com\\/grahamc", + "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", + "type": "User", + "site_admin": false + }, + "body": "###### Motivation for this change\r\n\r\nSometimes tests can be hard to debug. Maybe recording an FLV from the VNC could help with that? To start, enable the recording on the flaky keymap test.\r\n\r\n###### Things done\r\n\r\n\r\n\r\n- [ ] Tested using sandboxing ([nix.useSandbox](http:\\/\\/nixos.org\\/nixos\\/manual\\/options.html#opt-nix.useSandbox) on NixOS, or option `build-use-sandbox` in [`nix.conf`](http:\\/\\/nixos.org\\/nix\\/manual\\/#sec-conf-file) on non-NixOS)\r\n- Built on platform(s)\r\n - [ ] NixOS\r\n - [ ] macOS\r\n - [ ] other Linux distributions\r\n- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos\\/tests](https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/blob\\/master\\/nixos\\/tests))\r\n- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run \"nox-review wip\"`\r\n- [ ] Tested execution of all binary files (usually in `.\\/result\\/bin\\/`)\r\n- [ ] Fits [CONTRIBUTING.md](https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/blob\\/master\\/.github\\/CONTRIBUTING.md).\r\n\r\n---\r\n\r\n", + "created_at": "2018-01-01T22:39:24Z", + "updated_at": "2018-02-23T21:48:19Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "e145dffca8579ca8fac15497af5f166d1e1197a4", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 737642262, + "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels\\/10.rebuild-darwin:%200", + "name": "10.rebuild-darwin: 0", + "color": "eeffee", + "default": false + }, + { + "id": 737642408, + "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels\\/10.rebuild-linux:%200", + "name": "10.rebuild-linux: 0", + "color": "eeffee", + "default": false + } + ], + "milestone": null, + "commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/commits", + "review_comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/comments", + "review_comment_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/comments{\\/number}", + "comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299\\/comments", + "statuses_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/887e8b460a7d45ddb3bbdebe01447b251b3229e8", + "head": { + "label": "grahamc:flv-nixos-tests", + "ref": "flv-nixos-tests", + "sha": "887e8b460a7d45ddb3bbdebe01447b251b3229e8", + "user": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/grahamc", + "html_url": "https:\\/\\/github.com\\/grahamc", + "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 52226505, + "name": "nixpkgs", + "full_name": "grahamc\\/nixpkgs", + "owner": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/grahamc", + "html_url": "https:\\/\\/github.com\\/grahamc", + "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https:\\/\\/github.com\\/grahamc\\/nixpkgs", + "description": "Nix Packages collection", + "fork": true, + "url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs", + "forks_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/forks", + "keys_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/keys{\\/key_id}", + "collaborators_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/collaborators{\\/collaborator}", + "teams_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/teams", + "hooks_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/hooks", + "issue_events_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/issues\\/events{\\/number}", + "events_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/events", + "assignees_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/assignees{\\/user}", + "branches_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/branches{\\/branch}", + "tags_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/tags", + "blobs_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/blobs{\\/sha}", + "git_tags_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/tags{\\/sha}", + "git_refs_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/refs{\\/sha}", + "trees_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/trees{\\/sha}", + "statuses_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/statuses\\/{sha}", + "languages_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/languages", + "stargazers_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/stargazers", + "contributors_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/contributors", + "subscribers_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/subscribers", + "subscription_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/subscription", + "commits_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/commits{\\/sha}", + "git_commits_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/commits{\\/sha}", + "comments_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/comments{\\/number}", + "issue_comment_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/issues\\/comments{\\/number}", + "contents_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/contents\\/{+path}", + "compare_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/compare\\/{base}...{head}", + "merges_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/merges", + "archive_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/{archive_format}{\\/ref}", + "downloads_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/downloads", + "issues_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/issues{\\/number}", + "pulls_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/pulls{\\/number}", + "milestones_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/milestones{\\/number}", + "notifications_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/notifications{?since,all,participating}", + "labels_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/labels{\\/name}", + "releases_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/releases{\\/id}", + "deployments_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/deployments", + "created_at": "2016-02-21T20:31:54Z", + "updated_at": "2017-05-07T04:44:29Z", + "pushed_at": "2018-01-01T22:35:52Z", + "git_url": "git:\\/\\/github.com\\/grahamc\\/nixpkgs.git", + "ssh_url": "git@github.com:grahamc\\/nixpkgs.git", + "clone_url": "https:\\/\\/github.com\\/grahamc\\/nixpkgs.git", + "svn_url": "https:\\/\\/github.com\\/grahamc\\/nixpkgs", + "homepage": null, + "size": 627435, + "stargazers_count": 1, + "watchers_count": 1, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": { + "key": "other", + "name": "Other", + "spdx_id": null, + "url": null + }, + "forks": 0, + "open_issues": 1, + "watchers": 1, + "default_branch": "master" + } + }, + "base": { + "label": "NixOS:staging", + "ref": "staging", + "sha": "19784ca4c9ac378539bdc535b02ae673ba6ba0b0", + "user": { + "login": "NixOS", + "id": 487568, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/NixOS", + "html_url": "https:\\/\\/github.com\\/NixOS", + "followers_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 4542716, + "name": "nixpkgs", + "full_name": "NixOS\\/nixpkgs", + "owner": { + "login": "NixOS", + "id": 487568, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/NixOS", + "html_url": "https:\\/\\/github.com\\/NixOS", + "followers_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", + "description": "Nix Packages collection", + "fork": false, + "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs", + "forks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/forks", + "keys_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/keys{\\/key_id}", + "collaborators_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/collaborators{\\/collaborator}", + "teams_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/teams", + "hooks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/hooks", + "issue_events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/events{\\/number}", + "events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/events", + "assignees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/assignees{\\/user}", + "branches_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/branches{\\/branch}", + "tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/tags", + "blobs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/blobs{\\/sha}", + "git_tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/tags{\\/sha}", + "git_refs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/refs{\\/sha}", + "trees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/trees{\\/sha}", + "statuses_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/{sha}", + "languages_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/languages", + "stargazers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/stargazers", + "contributors_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contributors", + "subscribers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscribers", + "subscription_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscription", + "commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/commits{\\/sha}", + "git_commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/commits{\\/sha}", + "comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/comments{\\/number}", + "issue_comment_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/comments{\\/number}", + "contents_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contents\\/{+path}", + "compare_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/compare\\/{base}...{head}", + "merges_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/merges", + "archive_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/{archive_format}{\\/ref}", + "downloads_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/downloads", + "issues_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues{\\/number}", + "pulls_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls{\\/number}", + "milestones_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/milestones{\\/number}", + "notifications_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/notifications{?since,all,participating}", + "labels_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels{\\/name}", + "releases_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/releases{\\/id}", + "deployments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/deployments", + "created_at": "2012-06-04T02:49:46Z", + "updated_at": "2018-02-23T20:56:05Z", + "pushed_at": "2018-02-23T21:40:58Z", + "git_url": "git:\\/\\/github.com\\/NixOS\\/nixpkgs.git", + "ssh_url": "git@github.com:NixOS\\/nixpkgs.git", + "clone_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs.git", + "svn_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", + "homepage": null, + "size": 724069, + "stargazers_count": 2239, + "watchers_count": 2239, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 2580, + "mirror_url": null, + "archived": false, + "open_issues_count": 2860, + "license": { + "key": "other", + "name": "Other", + "spdx_id": null, + "url": null + }, + "forks": 2580, + "open_issues": 2860, + "watchers": 2239, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299" + }, + "html": { + "href": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299" + }, + "issue": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299" + }, + "comments": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299\\/comments" + }, + "review_comments": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/comments" + }, + "review_comment": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/comments{\\/number}" + }, + "commits": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/commits" + }, + "statuses": { + "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/887e8b460a7d45ddb3bbdebe01447b251b3229e8" + } + }, + "author_association": "MEMBER", + "merged": false, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 5, + "review_comments": 0, + "maintainer_can_modify": true, + "commits": 1, + "additions": 41, + "deletions": 4, + "changed_files": 4 + }, + "changes": { + "base": { + "ref": { + "from": "master" + }, + "sha": { + "from": "a6664d8192038c4dc2ad44169dbb76556fe71ac1" + } + } + }, + "repository": { + "id": 4542716, + "name": "nixpkgs", + "full_name": "NixOS\\/nixpkgs", + "owner": { + "login": "NixOS", + "id": 487568, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/NixOS", + "html_url": "https:\\/\\/github.com\\/NixOS", + "followers_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", + "description": "Nix Packages collection", + "fork": false, + "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs", + "forks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/forks", + "keys_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/keys{\\/key_id}", + "collaborators_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/collaborators{\\/collaborator}", + "teams_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/teams", + "hooks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/hooks", + "issue_events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/events{\\/number}", + "events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/events", + "assignees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/assignees{\\/user}", + "branches_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/branches{\\/branch}", + "tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/tags", + "blobs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/blobs{\\/sha}", + "git_tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/tags{\\/sha}", + "git_refs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/refs{\\/sha}", + "trees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/trees{\\/sha}", + "statuses_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/{sha}", + "languages_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/languages", + "stargazers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/stargazers", + "contributors_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contributors", + "subscribers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscribers", + "subscription_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscription", + "commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/commits{\\/sha}", + "git_commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/commits{\\/sha}", + "comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/comments{\\/number}", + "issue_comment_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/comments{\\/number}", + "contents_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contents\\/{+path}", + "compare_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/compare\\/{base}...{head}", + "merges_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/merges", + "archive_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/{archive_format}{\\/ref}", + "downloads_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/downloads", + "issues_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues{\\/number}", + "pulls_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls{\\/number}", + "milestones_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/milestones{\\/number}", + "notifications_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/notifications{?since,all,participating}", + "labels_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels{\\/name}", + "releases_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/releases{\\/id}", + "deployments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/deployments", + "created_at": "2012-06-04T02:49:46Z", + "updated_at": "2018-02-23T20:56:05Z", + "pushed_at": "2018-02-23T21:40:58Z", + "git_url": "git:\\/\\/github.com\\/NixOS\\/nixpkgs.git", + "ssh_url": "git@github.com:NixOS\\/nixpkgs.git", + "clone_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs.git", + "svn_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", + "homepage": null, + "size": 724069, + "stargazers_count": 2239, + "watchers_count": 2239, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 2580, + "mirror_url": null, + "archived": false, + "open_issues_count": 2860, + "license": { + "key": "other", + "name": "Other", + "spdx_id": null, + "url": null + }, + "forks": 2580, + "open_issues": 2860, + "watchers": 2239, + "default_branch": "master" + }, + "organization": { + "login": "NixOS", + "id": 487568, + "url": "https:\\/\\/api.github.com\\/orgs\\/NixOS", + "repos_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/repos", + "events_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/events", + "hooks_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/hooks", + "issues_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/issues", + "members_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/members{\\/member}", + "public_members_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/public_members{\\/member}", + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", + "description": "" + }, + "sender": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", + "gravatar_id": "", + "url": "https:\\/\\/api.github.com\\/users\\/grahamc", + "html_url": "https:\\/\\/github.com\\/grahamc", + "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", + "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", + "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", + "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", + "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", + "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", + "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", + "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", + "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", + "type": "User", + "site_admin": false + } + }); + + let _p: PullRequestEvent = + serde_json::from_str(&data.to_string()) + .expect("Should properly deserialize"); + } +} diff --git a/ofborg/src/lib.rs b/ofborg/src/lib.rs index 509efa1..f7c6fee 100644 --- a/ofborg/src/lib.rs +++ b/ofborg/src/lib.rs @@ -1,6 +1,12 @@ + +#![recursion_limit="512"] + #[macro_use] extern crate serde_derive; extern crate serde; + + +#[cfg_attr(test, macro_use)] extern crate serde_json; #[macro_use] From 2745eb85b12ea7758e79e89e3f599dd28816ccf8 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 19:14:38 -0500 Subject: [PATCH 26/47] Fix the PullRequestEvents --- ofborg/src/ghevent/mod.rs | 2 +- ofborg/src/ghevent/pullrequestevent.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ofborg/src/ghevent/mod.rs b/ofborg/src/ghevent/mod.rs index 622fda7..d50c400 100644 --- a/ofborg/src/ghevent/mod.rs +++ b/ofborg/src/ghevent/mod.rs @@ -3,5 +3,5 @@ mod issuecomment; mod pullrequestevent; pub use self::issuecomment::IssueComment; -pub use self::pullrequestevent::{PullRequest,PullRequestEvent}; +pub use self::pullrequestevent::{PullRequest, PullRequestEvent, PullRequestAction, PullRequestState}; pub use self::common::{Issue, Repository, User, Comment}; diff --git a/ofborg/src/ghevent/pullrequestevent.rs b/ofborg/src/ghevent/pullrequestevent.rs index a78a242..1530405 100644 --- a/ofborg/src/ghevent/pullrequestevent.rs +++ b/ofborg/src/ghevent/pullrequestevent.rs @@ -8,7 +8,14 @@ pub struct PullRequestEvent { pub pull_request: PullRequest, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, PartialEq)] +#[serde(rename_all="snake_case")] +pub enum PullRequestState { + Open, + Closed, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq)] #[serde(rename_all="snake_case")] pub enum PullRequestAction { Assigned, @@ -21,6 +28,7 @@ pub enum PullRequestAction { Edited, Closed, Reopened, + Synchronize, } #[derive(Serialize, Deserialize, Debug)] @@ -32,9 +40,9 @@ pub struct PullRequestRef { #[derive(Serialize, Deserialize, Debug)] pub struct PullRequest { + pub state: PullRequestState, pub base: PullRequestRef, pub head: PullRequestRef, - pub patch_url: String, } From d7ffb2b83136db81078659d00ace387534ae3769 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 19:15:01 -0500 Subject: [PATCH 27/47] Eligible repo support --- ofborg/src/acl.rs | 8 +++++++- ofborg/src/config.rs | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ofborg/src/acl.rs b/ofborg/src/acl.rs index 805d304..90de362 100644 --- a/ofborg/src/acl.rs +++ b/ofborg/src/acl.rs @@ -2,16 +2,22 @@ pub struct ACL { trusted_users: Vec, known_users: Vec, + repos: Vec, } impl ACL { - pub fn new(trusted_users: Vec, known_users: Vec) -> ACL { + pub fn new(repos: Vec, trusted_users: Vec, known_users: Vec) -> ACL { return ACL { trusted_users: trusted_users, known_users: known_users, + repos: repos, }; } + pub fn is_repo_eligible(&self, name: &str) -> bool { + self.repos.contains(&name.to_lowercase()) + } + pub fn build_job_destinations_for_user_repo( &self, user: &str, diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index 0928f7e..ff886a4 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -58,6 +58,7 @@ pub struct LogStorage { #[derive(Serialize, Deserialize, Debug)] pub struct RunnerConfig { pub identity: String, + pub repos: Option>, pub trusted_users: Option>, pub known_users: Option>, } @@ -74,6 +75,9 @@ impl Config { pub fn acl(&self) -> acl::ACL { return acl::ACL::new( + self.runner.repos.clone().expect( + "fetching config's runner.repos", + ), self.runner.trusted_users.clone().expect( "fetching config's runner.trusted_users", ), From de08c2eb65f5f86f0d84fb6ab54dd8234b74e3e4 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 21:23:21 -0500 Subject: [PATCH 28/47] Support deserializing PR changes --- ofborg/src/ghevent/pullrequestevent.rs | 503 +------------------ ofborg/test-srcs/events/pr-changed-base.json | 484 ++++++++++++++++++ 2 files changed, 503 insertions(+), 484 deletions(-) create mode 100644 ofborg/test-srcs/events/pr-changed-base.json diff --git a/ofborg/src/ghevent/pullrequestevent.rs b/ofborg/src/ghevent/pullrequestevent.rs index 1530405..11f685c 100644 --- a/ofborg/src/ghevent/pullrequestevent.rs +++ b/ofborg/src/ghevent/pullrequestevent.rs @@ -6,6 +6,24 @@ pub struct PullRequestEvent { pub number: u64, pub repository: Repository, pub pull_request: PullRequest, + pub changes: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct PullRequestChanges { + pub base: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct BaseChange { + #[serde(rename="ref")] + pub git_ref: ChangeWas, + pub sha: ChangeWas, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq)] +pub struct ChangeWas { + pub from: String, } #[derive(Serialize, Deserialize, Debug, PartialEq)] @@ -53,490 +71,7 @@ mod tests { #[test] fn test_parse_pr_event() { - let data = json!({ - "action": "edited", - "number": 33299, - "pull_request": { - "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299", - "id": 160662893, - "html_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299", - "diff_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299.diff", - "patch_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299.patch", - "issue_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299", - "number": 33299, - "state": "open", - "locked": false, - "title": "NixOS Tests: record an flv of the test", - "user": { - "login": "grahamc", - "id": 76716, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/grahamc", - "html_url": "https:\\/\\/github.com\\/grahamc", - "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", - "type": "User", - "site_admin": false - }, - "body": "###### Motivation for this change\r\n\r\nSometimes tests can be hard to debug. Maybe recording an FLV from the VNC could help with that? To start, enable the recording on the flaky keymap test.\r\n\r\n###### Things done\r\n\r\n\r\n\r\n- [ ] Tested using sandboxing ([nix.useSandbox](http:\\/\\/nixos.org\\/nixos\\/manual\\/options.html#opt-nix.useSandbox) on NixOS, or option `build-use-sandbox` in [`nix.conf`](http:\\/\\/nixos.org\\/nix\\/manual\\/#sec-conf-file) on non-NixOS)\r\n- Built on platform(s)\r\n - [ ] NixOS\r\n - [ ] macOS\r\n - [ ] other Linux distributions\r\n- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos\\/tests](https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/blob\\/master\\/nixos\\/tests))\r\n- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run \"nox-review wip\"`\r\n- [ ] Tested execution of all binary files (usually in `.\\/result\\/bin\\/`)\r\n- [ ] Fits [CONTRIBUTING.md](https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/blob\\/master\\/.github\\/CONTRIBUTING.md).\r\n\r\n---\r\n\r\n", - "created_at": "2018-01-01T22:39:24Z", - "updated_at": "2018-02-23T21:48:19Z", - "closed_at": null, - "merged_at": null, - "merge_commit_sha": "e145dffca8579ca8fac15497af5f166d1e1197a4", - "assignee": null, - "assignees": [], - "requested_reviewers": [], - "requested_teams": [], - "labels": [ - { - "id": 737642262, - "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels\\/10.rebuild-darwin:%200", - "name": "10.rebuild-darwin: 0", - "color": "eeffee", - "default": false - }, - { - "id": 737642408, - "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels\\/10.rebuild-linux:%200", - "name": "10.rebuild-linux: 0", - "color": "eeffee", - "default": false - } - ], - "milestone": null, - "commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/commits", - "review_comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/comments", - "review_comment_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/comments{\\/number}", - "comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299\\/comments", - "statuses_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/887e8b460a7d45ddb3bbdebe01447b251b3229e8", - "head": { - "label": "grahamc:flv-nixos-tests", - "ref": "flv-nixos-tests", - "sha": "887e8b460a7d45ddb3bbdebe01447b251b3229e8", - "user": { - "login": "grahamc", - "id": 76716, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/grahamc", - "html_url": "https:\\/\\/github.com\\/grahamc", - "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", - "type": "User", - "site_admin": false - }, - "repo": { - "id": 52226505, - "name": "nixpkgs", - "full_name": "grahamc\\/nixpkgs", - "owner": { - "login": "grahamc", - "id": 76716, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/grahamc", - "html_url": "https:\\/\\/github.com\\/grahamc", - "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", - "type": "User", - "site_admin": false - }, - "private": false, - "html_url": "https:\\/\\/github.com\\/grahamc\\/nixpkgs", - "description": "Nix Packages collection", - "fork": true, - "url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs", - "forks_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/forks", - "keys_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/keys{\\/key_id}", - "collaborators_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/collaborators{\\/collaborator}", - "teams_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/teams", - "hooks_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/hooks", - "issue_events_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/issues\\/events{\\/number}", - "events_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/events", - "assignees_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/assignees{\\/user}", - "branches_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/branches{\\/branch}", - "tags_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/tags", - "blobs_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/blobs{\\/sha}", - "git_tags_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/tags{\\/sha}", - "git_refs_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/refs{\\/sha}", - "trees_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/trees{\\/sha}", - "statuses_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/statuses\\/{sha}", - "languages_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/languages", - "stargazers_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/stargazers", - "contributors_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/contributors", - "subscribers_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/subscribers", - "subscription_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/subscription", - "commits_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/commits{\\/sha}", - "git_commits_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/git\\/commits{\\/sha}", - "comments_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/comments{\\/number}", - "issue_comment_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/issues\\/comments{\\/number}", - "contents_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/contents\\/{+path}", - "compare_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/compare\\/{base}...{head}", - "merges_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/merges", - "archive_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/{archive_format}{\\/ref}", - "downloads_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/downloads", - "issues_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/issues{\\/number}", - "pulls_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/pulls{\\/number}", - "milestones_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/milestones{\\/number}", - "notifications_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/notifications{?since,all,participating}", - "labels_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/labels{\\/name}", - "releases_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/releases{\\/id}", - "deployments_url": "https:\\/\\/api.github.com\\/repos\\/grahamc\\/nixpkgs\\/deployments", - "created_at": "2016-02-21T20:31:54Z", - "updated_at": "2017-05-07T04:44:29Z", - "pushed_at": "2018-01-01T22:35:52Z", - "git_url": "git:\\/\\/github.com\\/grahamc\\/nixpkgs.git", - "ssh_url": "git@github.com:grahamc\\/nixpkgs.git", - "clone_url": "https:\\/\\/github.com\\/grahamc\\/nixpkgs.git", - "svn_url": "https:\\/\\/github.com\\/grahamc\\/nixpkgs", - "homepage": null, - "size": 627435, - "stargazers_count": 1, - "watchers_count": 1, - "language": "Nix", - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": false, - "has_pages": false, - "forks_count": 0, - "mirror_url": null, - "archived": false, - "open_issues_count": 1, - "license": { - "key": "other", - "name": "Other", - "spdx_id": null, - "url": null - }, - "forks": 0, - "open_issues": 1, - "watchers": 1, - "default_branch": "master" - } - }, - "base": { - "label": "NixOS:staging", - "ref": "staging", - "sha": "19784ca4c9ac378539bdc535b02ae673ba6ba0b0", - "user": { - "login": "NixOS", - "id": 487568, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/NixOS", - "html_url": "https:\\/\\/github.com\\/NixOS", - "followers_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/received_events", - "type": "Organization", - "site_admin": false - }, - "repo": { - "id": 4542716, - "name": "nixpkgs", - "full_name": "NixOS\\/nixpkgs", - "owner": { - "login": "NixOS", - "id": 487568, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/NixOS", - "html_url": "https:\\/\\/github.com\\/NixOS", - "followers_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/received_events", - "type": "Organization", - "site_admin": false - }, - "private": false, - "html_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", - "description": "Nix Packages collection", - "fork": false, - "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs", - "forks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/forks", - "keys_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/keys{\\/key_id}", - "collaborators_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/collaborators{\\/collaborator}", - "teams_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/teams", - "hooks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/hooks", - "issue_events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/events{\\/number}", - "events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/events", - "assignees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/assignees{\\/user}", - "branches_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/branches{\\/branch}", - "tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/tags", - "blobs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/blobs{\\/sha}", - "git_tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/tags{\\/sha}", - "git_refs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/refs{\\/sha}", - "trees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/trees{\\/sha}", - "statuses_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/{sha}", - "languages_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/languages", - "stargazers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/stargazers", - "contributors_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contributors", - "subscribers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscribers", - "subscription_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscription", - "commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/commits{\\/sha}", - "git_commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/commits{\\/sha}", - "comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/comments{\\/number}", - "issue_comment_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/comments{\\/number}", - "contents_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contents\\/{+path}", - "compare_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/compare\\/{base}...{head}", - "merges_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/merges", - "archive_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/{archive_format}{\\/ref}", - "downloads_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/downloads", - "issues_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues{\\/number}", - "pulls_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls{\\/number}", - "milestones_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/milestones{\\/number}", - "notifications_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/notifications{?since,all,participating}", - "labels_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels{\\/name}", - "releases_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/releases{\\/id}", - "deployments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/deployments", - "created_at": "2012-06-04T02:49:46Z", - "updated_at": "2018-02-23T20:56:05Z", - "pushed_at": "2018-02-23T21:40:58Z", - "git_url": "git:\\/\\/github.com\\/NixOS\\/nixpkgs.git", - "ssh_url": "git@github.com:NixOS\\/nixpkgs.git", - "clone_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs.git", - "svn_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", - "homepage": null, - "size": 724069, - "stargazers_count": 2239, - "watchers_count": 2239, - "language": "Nix", - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": false, - "has_pages": false, - "forks_count": 2580, - "mirror_url": null, - "archived": false, - "open_issues_count": 2860, - "license": { - "key": "other", - "name": "Other", - "spdx_id": null, - "url": null - }, - "forks": 2580, - "open_issues": 2860, - "watchers": 2239, - "default_branch": "master" - } - }, - "_links": { - "self": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299" - }, - "html": { - "href": "https:\\/\\/github.com\\/NixOS\\/nixpkgs\\/pull\\/33299" - }, - "issue": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299" - }, - "comments": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/33299\\/comments" - }, - "review_comments": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/comments" - }, - "review_comment": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/comments{\\/number}" - }, - "commits": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls\\/33299\\/commits" - }, - "statuses": { - "href": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/887e8b460a7d45ddb3bbdebe01447b251b3229e8" - } - }, - "author_association": "MEMBER", - "merged": false, - "mergeable": null, - "rebaseable": null, - "mergeable_state": "unknown", - "merged_by": null, - "comments": 5, - "review_comments": 0, - "maintainer_can_modify": true, - "commits": 1, - "additions": 41, - "deletions": 4, - "changed_files": 4 - }, - "changes": { - "base": { - "ref": { - "from": "master" - }, - "sha": { - "from": "a6664d8192038c4dc2ad44169dbb76556fe71ac1" - } - } - }, - "repository": { - "id": 4542716, - "name": "nixpkgs", - "full_name": "NixOS\\/nixpkgs", - "owner": { - "login": "NixOS", - "id": 487568, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/NixOS", - "html_url": "https:\\/\\/github.com\\/NixOS", - "followers_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/NixOS\\/received_events", - "type": "Organization", - "site_admin": false - }, - "private": false, - "html_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", - "description": "Nix Packages collection", - "fork": false, - "url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs", - "forks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/forks", - "keys_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/keys{\\/key_id}", - "collaborators_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/collaborators{\\/collaborator}", - "teams_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/teams", - "hooks_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/hooks", - "issue_events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/events{\\/number}", - "events_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/events", - "assignees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/assignees{\\/user}", - "branches_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/branches{\\/branch}", - "tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/tags", - "blobs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/blobs{\\/sha}", - "git_tags_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/tags{\\/sha}", - "git_refs_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/refs{\\/sha}", - "trees_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/trees{\\/sha}", - "statuses_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/statuses\\/{sha}", - "languages_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/languages", - "stargazers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/stargazers", - "contributors_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contributors", - "subscribers_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscribers", - "subscription_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/subscription", - "commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/commits{\\/sha}", - "git_commits_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/git\\/commits{\\/sha}", - "comments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/comments{\\/number}", - "issue_comment_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues\\/comments{\\/number}", - "contents_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/contents\\/{+path}", - "compare_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/compare\\/{base}...{head}", - "merges_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/merges", - "archive_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/{archive_format}{\\/ref}", - "downloads_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/downloads", - "issues_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/issues{\\/number}", - "pulls_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/pulls{\\/number}", - "milestones_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/milestones{\\/number}", - "notifications_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/notifications{?since,all,participating}", - "labels_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/labels{\\/name}", - "releases_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/releases{\\/id}", - "deployments_url": "https:\\/\\/api.github.com\\/repos\\/NixOS\\/nixpkgs\\/deployments", - "created_at": "2012-06-04T02:49:46Z", - "updated_at": "2018-02-23T20:56:05Z", - "pushed_at": "2018-02-23T21:40:58Z", - "git_url": "git:\\/\\/github.com\\/NixOS\\/nixpkgs.git", - "ssh_url": "git@github.com:NixOS\\/nixpkgs.git", - "clone_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs.git", - "svn_url": "https:\\/\\/github.com\\/NixOS\\/nixpkgs", - "homepage": null, - "size": 724069, - "stargazers_count": 2239, - "watchers_count": 2239, - "language": "Nix", - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": false, - "has_pages": false, - "forks_count": 2580, - "mirror_url": null, - "archived": false, - "open_issues_count": 2860, - "license": { - "key": "other", - "name": "Other", - "spdx_id": null, - "url": null - }, - "forks": 2580, - "open_issues": 2860, - "watchers": 2239, - "default_branch": "master" - }, - "organization": { - "login": "NixOS", - "id": 487568, - "url": "https:\\/\\/api.github.com\\/orgs\\/NixOS", - "repos_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/repos", - "events_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/events", - "hooks_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/hooks", - "issues_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/issues", - "members_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/members{\\/member}", - "public_members_url": "https:\\/\\/api.github.com\\/orgs\\/NixOS\\/public_members{\\/member}", - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/487568?v=4", - "description": "" - }, - "sender": { - "login": "grahamc", - "id": 76716, - "avatar_url": "https:\\/\\/avatars3.githubusercontent.com\\/u\\/76716?v=4", - "gravatar_id": "", - "url": "https:\\/\\/api.github.com\\/users\\/grahamc", - "html_url": "https:\\/\\/github.com\\/grahamc", - "followers_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/grahamc\\/received_events", - "type": "User", - "site_admin": false - } - }); + let data = include_str!("../../test-srcs/events/pr-changed-base.json"); let _p: PullRequestEvent = serde_json::from_str(&data.to_string()) diff --git a/ofborg/test-srcs/events/pr-changed-base.json b/ofborg/test-srcs/events/pr-changed-base.json new file mode 100644 index 0000000..6846bf8 --- /dev/null +++ b/ofborg/test-srcs/events/pr-changed-base.json @@ -0,0 +1,484 @@ +{ + "action": "edited", + "number": 33299, + "pull_request": { + "url": "https://api.github.com/repos/NixOS/nixpkgs/pulls/33299", + "id": 160662893, + "html_url": "https://github.com/NixOS/nixpkgs/pull/33299", + "diff_url": "https://github.com/NixOS/nixpkgs/pull/33299.diff", + "patch_url": "https://github.com/NixOS/nixpkgs/pull/33299.patch", + "issue_url": "https://api.github.com/repos/NixOS/nixpkgs/issues/33299", + "number": 33299, + "state": "open", + "locked": false, + "title": "NixOS Tests: record an flv of the test", + "user": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https://avatars3.githubusercontent.com/u/76716?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/grahamc", + "html_url": "https://github.com/grahamc", + "followers_url": "https://api.github.com/users/grahamc/followers", + "following_url": "https://api.github.com/users/grahamc/following{/other_user}", + "gists_url": "https://api.github.com/users/grahamc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/grahamc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/grahamc/subscriptions", + "organizations_url": "https://api.github.com/users/grahamc/orgs", + "repos_url": "https://api.github.com/users/grahamc/repos", + "events_url": "https://api.github.com/users/grahamc/events{/privacy}", + "received_events_url": "https://api.github.com/users/grahamc/received_events", + "type": "User", + "site_admin": false + }, + "body": "###### Motivation for this change\r\n\r\nSometimes tests can be hard to debug. Maybe recording an FLV from the VNC could help with that? To start, enable the recording on the flaky keymap test.\r\n\r\n###### Things done\r\n\r\n\r\n\r\n- [ ] Tested using sandboxing ([nix.useSandbox](http://nixos.org/nixos/manual/options.html#opt-nix.useSandbox) on NixOS, or option `build-use-sandbox` in [`nix.conf`](http://nixos.org/nix/manual/#sec-conf-file) on non-NixOS)\r\n- Built on platform(s)\r\n - [ ] NixOS\r\n - [ ] macOS\r\n - [ ] other Linux distributions\r\n- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))\r\n- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run \"nox-review wip\"`\r\n- [ ] Tested execution of all binary files (usually in `./result/bin/`)\r\n- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).\r\n\r\n---\r\n\r\n", + "created_at": "2018-01-01T22:39:24Z", + "updated_at": "2018-02-23T21:48:19Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "e145dffca8579ca8fac15497af5f166d1e1197a4", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 737642262, + "url": "https://api.github.com/repos/NixOS/nixpkgs/labels/10.rebuild-darwin:%200", + "name": "10.rebuild-darwin: 0", + "color": "eeffee", + "default": false + }, + { + "id": 737642408, + "url": "https://api.github.com/repos/NixOS/nixpkgs/labels/10.rebuild-linux:%200", + "name": "10.rebuild-linux: 0", + "color": "eeffee", + "default": false + } + ], + "milestone": null, + "commits_url": "https://api.github.com/repos/NixOS/nixpkgs/pulls/33299/commits", + "review_comments_url": "https://api.github.com/repos/NixOS/nixpkgs/pulls/33299/comments", + "review_comment_url": "https://api.github.com/repos/NixOS/nixpkgs/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/NixOS/nixpkgs/issues/33299/comments", + "statuses_url": "https://api.github.com/repos/NixOS/nixpkgs/statuses/887e8b460a7d45ddb3bbdebe01447b251b3229e8", + "head": { + "label": "grahamc:flv-nixos-tests", + "ref": "flv-nixos-tests", + "sha": "887e8b460a7d45ddb3bbdebe01447b251b3229e8", + "user": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https://avatars3.githubusercontent.com/u/76716?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/grahamc", + "html_url": "https://github.com/grahamc", + "followers_url": "https://api.github.com/users/grahamc/followers", + "following_url": "https://api.github.com/users/grahamc/following{/other_user}", + "gists_url": "https://api.github.com/users/grahamc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/grahamc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/grahamc/subscriptions", + "organizations_url": "https://api.github.com/users/grahamc/orgs", + "repos_url": "https://api.github.com/users/grahamc/repos", + "events_url": "https://api.github.com/users/grahamc/events{/privacy}", + "received_events_url": "https://api.github.com/users/grahamc/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 52226505, + "name": "nixpkgs", + "full_name": "grahamc/nixpkgs", + "owner": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https://avatars3.githubusercontent.com/u/76716?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/grahamc", + "html_url": "https://github.com/grahamc", + "followers_url": "https://api.github.com/users/grahamc/followers", + "following_url": "https://api.github.com/users/grahamc/following{/other_user}", + "gists_url": "https://api.github.com/users/grahamc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/grahamc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/grahamc/subscriptions", + "organizations_url": "https://api.github.com/users/grahamc/orgs", + "repos_url": "https://api.github.com/users/grahamc/repos", + "events_url": "https://api.github.com/users/grahamc/events{/privacy}", + "received_events_url": "https://api.github.com/users/grahamc/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/grahamc/nixpkgs", + "description": "Nix Packages collection", + "fork": true, + "url": "https://api.github.com/repos/grahamc/nixpkgs", + "forks_url": "https://api.github.com/repos/grahamc/nixpkgs/forks", + "keys_url": "https://api.github.com/repos/grahamc/nixpkgs/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/grahamc/nixpkgs/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/grahamc/nixpkgs/teams", + "hooks_url": "https://api.github.com/repos/grahamc/nixpkgs/hooks", + "issue_events_url": "https://api.github.com/repos/grahamc/nixpkgs/issues/events{/number}", + "events_url": "https://api.github.com/repos/grahamc/nixpkgs/events", + "assignees_url": "https://api.github.com/repos/grahamc/nixpkgs/assignees{/user}", + "branches_url": "https://api.github.com/repos/grahamc/nixpkgs/branches{/branch}", + "tags_url": "https://api.github.com/repos/grahamc/nixpkgs/tags", + "blobs_url": "https://api.github.com/repos/grahamc/nixpkgs/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/grahamc/nixpkgs/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/grahamc/nixpkgs/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/grahamc/nixpkgs/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/grahamc/nixpkgs/statuses/{sha}", + "languages_url": "https://api.github.com/repos/grahamc/nixpkgs/languages", + "stargazers_url": "https://api.github.com/repos/grahamc/nixpkgs/stargazers", + "contributors_url": "https://api.github.com/repos/grahamc/nixpkgs/contributors", + "subscribers_url": "https://api.github.com/repos/grahamc/nixpkgs/subscribers", + "subscription_url": "https://api.github.com/repos/grahamc/nixpkgs/subscription", + "commits_url": "https://api.github.com/repos/grahamc/nixpkgs/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/grahamc/nixpkgs/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/grahamc/nixpkgs/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/grahamc/nixpkgs/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/grahamc/nixpkgs/contents/{+path}", + "compare_url": "https://api.github.com/repos/grahamc/nixpkgs/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/grahamc/nixpkgs/merges", + "archive_url": "https://api.github.com/repos/grahamc/nixpkgs/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/grahamc/nixpkgs/downloads", + "issues_url": "https://api.github.com/repos/grahamc/nixpkgs/issues{/number}", + "pulls_url": "https://api.github.com/repos/grahamc/nixpkgs/pulls{/number}", + "milestones_url": "https://api.github.com/repos/grahamc/nixpkgs/milestones{/number}", + "notifications_url": "https://api.github.com/repos/grahamc/nixpkgs/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/grahamc/nixpkgs/labels{/name}", + "releases_url": "https://api.github.com/repos/grahamc/nixpkgs/releases{/id}", + "deployments_url": "https://api.github.com/repos/grahamc/nixpkgs/deployments", + "created_at": "2016-02-21T20:31:54Z", + "updated_at": "2017-05-07T04:44:29Z", + "pushed_at": "2018-01-01T22:35:52Z", + "git_url": "git://github.com/grahamc/nixpkgs.git", + "ssh_url": "git@github.com:grahamc/nixpkgs.git", + "clone_url": "https://github.com/grahamc/nixpkgs.git", + "svn_url": "https://github.com/grahamc/nixpkgs", + "homepage": null, + "size": 627435, + "stargazers_count": 1, + "watchers_count": 1, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": { + "key": "other", + "name": "Other", + "spdx_id": null, + "url": null + }, + "forks": 0, + "open_issues": 1, + "watchers": 1, + "default_branch": "master" + } + }, + "base": { + "label": "NixOS:staging", + "ref": "staging", + "sha": "19784ca4c9ac378539bdc535b02ae673ba6ba0b0", + "user": { + "login": "NixOS", + "id": 487568, + "avatar_url": "https://avatars3.githubusercontent.com/u/487568?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/NixOS", + "html_url": "https://github.com/NixOS", + "followers_url": "https://api.github.com/users/NixOS/followers", + "following_url": "https://api.github.com/users/NixOS/following{/other_user}", + "gists_url": "https://api.github.com/users/NixOS/gists{/gist_id}", + "starred_url": "https://api.github.com/users/NixOS/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/NixOS/subscriptions", + "organizations_url": "https://api.github.com/users/NixOS/orgs", + "repos_url": "https://api.github.com/users/NixOS/repos", + "events_url": "https://api.github.com/users/NixOS/events{/privacy}", + "received_events_url": "https://api.github.com/users/NixOS/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 4542716, + "name": "nixpkgs", + "full_name": "NixOS/nixpkgs", + "owner": { + "login": "NixOS", + "id": 487568, + "avatar_url": "https://avatars3.githubusercontent.com/u/487568?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/NixOS", + "html_url": "https://github.com/NixOS", + "followers_url": "https://api.github.com/users/NixOS/followers", + "following_url": "https://api.github.com/users/NixOS/following{/other_user}", + "gists_url": "https://api.github.com/users/NixOS/gists{/gist_id}", + "starred_url": "https://api.github.com/users/NixOS/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/NixOS/subscriptions", + "organizations_url": "https://api.github.com/users/NixOS/orgs", + "repos_url": "https://api.github.com/users/NixOS/repos", + "events_url": "https://api.github.com/users/NixOS/events{/privacy}", + "received_events_url": "https://api.github.com/users/NixOS/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/NixOS/nixpkgs", + "description": "Nix Packages collection", + "fork": false, + "url": "https://api.github.com/repos/NixOS/nixpkgs", + "forks_url": "https://api.github.com/repos/NixOS/nixpkgs/forks", + "keys_url": "https://api.github.com/repos/NixOS/nixpkgs/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/NixOS/nixpkgs/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/NixOS/nixpkgs/teams", + "hooks_url": "https://api.github.com/repos/NixOS/nixpkgs/hooks", + "issue_events_url": "https://api.github.com/repos/NixOS/nixpkgs/issues/events{/number}", + "events_url": "https://api.github.com/repos/NixOS/nixpkgs/events", + "assignees_url": "https://api.github.com/repos/NixOS/nixpkgs/assignees{/user}", + "branches_url": "https://api.github.com/repos/NixOS/nixpkgs/branches{/branch}", + "tags_url": "https://api.github.com/repos/NixOS/nixpkgs/tags", + "blobs_url": "https://api.github.com/repos/NixOS/nixpkgs/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/NixOS/nixpkgs/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/NixOS/nixpkgs/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/NixOS/nixpkgs/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/NixOS/nixpkgs/statuses/{sha}", + "languages_url": "https://api.github.com/repos/NixOS/nixpkgs/languages", + "stargazers_url": "https://api.github.com/repos/NixOS/nixpkgs/stargazers", + "contributors_url": "https://api.github.com/repos/NixOS/nixpkgs/contributors", + "subscribers_url": "https://api.github.com/repos/NixOS/nixpkgs/subscribers", + "subscription_url": "https://api.github.com/repos/NixOS/nixpkgs/subscription", + "commits_url": "https://api.github.com/repos/NixOS/nixpkgs/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/NixOS/nixpkgs/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/NixOS/nixpkgs/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/NixOS/nixpkgs/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/NixOS/nixpkgs/contents/{+path}", + "compare_url": "https://api.github.com/repos/NixOS/nixpkgs/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/NixOS/nixpkgs/merges", + "archive_url": "https://api.github.com/repos/NixOS/nixpkgs/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/NixOS/nixpkgs/downloads", + "issues_url": "https://api.github.com/repos/NixOS/nixpkgs/issues{/number}", + "pulls_url": "https://api.github.com/repos/NixOS/nixpkgs/pulls{/number}", + "milestones_url": "https://api.github.com/repos/NixOS/nixpkgs/milestones{/number}", + "notifications_url": "https://api.github.com/repos/NixOS/nixpkgs/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/NixOS/nixpkgs/labels{/name}", + "releases_url": "https://api.github.com/repos/NixOS/nixpkgs/releases{/id}", + "deployments_url": "https://api.github.com/repos/NixOS/nixpkgs/deployments", + "created_at": "2012-06-04T02:49:46Z", + "updated_at": "2018-02-23T20:56:05Z", + "pushed_at": "2018-02-23T21:40:58Z", + "git_url": "git://github.com/NixOS/nixpkgs.git", + "ssh_url": "git@github.com:NixOS/nixpkgs.git", + "clone_url": "https://github.com/NixOS/nixpkgs.git", + "svn_url": "https://github.com/NixOS/nixpkgs", + "homepage": null, + "size": 724069, + "stargazers_count": 2239, + "watchers_count": 2239, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 2580, + "mirror_url": null, + "archived": false, + "open_issues_count": 2860, + "license": { + "key": "other", + "name": "Other", + "spdx_id": null, + "url": null + }, + "forks": 2580, + "open_issues": 2860, + "watchers": 2239, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/pulls/33299" + }, + "html": { + "href": "https://github.com/NixOS/nixpkgs/pull/33299" + }, + "issue": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/issues/33299" + }, + "comments": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/issues/33299/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/pulls/33299/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/pulls/33299/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/NixOS/nixpkgs/statuses/887e8b460a7d45ddb3bbdebe01447b251b3229e8" + } + }, + "author_association": "MEMBER", + "merged": false, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 5, + "review_comments": 0, + "maintainer_can_modify": true, + "commits": 1, + "additions": 41, + "deletions": 4, + "changed_files": 4 + }, + "changes": { + "base": { + "ref": { + "from": "master" + }, + "sha": { + "from": "a6664d8192038c4dc2ad44169dbb76556fe71ac1" + } + } + }, + "repository": { + "id": 4542716, + "name": "nixpkgs", + "full_name": "NixOS/nixpkgs", + "owner": { + "login": "NixOS", + "id": 487568, + "avatar_url": "https://avatars3.githubusercontent.com/u/487568?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/NixOS", + "html_url": "https://github.com/NixOS", + "followers_url": "https://api.github.com/users/NixOS/followers", + "following_url": "https://api.github.com/users/NixOS/following{/other_user}", + "gists_url": "https://api.github.com/users/NixOS/gists{/gist_id}", + "starred_url": "https://api.github.com/users/NixOS/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/NixOS/subscriptions", + "organizations_url": "https://api.github.com/users/NixOS/orgs", + "repos_url": "https://api.github.com/users/NixOS/repos", + "events_url": "https://api.github.com/users/NixOS/events{/privacy}", + "received_events_url": "https://api.github.com/users/NixOS/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/NixOS/nixpkgs", + "description": "Nix Packages collection", + "fork": false, + "url": "https://api.github.com/repos/NixOS/nixpkgs", + "forks_url": "https://api.github.com/repos/NixOS/nixpkgs/forks", + "keys_url": "https://api.github.com/repos/NixOS/nixpkgs/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/NixOS/nixpkgs/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/NixOS/nixpkgs/teams", + "hooks_url": "https://api.github.com/repos/NixOS/nixpkgs/hooks", + "issue_events_url": "https://api.github.com/repos/NixOS/nixpkgs/issues/events{/number}", + "events_url": "https://api.github.com/repos/NixOS/nixpkgs/events", + "assignees_url": "https://api.github.com/repos/NixOS/nixpkgs/assignees{/user}", + "branches_url": "https://api.github.com/repos/NixOS/nixpkgs/branches{/branch}", + "tags_url": "https://api.github.com/repos/NixOS/nixpkgs/tags", + "blobs_url": "https://api.github.com/repos/NixOS/nixpkgs/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/NixOS/nixpkgs/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/NixOS/nixpkgs/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/NixOS/nixpkgs/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/NixOS/nixpkgs/statuses/{sha}", + "languages_url": "https://api.github.com/repos/NixOS/nixpkgs/languages", + "stargazers_url": "https://api.github.com/repos/NixOS/nixpkgs/stargazers", + "contributors_url": "https://api.github.com/repos/NixOS/nixpkgs/contributors", + "subscribers_url": "https://api.github.com/repos/NixOS/nixpkgs/subscribers", + "subscription_url": "https://api.github.com/repos/NixOS/nixpkgs/subscription", + "commits_url": "https://api.github.com/repos/NixOS/nixpkgs/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/NixOS/nixpkgs/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/NixOS/nixpkgs/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/NixOS/nixpkgs/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/NixOS/nixpkgs/contents/{+path}", + "compare_url": "https://api.github.com/repos/NixOS/nixpkgs/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/NixOS/nixpkgs/merges", + "archive_url": "https://api.github.com/repos/NixOS/nixpkgs/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/NixOS/nixpkgs/downloads", + "issues_url": "https://api.github.com/repos/NixOS/nixpkgs/issues{/number}", + "pulls_url": "https://api.github.com/repos/NixOS/nixpkgs/pulls{/number}", + "milestones_url": "https://api.github.com/repos/NixOS/nixpkgs/milestones{/number}", + "notifications_url": "https://api.github.com/repos/NixOS/nixpkgs/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/NixOS/nixpkgs/labels{/name}", + "releases_url": "https://api.github.com/repos/NixOS/nixpkgs/releases{/id}", + "deployments_url": "https://api.github.com/repos/NixOS/nixpkgs/deployments", + "created_at": "2012-06-04T02:49:46Z", + "updated_at": "2018-02-23T20:56:05Z", + "pushed_at": "2018-02-23T21:40:58Z", + "git_url": "git://github.com/NixOS/nixpkgs.git", + "ssh_url": "git@github.com:NixOS/nixpkgs.git", + "clone_url": "https://github.com/NixOS/nixpkgs.git", + "svn_url": "https://github.com/NixOS/nixpkgs", + "homepage": null, + "size": 724069, + "stargazers_count": 2239, + "watchers_count": 2239, + "language": "Nix", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 2580, + "mirror_url": null, + "archived": false, + "open_issues_count": 2860, + "license": { + "key": "other", + "name": "Other", + "spdx_id": null, + "url": null + }, + "forks": 2580, + "open_issues": 2860, + "watchers": 2239, + "default_branch": "master" + }, + "organization": { + "login": "NixOS", + "id": 487568, + "url": "https://api.github.com/orgs/NixOS", + "repos_url": "https://api.github.com/orgs/NixOS/repos", + "events_url": "https://api.github.com/orgs/NixOS/events", + "hooks_url": "https://api.github.com/orgs/NixOS/hooks", + "issues_url": "https://api.github.com/orgs/NixOS/issues", + "members_url": "https://api.github.com/orgs/NixOS/members{/member}", + "public_members_url": "https://api.github.com/orgs/NixOS/public_members{/member}", + "avatar_url": "https://avatars3.githubusercontent.com/u/487568?v=4", + "description": "" + }, + "sender": { + "login": "grahamc", + "id": 76716, + "avatar_url": "https://avatars3.githubusercontent.com/u/76716?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/grahamc", + "html_url": "https://github.com/grahamc", + "followers_url": "https://api.github.com/users/grahamc/followers", + "following_url": "https://api.github.com/users/grahamc/following{/other_user}", + "gists_url": "https://api.github.com/users/grahamc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/grahamc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/grahamc/subscriptions", + "organizations_url": "https://api.github.com/users/grahamc/orgs", + "repos_url": "https://api.github.com/users/grahamc/repos", + "events_url": "https://api.github.com/users/grahamc/events{/privacy}", + "received_events_url": "https://api.github.com/users/grahamc/received_events", + "type": "User", + "site_admin": false + } + } From 6e305e16aa9c19751cc384fd2865c0f6fe0af810 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 21:23:50 -0500 Subject: [PATCH 29/47] Write a evaluation job filter in rust --- ofborg/src/bin/evalution-filter.rs | 93 +++++++++++++++++ ofborg/src/tasks/evaluationfilter.rs | 149 +++++++++++++++++++++++++++ ofborg/src/tasks/mod.rs | 1 + 3 files changed, 243 insertions(+) create mode 100644 ofborg/src/bin/evalution-filter.rs create mode 100644 ofborg/src/tasks/evaluationfilter.rs diff --git a/ofborg/src/bin/evalution-filter.rs b/ofborg/src/bin/evalution-filter.rs new file mode 100644 index 0000000..525fe55 --- /dev/null +++ b/ofborg/src/bin/evalution-filter.rs @@ -0,0 +1,93 @@ +extern crate ofborg; +extern crate amqp; +extern crate env_logger; + +extern crate hyper; +extern crate hubcaps; +extern crate hyper_native_tls; + + +use std::env; + +use amqp::Basic; + +use ofborg::config; +use ofborg::worker; +use ofborg::tasks; +use ofborg::easyamqp; +use ofborg::easyamqp::TypedWrappers; + + +fn main() { + let cfg = config::load(env::args().nth(1).unwrap().as_ref()); + ofborg::setup_log(); + + println!("Hello, world!"); + + + let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); + println!("Connected to rabbitmq"); + + let mut channel = session.open_channel(1).unwrap(); + + channel + .declare_queue(easyamqp::QueueConfig { + queue: "mass-rebuild-check-jobs".to_owned(), + passive: false, + durable: true, + exclusive: false, + auto_delete: false, + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel + .declare_queue(easyamqp::QueueConfig { + queue: "mass-rebuild-check-inputs".to_owned(), + passive: false, + durable: true, + exclusive: false, + auto_delete: false, + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel + .bind_queue(easyamqp::BindQueueConfig { + queue: "mass-rebuild-check-inputs".to_owned(), + exchange: "github-events".to_owned(), + routing_key: Some("pull_request.nixos/nixpkgs".to_owned()), + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel.basic_prefetch(1).unwrap(); + channel + .consume( + worker::new(tasks::evaluationfilter::EvaluationFilterWorker::new( + cfg.acl(), + )), + easyamqp::ConsumeConfig { + queue: "mass-rebuild-check-inputs".to_owned(), + consumer_tag: format!("{}-evaluation-filter", cfg.whoami()), + no_local: false, + no_ack: false, + no_wait: false, + exclusive: false, + arguments: None, + }, + ) + .unwrap(); + + channel.start_consuming(); + + println!("Finished consuming?"); + + channel.close(200, "Bye").unwrap(); + println!("Closed the channel"); + session.close(200, "Good Bye"); + println!("Closed the session... EOF"); +} diff --git a/ofborg/src/tasks/evaluationfilter.rs b/ofborg/src/tasks/evaluationfilter.rs new file mode 100644 index 0000000..e506195 --- /dev/null +++ b/ofborg/src/tasks/evaluationfilter.rs @@ -0,0 +1,149 @@ +extern crate amqp; +extern crate env_logger; + +use ofborg::ghevent; +use ofborg::acl; +use serde_json; + +use ofborg::message::{Repo, Pr, massrebuildjob}; +use ofborg::worker; +use amqp::protocol::basic::{Deliver, BasicProperties}; + + +pub struct EvaluationFilterWorker { + acl: acl::ACL, +} + + impl EvaluationFilterWorker { + pub fn new(acl: acl::ACL) -> EvaluationFilterWorker { + return EvaluationFilterWorker { + acl: acl, + }; + } +} + +impl worker::SimpleWorker for EvaluationFilterWorker { + type J = ghevent::PullRequestEvent; + + fn msg_to_job( + &mut self, + _: &Deliver, + _: &BasicProperties, + body: &Vec, + ) -> Result { + return match serde_json::from_slice(body) { + Ok(e) => Ok(e), + Err(e) => { + Err(format!( + "Failed to deserialize job {:?}: {:?}", + e, + String::from_utf8(body.clone()) + )) + } + }; + } + + fn consumer(&mut self, job: &ghevent::PullRequestEvent) -> worker::Actions { + if !self.acl.is_repo_eligible(&job.repository.full_name) { + info!("Repo not authorized ({})", job.repository.full_name); + return vec![worker::Action::Ack]; + } + + if job.pull_request.state != ghevent::PullRequestState::Open { + info!("PR is not open ({}#{})", job.repository.full_name, job.number); + return vec![worker::Action::Ack]; + } + + let interesting: bool = match job.action { + ghevent::PullRequestAction::Opened => true, + ghevent::PullRequestAction::Synchronize => true, + ghevent::PullRequestAction::Reopened => true, + ghevent::PullRequestAction::Edited => { + if let Some(ref changes) = job.changes { + changes.base.is_some() + } else { + false + } + }, + _ => false, + }; + + if interesting { + let repo_msg = Repo { + clone_url: job.repository.clone_url.clone(), + full_name: job.repository.full_name.clone(), + owner: job.repository.owner.login.clone(), + name: job.repository.name.clone(), + }; + + let pr_msg = Pr { + number: job.number.clone(), + head_sha: job.pull_request.head.sha.clone(), + target_branch: Some(job.pull_request.base.git_ref.clone()), + }; + + let msg = massrebuildjob::MassRebuildJob { + repo: repo_msg.clone(), + pr: pr_msg.clone(), + }; + + return vec![ + worker::publish_serde_action( + Some("mass-rebuild-check-jobs".to_owned()), + None, + &msg + ), + worker::Action::Ack + ]; + } + + return vec![ + worker::Action::Ack + ]; + } +} + +#[cfg(test)] +mod tests { + use worker::SimpleWorker; + use super::*; + + #[test] + fn changed_base() { + let data = include_str!("../../test-srcs/events/pr-changed-base.json"); + + let job: ghevent::PullRequestEvent = + serde_json::from_str(&data.to_string()) + .expect("Should properly deserialize"); + + let mut worker = EvaluationFilterWorker::new(acl::ACL::new( + vec!["nixos/nixpkgs".to_owned()], + vec![], + vec![], + )); + + assert_eq!( + worker.consumer(&job), + vec![ + worker::publish_serde_action( + Some("mass-rebuild-check-jobs".to_owned()), + None, + &massrebuildjob::MassRebuildJob { + repo: Repo { + clone_url: String::from("https://github.com/NixOS/nixpkgs.git"), + full_name: String::from("NixOS/nixpkgs"), + owner: String::from("NixOS"), + name: String::from("nixpkgs"), + }, + pr: Pr { + number: 33299, + head_sha: String::from("887e8b460a7d45ddb3bbdebe01447b251b3229e8"), + target_branch: Some(String::from("staging")), + }, + } + ), + worker::Action::Ack, + ] + ); + } +} diff --git a/ofborg/src/tasks/mod.rs b/ofborg/src/tasks/mod.rs index 663bab6..531e981 100644 --- a/ofborg/src/tasks/mod.rs +++ b/ofborg/src/tasks/mod.rs @@ -5,3 +5,4 @@ pub mod githubcommentfilter; pub mod githubcommentposter; pub mod statscollector; pub mod log_message_collector; +pub mod evaluationfilter; From 08a0a799766ff92d9a63d684daf5c1d514326905 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 21:28:32 -0500 Subject: [PATCH 30/47] Remove extra libs now that the mass rebuild filter isn't PHP anymore --- README.md | 10 +- php/composer.json | 4 +- php/composer.lock | 936 +----------------------------------- php/mass-rebuild-filter.php | 113 ----- 4 files changed, 12 insertions(+), 1051 deletions(-) delete mode 100644 php/mass-rebuild-filter.php diff --git a/README.md b/README.md index aeb2ce5..78206c4 100644 --- a/README.md +++ b/README.md @@ -214,13 +214,9 @@ function rabbitmq_conn($timeout = 3) { return $connection; } -function gh_client() { - $client = new \Github\Client(); - $client->authenticate('githubusername', - 'githubpassword', - Github\Client::AUTH_HTTP_PASSWORD); - - return $client; +function gh_secret() { + return "github webhook secret"; } + ``` diff --git a/php/composer.json b/php/composer.json index df67e8b..af4f062 100644 --- a/php/composer.json +++ b/php/composer.json @@ -1,8 +1,6 @@ { "require": { - "php-amqplib/php-amqplib": ">=2.6.1", - "knplabs/github-api": "^2.6@dev", - "php-http/guzzle6-adapter": "^1.2@dev" + "php-amqplib/php-amqplib": ">=2.6.1" }, "minimum-stability": "dev", "autoload": { diff --git a/php/composer.lock b/php/composer.lock index a453b7f..fc4a96a 100644 --- a/php/composer.lock +++ b/php/composer.lock @@ -4,321 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "0ee26122485b777e3ea752a8d5da0c61", + "content-hash": "dc3ed822ebc471c3f81c3a8a787af555", "packages": [ - { - "name": "clue/stream-filter", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/clue/php-stream-filter.git", - "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", - "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "^5.0 || ^4.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Clue\\StreamFilter\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@lueck.tv" - } - ], - "description": "A simple and modern approach to stream filtering in PHP", - "homepage": "https://github.com/clue/php-stream-filter", - "keywords": [ - "bucket brigade", - "callback", - "filter", - "php_user_filter", - "stream", - "stream_filter_append", - "stream_filter_register" - ], - "time": "2017-08-18T09:54:01+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.3.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699", - "shasum": "" - }, - "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0 || ^5.0", - "psr/log": "^1.0" - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.2-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2017-06-22T18:50:49+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "2e48ae638dc0bf0849772f5590835fcd700a2e1d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/2e48ae638dc0bf0849772f5590835fcd700a2e1d", - "reference": "2e48ae638dc0bf0849772f5590835fcd700a2e1d", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2017-12-07T21:04:15+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "d2537c86fa8b004c29e9b9f5e10028f0a29df101" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/d2537c86fa8b004c29e9b9f5e10028f0a29df101", - "reference": "d2537c86fa8b004c29e9b9f5e10028f0a29df101", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2017-10-07T03:19:56+00:00" - }, - { - "name": "knplabs/github-api", - "version": "2.7.0", - "source": { - "type": "git", - "url": "https://github.com/KnpLabs/php-github-api.git", - "reference": "d445f1eec4788763315c3c96a214db4e149f9deb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/d445f1eec4788763315c3c96a214db4e149f9deb", - "reference": "d445f1eec4788763315c3c96a214db4e149f9deb", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0", - "php-http/cache-plugin": "^1.4", - "php-http/client-common": "^1.3", - "php-http/client-implementation": "^1.0", - "php-http/discovery": "^1.0", - "php-http/httplug": "^1.1", - "psr/cache": "^1.0", - "psr/http-message": "^1.0" - }, - "require-dev": { - "cache/array-adapter": "^0.4", - "guzzlehttp/psr7": "^1.2", - "php-http/guzzle6-adapter": "^1.0", - "php-http/mock-client": "^1.0", - "phpunit/phpunit": "^5.5 || ^6.0", - "sllh/php-cs-fixer-styleci-bridge": "^1.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6.x-dev" - } - }, - "autoload": { - "psr-4": { - "Github\\": "lib/Github/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Thibault Duplessis", - "email": "thibault.duplessis@gmail.com", - "homepage": "http://ornicar.github.com" - }, - { - "name": "KnpLabs Team", - "homepage": "http://knplabs.com" - } - ], - "description": "GitHub API v3 client", - "homepage": "https://github.com/KnpLabs/php-github-api", - "keywords": [ - "api", - "gh", - "gist", - "github" - ], - "time": "2017-12-12T20:14:04+00:00" - }, { "name": "php-amqplib/php-amqplib", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/php-amqplib/php-amqplib.git", - "reference": "0f90b3d8bc50403458f0eefbcba7d1e2329dd0f6" + "reference": "dfd3694a86f1a7394d3693485259d4074a6ec79b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/0f90b3d8bc50403458f0eefbcba7d1e2329dd0f6", - "reference": "0f90b3d8bc50403458f0eefbcba7d1e2329dd0f6", + "url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/dfd3694a86f1a7394d3693485259d4074a6ec79b", + "reference": "dfd3694a86f1a7394d3693485259d4074a6ec79b", "shasum": "" }, "require": { @@ -330,6 +29,7 @@ "videlalvaro/php-amqplib": "self.version" }, "require-dev": { + "phpdocumentor/phpdocumentor": "^2.9", "phpunit/phpunit": "^4.8", "scrutinizer/ocular": "^1.1", "squizlabs/php_codesniffer": "^2.5" @@ -350,7 +50,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-2.1" + "LGPL-2.1-or-later" ], "authors": [ { @@ -375,633 +75,13 @@ "queue", "rabbitmq" ], - "time": "2017-09-26T05:30:15+00:00" - }, - { - "name": "php-http/cache-plugin", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/cache-plugin.git", - "reference": "c573ac6ea9b4e33fad567f875b844229d18000b9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/cache-plugin/zipball/c573ac6ea9b4e33fad567f875b844229d18000b9", - "reference": "c573ac6ea9b4e33fad567f875b844229d18000b9", - "shasum": "" - }, - "require": { - "php": "^5.4 || ^7.0", - "php-http/client-common": "^1.1", - "php-http/message-factory": "^1.0", - "psr/cache": "^1.0", - "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Client\\Common\\Plugin\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "PSR-6 Cache plugin for HTTPlug", - "homepage": "http://httplug.io", - "keywords": [ - "cache", - "http", - "httplug", - "plugin" - ], - "time": "2017-11-29T20:45:41+00:00" - }, - { - "name": "php-http/client-common", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/client-common.git", - "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/client-common/zipball/9accb4a082eb06403747c0ffd444112eda41a0fd", - "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd", - "shasum": "" - }, - "require": { - "php": "^5.4 || ^7.0", - "php-http/httplug": "^1.1", - "php-http/message": "^1.6", - "php-http/message-factory": "^1.0", - "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" - }, - "require-dev": { - "guzzlehttp/psr7": "^1.4", - "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2" - }, - "suggest": { - "php-http/cache-plugin": "PSR-6 Cache plugin", - "php-http/logger-plugin": "PSR-3 Logger plugin", - "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.7-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Client\\Common\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "Common HTTP Client implementations and tools for HTTPlug", - "homepage": "http://httplug.io", - "keywords": [ - "client", - "common", - "http", - "httplug" - ], - "time": "2017-11-30T11:06:59+00:00" - }, - { - "name": "php-http/discovery", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/discovery.git", - "reference": "0ecc08360e6011a4454dc60077db6e9f412be94c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/discovery/zipball/0ecc08360e6011a4454dc60077db6e9f412be94c", - "reference": "0ecc08360e6011a4454dc60077db6e9f412be94c", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^2.0.2", - "php-http/httplug": "^1.0", - "php-http/message-factory": "^1.0", - "phpspec/phpspec": "^2.4", - "puli/composer-plugin": "1.0.0-beta10" - }, - "suggest": { - "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", - "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Discovery\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "Finds installed HTTPlug implementations and PSR-7 message factories", - "homepage": "http://php-http.org", - "keywords": [ - "adapter", - "client", - "discovery", - "factory", - "http", - "message", - "psr7" - ], - "time": "2017-11-22T21:17:04+00:00" - }, - { - "name": "php-http/guzzle6-adapter", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/guzzle6-adapter.git", - "reference": "54181ff8455a4c2e1706a53e0d98060b93030321" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/54181ff8455a4c2e1706a53e0d98060b93030321", - "reference": "54181ff8455a4c2e1706a53e0d98060b93030321", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.0", - "php": "^5.5 || ^7.0", - "php-http/httplug": "^1.0" - }, - "provide": { - "php-http/async-client-implementation": "1.0", - "php-http/client-implementation": "1.0" - }, - "require-dev": { - "ext-curl": "*", - "php-http/client-integration-tests": "^0.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Adapter\\Guzzle6\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "David de Boer", - "email": "david@ddeboer.nl" - } - ], - "description": "Guzzle 6 HTTP Adapter", - "homepage": "http://httplug.io", - "keywords": [ - "Guzzle", - "http" - ], - "time": "2017-05-29T15:06:15+00:00" - }, - { - "name": "php-http/httplug", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/httplug.git", - "reference": "afa7b216322f8157e21025f04f72eda0ee12f89d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/httplug/zipball/afa7b216322f8157e21025f04f72eda0ee12f89d", - "reference": "afa7b216322f8157e21025f04f72eda0ee12f89d", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "php-http/promise": "^1.0", - "psr/http-message": "^1.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Eric GELOEN", - "email": "geloen.eric@gmail.com" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "HTTPlug, the HTTP client abstraction for PHP", - "homepage": "http://httplug.io", - "keywords": [ - "client", - "http" - ], - "time": "2017-12-18T08:01:36+00:00" - }, - { - "name": "php-http/message", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/message.git", - "reference": "977edb516e3c0419d3477610b4b718c8a9da1575" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/message/zipball/977edb516e3c0419d3477610b4b718c8a9da1575", - "reference": "977edb516e3c0419d3477610b4b718c8a9da1575", - "shasum": "" - }, - "require": { - "clue/stream-filter": "^1.4", - "php": ">=5.4", - "php-http/message-factory": "^1.0.2", - "psr/http-message": "^1.0" - }, - "provide": { - "php-http/message-factory-implementation": "1.0" - }, - "require-dev": { - "akeneo/phpspec-skip-example-extension": "^1.0", - "coduo/phpspec-data-provider-extension": "^1.0", - "ext-zlib": "*", - "guzzlehttp/psr7": "^1.0", - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4", - "slim/slim": "^3.0", - "zendframework/zend-diactoros": "^1.0" - }, - "suggest": { - "ext-zlib": "Used with compressor/decompressor streams", - "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", - "slim/slim": "Used with Slim Framework PSR-7 implementation", - "zendframework/zend-diactoros": "Used with Diactoros Factories" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Message\\": "src/" - }, - "files": [ - "src/filters.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "HTTP Message related tools", - "homepage": "http://php-http.org", - "keywords": [ - "http", - "message", - "psr-7" - ], - "time": "2017-11-25T06:38:46+00:00" - }, - { - "name": "php-http/message-factory", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/message-factory.git", - "reference": "a2809d4fe294ebe8879aec8d4d5bf21faa029344" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/message-factory/zipball/a2809d4fe294ebe8879aec8d4d5bf21faa029344", - "reference": "a2809d4fe294ebe8879aec8d4d5bf21faa029344", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "Factory interfaces for PSR-7 HTTP Message", - "homepage": "http://php-http.org", - "keywords": [ - "factory", - "http", - "message", - "stream", - "uri" - ], - "time": "2016-02-03T08:16:31+00:00" - }, - { - "name": "php-http/promise", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-http/promise.git", - "reference": "1cc44dc01402d407fc6da922591deebe4659826f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/promise/zipball/1cc44dc01402d407fc6da922591deebe4659826f", - "reference": "1cc44dc01402d407fc6da922591deebe4659826f", - "shasum": "" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Http\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "Joel Wurtz", - "email": "joel.wurtz@gmail.com" - } - ], - "description": "Promise used for asynchronous HTTP requests", - "homepage": "http://httplug.io", - "keywords": [ - "promise" - ], - "time": "2017-11-22T21:24:54+00:00" - }, - { - "name": "psr/cache", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "78c5a01ddbf11cf731f1338a4f5aba23b14d5b47" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/78c5a01ddbf11cf731f1338a4f5aba23b14d5b47", - "reference": "78c5a01ddbf11cf731f1338a4f5aba23b14d5b47", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "time": "2016-10-13T14:48:10+00:00" - }, - { - "name": "psr/http-message", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "95a16ad04c0ca3404c9286eca3b4a0c36cc46f7d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/95a16ad04c0ca3404c9286eca3b4a0c36cc46f7d", - "reference": "95a16ad04c0ca3404c9286eca3b4a0c36cc46f7d", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony OptionsResolver Component", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "time": "2017-12-14T19:50:39+00:00" + "time": "2018-02-11T19:28:00+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "dev", - "stability-flags": { - "knplabs/github-api": 20, - "php-http/guzzle6-adapter": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], diff --git a/php/mass-rebuild-filter.php b/php/mass-rebuild-filter.php deleted file mode 100644 index a73ba29..0000000 --- a/php/mass-rebuild-filter.php +++ /dev/null @@ -1,113 +0,0 @@ -channel(); -$channel->basic_qos(null, 1, true); - - -$channel->queue_declare('mass-rebuild-check-jobs', - false, true, false, false); -list($queueName, , ) = $channel->queue_declare('mass-rebuild-check-inputs', - false, true, false, false); -$channel->queue_bind($queueName, 'github-events', 'pull_request.nixos/nixpkgs'); - -echo "hi\n"; - -function outrunner($msg) { - try { - runner($msg); - } catch (\PhpAmqpLib\Exception\AMQPProtocolChannelException $e) { - echo "Channel exception:\n"; - var_dump($e); - } -} - -function runner($msg) { - echo "Msg Sha: " . md5($msg->body) . "\n"; - $in = json_decode($msg->body); - - if (!\GHE\ACL::isRepoEligible($in->repository->full_name)) { - echo "Repo not authorized (" . $in->repository->full_name . ")\n"; - $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); - return true; - } - - if ($in->pull_request->state != "open") { - echo "PR isn't open in the event\n"; - $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); - return true; - } - - $client = gh_client(); - $status = $client->api('pull_request')->show( - $in->repository->owner->login, - $in->repository->name, - $in->number); - if ($status['mergeable'] === false) { - echo "github says the PR isn't able to be merged\n"; - $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); - return true; - } - if ($status['state'] !== 'open') { - echo "github says the PR isn't open\n"; - $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); - return true; - } - - - $ok_events = [ - 'opened', - 'created', - 'synchronize', - 'reopened', - ]; - - if (!in_array($in->action, $ok_events)) { - echo "Uninteresting event " . $in->action . "\n"; - $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); - return true; - } else { - echo "so-called interesting event on #" . $in->number . ": " . $in->action . "\n"; - } - - $forward = [ - 'original_payload' => $in, - 'repo' => [ - 'owner' => $in->repository->owner->login, - 'name' => $in->repository->name, - 'full_name' => $in->repository->full_name, - 'clone_url' => $in->repository->clone_url, - ], - 'pr' => [ - 'number' => $in->number, - 'target_branch' => $in->pull_request->base->ref, - 'patch_url' => $in->pull_request->patch_url, - 'head_sha' => $in->pull_request->head->sha, - ], - ]; - - - echo "forwarding to mass-rebuild-check-jobs :)\n"; - - $message = new AMQPMessage(json_encode($forward), - array( - 'content_type' => 'application/json', - 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT, - )); - $msg->delivery_info['channel']->basic_publish($message, '', 'mass-rebuild-check-jobs'); - $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); - return true; -} - -$consumerTag = 'massrebuildcheckfilter' . getmypid(); -$channel->basic_consume($queueName, $consumerTag, false, false, false, false, 'outrunner'); -while(count($channel->callbacks)) { - $channel->wait(); -} - -echo "Bye\n"; \ No newline at end of file From f6289be8612a24d46b683a3ecd31c88281ff217b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 21:45:18 -0500 Subject: [PATCH 31/47] Add repos to the public config --- config.public.json | 3 +++ ofborg/src/bin/{evalution-filter.rs => evaluation-filter.rs} | 0 2 files changed, 3 insertions(+) rename ofborg/src/bin/{evalution-filter.rs => evaluation-filter.rs} (100%) diff --git a/config.public.json b/config.public.json index d44b9a1..3aaeea9 100644 --- a/config.public.json +++ b/config.public.json @@ -6,6 +6,9 @@ "path": "/var/lib/nginx/ofborg/logs/" }, "runner": { + "repos": [ + "nixos/nixpkgs" + ], "trusted_users": [ "7c6f434c", "adisbladis", diff --git a/ofborg/src/bin/evalution-filter.rs b/ofborg/src/bin/evaluation-filter.rs similarity index 100% rename from ofborg/src/bin/evalution-filter.rs rename to ofborg/src/bin/evaluation-filter.rs From aa562cf94372208c0f42151959ca634bd881b1a6 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 21:45:55 -0500 Subject: [PATCH 32/47] fixup queue to publish to --- ofborg/src/tasks/evaluationfilter.rs | 57 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/ofborg/src/tasks/evaluationfilter.rs b/ofborg/src/tasks/evaluationfilter.rs index e506195..296642b 100644 --- a/ofborg/src/tasks/evaluationfilter.rs +++ b/ofborg/src/tasks/evaluationfilter.rs @@ -68,39 +68,46 @@ impl worker::SimpleWorker for EvaluationFilterWorker { _ => false, }; - if interesting { - let repo_msg = Repo { - clone_url: job.repository.clone_url.clone(), - full_name: job.repository.full_name.clone(), - owner: job.repository.owner.login.clone(), - name: job.repository.name.clone(), - }; - - let pr_msg = Pr { - number: job.number.clone(), - head_sha: job.pull_request.head.sha.clone(), - target_branch: Some(job.pull_request.base.git_ref.clone()), - }; - - let msg = massrebuildjob::MassRebuildJob { - repo: repo_msg.clone(), - pr: pr_msg.clone(), - }; + if !interesting { + info!("Not interesting: {}#{} to be interesting because of {:?}", + job.repository.full_name, job.number, job.action + ); return vec![ - worker::publish_serde_action( - Some("mass-rebuild-check-jobs".to_owned()), - None, - &msg - ), worker::Action::Ack ]; } + info!("Found {}#{} to be interesting because of {:?}", + job.repository.full_name, job.number, job.action + ); + let repo_msg = Repo { + clone_url: job.repository.clone_url.clone(), + full_name: job.repository.full_name.clone(), + owner: job.repository.owner.login.clone(), + name: job.repository.name.clone(), + }; + + let pr_msg = Pr { + number: job.number.clone(), + head_sha: job.pull_request.head.sha.clone(), + target_branch: Some(job.pull_request.base.git_ref.clone()), + }; + + let msg = massrebuildjob::MassRebuildJob { + repo: repo_msg.clone(), + pr: pr_msg.clone(), + }; + return vec![ + worker::publish_serde_action( + None, + Some("mass-rebuild-check-jobs".to_owned()), + &msg + ), worker::Action::Ack ]; - } + } } #[cfg(test)] @@ -126,8 +133,8 @@ mod tests { worker.consumer(&job), vec![ worker::publish_serde_action( - Some("mass-rebuild-check-jobs".to_owned()), None, + Some("mass-rebuild-check-jobs".to_owned()), &massrebuildjob::MassRebuildJob { repo: Repo { clone_url: String::from("https://github.com/NixOS/nixpkgs.git"), From e1cb289d80cda068ec1add455ffb2c5eae4e07c3 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 21:52:17 -0500 Subject: [PATCH 33/47] fixup log --- ofborg/src/tasks/evaluationfilter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofborg/src/tasks/evaluationfilter.rs b/ofborg/src/tasks/evaluationfilter.rs index 296642b..95f8fab 100644 --- a/ofborg/src/tasks/evaluationfilter.rs +++ b/ofborg/src/tasks/evaluationfilter.rs @@ -69,7 +69,7 @@ impl worker::SimpleWorker for EvaluationFilterWorker { }; if !interesting { - info!("Not interesting: {}#{} to be interesting because of {:?}", + info!("Not interesting: {}#{} because of {:?}", job.repository.full_name, job.number, job.action ); From 695fea935a2d99049f82b0a2fddcae7385437fa0 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 23 Feb 2018 22:00:37 -0500 Subject: [PATCH 34/47] Prune more unneeded PHP bits --- php/composer.json | 4 ---- php/composer.lock | 6 +++--- php/src/ACL.php | 16 ---------------- 3 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 php/src/ACL.php diff --git a/php/composer.json b/php/composer.json index af4f062..3928836 100644 --- a/php/composer.json +++ b/php/composer.json @@ -1,9 +1,5 @@ { "require": { "php-amqplib/php-amqplib": ">=2.6.1" - }, - "minimum-stability": "dev", - "autoload": { - "psr-4": {"GHE\\": "src/"} } } diff --git a/php/composer.lock b/php/composer.lock index fc4a96a..351ea07 100644 --- a/php/composer.lock +++ b/php/composer.lock @@ -4,11 +4,11 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "dc3ed822ebc471c3f81c3a8a787af555", + "content-hash": "f0b42ac9169509834501cb7aa271b580", "packages": [ { "name": "php-amqplib/php-amqplib", - "version": "dev-master", + "version": "v2.7.2", "source": { "type": "git", "url": "https://github.com/php-amqplib/php-amqplib.git", @@ -80,7 +80,7 @@ ], "packages-dev": [], "aliases": [], - "minimum-stability": "dev", + "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, diff --git a/php/src/ACL.php b/php/src/ACL.php deleted file mode 100644 index e9e14be..0000000 --- a/php/src/ACL.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Sun, 25 Feb 2018 17:40:36 +0100 Subject: [PATCH 35/47] mark vim-plugins changes with vim topic --- config.public.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config.public.json b/config.public.json index 3aaeea9..ee787b5 100644 --- a/config.public.json +++ b/config.public.json @@ -127,6 +127,7 @@ ], "6.topic: vim": [ "pkgs/applications/editors/vim", + "pkgs/misc/vim-plugins", "doc/languages-frameworks/vim.md" ], "6.topic: xfce": [ From 20a85b6fa78ed1b86cb5cef70de5aa7949d1d67d Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Mon, 26 Feb 2018 23:00:52 +0100 Subject: [PATCH 36/47] nix: fix test with ANSI escape characters The nix commands print the error: commands in red, the ANSI reset caused one of the tests to fail. --- ofborg/src/nix.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index 207320a..8fc5421 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -261,6 +261,7 @@ mod tests { let buildlog = lines .into_iter() + .map(|line| line.replace("\u{1b}[0m", "")) // ANSI reset .map(|line| format!(" | {}", line)) .collect::>() .join("\n"); From d6787a0923f4530f611f4045d488e81e76a60607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Romildo=20Malaquias?= Date: Wed, 28 Feb 2018 17:04:38 -0300 Subject: [PATCH 37/47] Add romildo to config.public.json --- config.public.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config.public.json b/config.public.json index 5cc51fb..724cb06 100644 --- a/config.public.json +++ b/config.public.json @@ -40,6 +40,7 @@ "orivej", "peti", "rbvermaa", + "romildo", "ryantm", "shlevy", "srhb", From 71f63ef0fd4e3ec0a10e88e1153366a314d1195b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 1 Mar 2018 12:58:04 -0500 Subject: [PATCH 38/47] Document known vs. trusted users and their implicatinos --- README.md | 29 ++++++++++++++++++++++++++--- config.extra-known-users.json | 1 - config.public.json | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 78206c4..ec0ff37 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ ## Automatic Building -Users who are _trusted_ (see: ./config.public.json) or _known_ (see: -./config.known-users.json) will have their PRs automatically trigger -builds if their commits follow the well-defined format of Nixpkgs. +Users who are _trusted_ or _known_ (see: Trusted Users vs Known Users) +will have their PRs automatically trigger builds if their commits +follow the well-defined format of Nixpkgs. + Example messages and the builds: |Message|Automatic Build| @@ -104,6 +105,28 @@ This is will build `list`, `of`, `attrs`, `looks`, `good`, `to`, `me!`: @grahamcofborg build list of attrs looks good to me! ``` +## Trusted Users vs Known Users + +Known users have their builds executed on platforms with working +sandboxing. At the time of writing, that means: + + - `x86_64-linux` + - `aarch64_linux` + +Trusted users have their builds executed on _all_ platforms, even if +they don't have good sandboxing. This opens the host up to a higher +risk of security issues, so only well known, trusted member of the +community should be added to the trusted user list. + +At the time of writing, trusted users have their builds run on the +following platforms: + + - `x86_64-linux` + - `aarch64_linux` + - `x86_64-darwin` + +See ./config.public.json and ./config.known-users.json for a list of +all the trusted and known users. # How does OfBorg call nix-build? diff --git a/config.extra-known-users.json b/config.extra-known-users.json index 22a7dc7..9d015b2 100644 --- a/config.extra-known-users.json +++ b/config.extra-known-users.json @@ -1,6 +1,5 @@ [ "bhipple", - "dotlambda", "dywedir", "unode" ] diff --git a/config.public.json b/config.public.json index 724cb06..33509c7 100644 --- a/config.public.json +++ b/config.public.json @@ -23,7 +23,7 @@ "dtzwill", "edolstra", "ericson2314", - "flokli", + "flokli", "fpletz", "fridh", "garbas", From c6855b5fd38dea77f178eb2baa6c3fe49d347227 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 1 Mar 2018 22:42:01 -0500 Subject: [PATCH 39/47] Add some explicit declarations --- ofborg/src/bin/builder.rs | 34 ++++++++++++++++++++++++++++++++++ ofborg/src/bin/stats.rs | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/ofborg/src/bin/builder.rs b/ofborg/src/bin/builder.rs index 538252f..0be9718 100644 --- a/ofborg/src/bin/builder.rs +++ b/ofborg/src/bin/builder.rs @@ -40,6 +40,40 @@ fn main() { let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); let mut channel = session.open_channel(1).unwrap(); channel.basic_prefetch(1).unwrap(); + channel + .declare_exchange(easyamqp::ExchangeConfig { + exchange: "build-inputs".to_owned(), + exchange_type: easyamqp::ExchangeType::Fanout, + passive: false, + durable: true, + auto_delete: false, + no_wait: false, + internal: false, + arguments: None, + }) + .unwrap(); + + channel + .declare_queue(easyamqp::QueueConfig { + queue: format!("build-inputs-{}", cfg.nix.system.clone()), + passive: false, + durable: true, + exclusive: false, + auto_delete: false, + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel + .bind_queue(easyamqp::BindQueueConfig { + queue: format!("build-inputs-{}", cfg.nix.system.clone()), + exchange: "build-inputs".to_owned(), + routing_key: None, + no_wait: false, + arguments: None, + }) + .unwrap(); channel .consume( diff --git a/ofborg/src/bin/stats.rs b/ofborg/src/bin/stats.rs index ad3ada0..5762609 100644 --- a/ofborg/src/bin/stats.rs +++ b/ofborg/src/bin/stats.rs @@ -34,13 +34,47 @@ fn main() { ); let mut channel = session.open_channel(1).unwrap(); + channel + .declare_exchange(easyamqp::ExchangeConfig { + exchange: "stats".to_owned(), + exchange_type: easyamqp::ExchangeType::Fanout, + passive: false, + durable: true, + auto_delete: false, + no_wait: false, + internal: false, + arguments: None, + }) + .unwrap(); + + channel + .declare_queue(easyamqp::QueueConfig { + queue: "stats-events".to_owned(), + passive: false, + durable: true, + exclusive: false, + auto_delete: false, + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel + .bind_queue(easyamqp::BindQueueConfig { + queue: "stats-events".to_owned(), + exchange: "stats".to_owned(), + routing_key: None, + no_wait: false, + arguments: None, + }) + .unwrap(); channel.basic_prefetch(1).unwrap(); channel .consume( worker::new(collector), easyamqp::ConsumeConfig { - queue: "sample-stats-events".to_owned(), + queue: "stats-events".to_owned(), consumer_tag: format!("{}-prometheus-stats-collector", cfg.whoami()), no_local: false, no_ack: false, From 7eb39889c32274d46e23c48e72979c29083592a7 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 1 Mar 2018 22:42:25 -0500 Subject: [PATCH 40/47] Allow configuring vhost --- ofborg/src/config.rs | 6 ++++-- ofborg/src/easyamqp.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index ff886a4..2b81fdd 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -33,6 +33,7 @@ pub struct FeedbackConfig { pub struct RabbitMQConfig { pub ssl: bool, pub host: String, + pub virtualhost: Option, pub username: String, pub password: String, } @@ -118,11 +119,12 @@ impl Config { impl RabbitMQConfig { pub fn as_uri(&self) -> String { return format!( - "{}://{}:{}@{}//", + "{}://{}:{}@{}/{}", if self.ssl { "amqps" } else { "amqp" }, self.username, self.password, - self.host + self.host, + self.virtualhost.clone().unwrap_or("/".to_owned()), ); } } diff --git a/ofborg/src/easyamqp.rs b/ofborg/src/easyamqp.rs index e3c57ed..d729619 100644 --- a/ofborg/src/easyamqp.rs +++ b/ofborg/src/easyamqp.rs @@ -301,7 +301,7 @@ pub fn session_from_config(config: &RabbitMQConfig) -> Result 5671, amqp::AMQPScheme::AMQP => 5672, }, - vhost: "/".to_owned(), + vhost: config.virtualhost.clone().unwrap_or("/".to_owned()), login: config.username.clone(), password: config.password.clone(), scheme: scheme, From 7f0c39a3155a0e7f122e8121d471cf1c3b10073b Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 2 Mar 2018 19:41:13 -0500 Subject: [PATCH 41/47] builders: correct the definition --- ofborg/src/bin/builder.rs | 4 +- ofborg/src/bin/log-message-collector.rs | 51 +++++++++++++++---------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/ofborg/src/bin/builder.rs b/ofborg/src/bin/builder.rs index 0be9718..7c2475f 100644 --- a/ofborg/src/bin/builder.rs +++ b/ofborg/src/bin/builder.rs @@ -42,7 +42,7 @@ fn main() { channel.basic_prefetch(1).unwrap(); channel .declare_exchange(easyamqp::ExchangeConfig { - exchange: "build-inputs".to_owned(), + exchange: "build-jobs".to_owned(), exchange_type: easyamqp::ExchangeType::Fanout, passive: false, durable: true, @@ -68,7 +68,7 @@ fn main() { channel .bind_queue(easyamqp::BindQueueConfig { queue: format!("build-inputs-{}", cfg.nix.system.clone()), - exchange: "build-inputs".to_owned(), + exchange: "build-jobs".to_owned(), routing_key: None, no_wait: false, arguments: None, diff --git a/ofborg/src/bin/log-message-collector.rs b/ofborg/src/bin/log-message-collector.rs index f6eb773..f40b7e9 100644 --- a/ofborg/src/bin/log-message-collector.rs +++ b/ofborg/src/bin/log-message-collector.rs @@ -23,29 +23,40 @@ fn main() { let mut channel = session.open_channel(1).unwrap(); - let queue_name = channel - .queue_declare( - "", - false, // passive - false, // durable - true, // exclusive - true, // auto_delete - false, //nowait - Table::new(), - ) - .expect("Failed to declare an anon queue for log collection!") - .queue; - channel - .queue_bind( - queue_name.as_ref(), - "logs", - "*.*".as_ref(), - false, - Table::new(), - ) + .declare_exchange(easyamqp::ExchangeConfig { + exchange: "logs".to_owned(), + exchange_type: easyamqp::ExchangeType::Topic, + passive: false, + durable: true, + auto_delete: false, + no_wait: false, + internal: false, + arguments: None, + }) .unwrap(); + let queue_name = channel + .declare_queue(easyamqp::QueueConfig { + queue: "".to_owned(), + passive: false, + durable: false, + exclusive: true, + auto_delete: true, + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel + .bind_queue(easyamqp::BindQueueConfig { + queue: queue_name.clone(), + exchange: "logs".to_owned(), + routing_key: Some("*.*".to_owned()), + no_wait: false, + arguments: None, + }) + .unwrap(); channel .consume( From 4a3aa348a346d176079f514e708b0486e27e9133 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 2 Mar 2018 19:44:21 -0500 Subject: [PATCH 42/47] Declare github-events exchange in the evaluation filter --- ofborg/src/bin/evaluation-filter.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ofborg/src/bin/evaluation-filter.rs b/ofborg/src/bin/evaluation-filter.rs index 525fe55..43a3092 100644 --- a/ofborg/src/bin/evaluation-filter.rs +++ b/ofborg/src/bin/evaluation-filter.rs @@ -30,6 +30,19 @@ fn main() { let mut channel = session.open_channel(1).unwrap(); + channel + .declare_exchange(easyamqp::ExchangeConfig { + exchange: "github-events".to_owned(), + exchange_type: easyamqp::ExchangeType::Topic, + passive: false, + durable: true, + auto_delete: false, + no_wait: false, + internal: false, + arguments: None, + }) + .unwrap(); + channel .declare_queue(easyamqp::QueueConfig { queue: "mass-rebuild-check-jobs".to_owned(), From 9c2771f4094f74bbe57500069a59ea653d3d02bb Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 2 Mar 2018 22:25:33 -0500 Subject: [PATCH 43/47] Declare more rabbitmq primitives --- ofborg/src/bin/github-comment-filter.rs | 47 +++++++++++++++++++++++++ ofborg/src/bin/log-message-collector.rs | 3 +- ofborg/src/bin/mass-rebuilder.rs | 12 +++++++ ofborg/src/tasks/githubcommentfilter.rs | 1 + 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/ofborg/src/bin/github-comment-filter.rs b/ofborg/src/bin/github-comment-filter.rs index f75bc83..69ace11 100644 --- a/ofborg/src/bin/github-comment-filter.rs +++ b/ofborg/src/bin/github-comment-filter.rs @@ -29,6 +29,53 @@ fn main() { println!("Connected to rabbitmq"); let mut channel = session.open_channel(1).unwrap(); + channel + .declare_exchange(easyamqp::ExchangeConfig { + exchange: "github-events".to_owned(), + exchange_type: easyamqp::ExchangeType::Topic, + passive: false, + durable: true, + auto_delete: false, + no_wait: false, + internal: false, + arguments: None, + }) + .unwrap(); + + channel + .declare_exchange(easyamqp::ExchangeConfig { + exchange: "build-jobs".to_owned(), + exchange_type: easyamqp::ExchangeType::Fanout, + passive: false, + durable: true, + auto_delete: false, + no_wait: false, + internal: false, + arguments: None, + }) + .unwrap(); + + channel + .declare_queue(easyamqp::QueueConfig { + queue: "build-inputs".to_owned(), + passive: false, + durable: true, + exclusive: false, + auto_delete: false, + no_wait: false, + arguments: None, + }) + .unwrap(); + + channel + .bind_queue(easyamqp::BindQueueConfig { + queue: "build-inputs".to_owned(), + exchange: "github-events".to_owned(), + routing_key: Some("issue_comment.nixos/nixpkgs".to_owned()), + no_wait: false, + arguments: None, + }) + .unwrap(); channel.basic_prefetch(1).unwrap(); channel diff --git a/ofborg/src/bin/log-message-collector.rs b/ofborg/src/bin/log-message-collector.rs index f40b7e9..48276cd 100644 --- a/ofborg/src/bin/log-message-collector.rs +++ b/ofborg/src/bin/log-message-collector.rs @@ -46,7 +46,8 @@ fn main() { no_wait: false, arguments: None, }) - .unwrap(); + .unwrap() + .queue; channel .bind_queue(easyamqp::BindQueueConfig { diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index d98d870..c50a493 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -45,6 +45,18 @@ fn main() { cfg.tag_paths.clone().unwrap(), ); + channel + .declare_queue(easyamqp::QueueConfig { + queue: "mass-rebuild-check-jobs".to_owned(), + passive: false, + durable: true, + exclusive: false, + auto_delete: false, + no_wait: false, + arguments: None, + }) + .unwrap(); + channel.basic_prefetch(1).unwrap(); channel .consume( diff --git a/ofborg/src/tasks/githubcommentfilter.rs b/ofborg/src/tasks/githubcommentfilter.rs index 2e0aa86..3c8e1f0 100644 --- a/ofborg/src/tasks/githubcommentfilter.rs +++ b/ofborg/src/tasks/githubcommentfilter.rs @@ -59,6 +59,7 @@ impl worker::SimpleWorker for GitHubCommentWorker { ); if build_destinations.len() == 0 { + println!("No build destinations for: {:?}", job); // Don't process comments if they can't build anything return vec![worker::Action::Ack]; } From 7a7d99bfdac001db62dfdc1df9997812067ea3fb Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 5 Mar 2018 07:38:52 -0500 Subject: [PATCH 44/47] Add some little support for other repos for testing --- config.public.json | 4 +++- ofborg/src/acl.rs | 8 +++++--- ofborg/src/bin/github-comment-filter.rs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config.public.json b/config.public.json index 33509c7..eaba7e0 100644 --- a/config.public.json +++ b/config.public.json @@ -7,7 +7,9 @@ }, "runner": { "repos": [ - "nixos/nixpkgs" + "nixos/nixpkgs", + "nixos/ofborg", + "grahamc/nixpkgs" ], "trusted_users": [ "7c6f434c", diff --git a/ofborg/src/acl.rs b/ofborg/src/acl.rs index 90de362..7bcb1f0 100644 --- a/ofborg/src/acl.rs +++ b/ofborg/src/acl.rs @@ -44,10 +44,12 @@ impl ACL { } pub fn can_build_unrestricted(&self, user: &str, repo: &str) -> bool { - if repo.to_lowercase() != "nixos/nixpkgs" { + if repo.to_lowercase() == "nixos/nixpkgs" { + return self.trusted_users.contains(&user.to_lowercase()); + } else if user == "grahamc" { + return true; + } else { return false; } - - return self.trusted_users.contains(&user.to_lowercase()); } } diff --git a/ofborg/src/bin/github-comment-filter.rs b/ofborg/src/bin/github-comment-filter.rs index 69ace11..e8920e7 100644 --- a/ofborg/src/bin/github-comment-filter.rs +++ b/ofborg/src/bin/github-comment-filter.rs @@ -71,7 +71,7 @@ fn main() { .bind_queue(easyamqp::BindQueueConfig { queue: "build-inputs".to_owned(), exchange: "github-events".to_owned(), - routing_key: Some("issue_comment.nixos/nixpkgs".to_owned()), + routing_key: Some("issue_comment.*".to_owned()), no_wait: false, arguments: None, }) From f3b728ce7fee26df4ab18a74e7e2bd91de496bac Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 5 Mar 2018 07:39:07 -0500 Subject: [PATCH 45/47] Fix the log API for new log directories --- log-api/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/log-api/index.php b/log-api/index.php index fa1e5e7..8519c6c 100644 --- a/log-api/index.php +++ b/log-api/index.php @@ -3,7 +3,7 @@ header('Content-Type: application/json'); $d = array('attempts' => []); -$root = "/var/lib/nginx/ofborg/"; +$root = "/var/log/ofborg/"; function abrt($msg) { echo $msg; @@ -19,8 +19,8 @@ if (!isset($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_URI'])) { } $reqd = substr($_SERVER['REQUEST_URI'], strlen("/logs/")); -$req = realpath("$root/logs/$reqd"); -$serve_root = "https://logs.nix.gsc.io/logfile/$reqd"; +$req = realpath("$root/$reqd"); +$serve_root = "https://logs.nix.ci/logfile/$reqd"; if ($req === false) { abrt("absent"); From bb697d5375cf47c10b6394f0b8da5e17e15aac51 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 5 Mar 2018 07:39:19 -0500 Subject: [PATCH 46/47] stats: listen on 0.0.0.0 for prom --- ofborg/src/bin/stats.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofborg/src/bin/stats.rs b/ofborg/src/bin/stats.rs index 5762609..43c536e 100644 --- a/ofborg/src/bin/stats.rs +++ b/ofborg/src/bin/stats.rs @@ -87,7 +87,7 @@ fn main() { thread::spawn(||{ - let addr = "127.0.0.1:9898"; + let addr = "0.0.0.0:9898"; println!("listening addr {:?}", addr); Server::http(addr) .unwrap() From 9fc13b95d2d90da1813e17c5579324bdd65c2703 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 5 Mar 2018 07:39:35 -0500 Subject: [PATCH 47/47] Webhook: create an 'unknown' queue for collecting weird messages --- php/web/index.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/php/web/index.php b/php/web/index.php index ecf8079..e22331a 100644 --- a/php/web/index.php +++ b/php/web/index.php @@ -142,7 +142,26 @@ try { $connection = retry_rabbitmq_conn(); $channel = $connection->channel(); - $dec = $channel->exchange_declare('github-events', 'topic', false, true, false); + $dec = $channel->exchange_declare( + 'github-events', + 'topic', + false, // passive + true, // durable + false // auto_delete + ); + + $channel->queue_declare( + 'github-events-unknown', + false, // passive + true, // durable + false, // exclusive + false // auto-delete + ); + $channel->queue_bind( + 'github-events-unknown', + 'github-events', + 'unknown.*' + ); $message = new AMQPMessage(json_encode($input), array(