From e5680ff0cf3d5a331f7105b4d60aac18923c6afc Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 16:07:43 -0400 Subject: [PATCH 01/12] 0.1.7 for the new result changes --- ofborg/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofborg/Cargo.toml b/ofborg/Cargo.toml index 336292a..f69479a 100644 --- a/ofborg/Cargo.toml +++ b/ofborg/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ofborg" -version = "0.1.6" +version = "0.1.7" authors = ["Graham Christensen "] include = ["Cargo.toml", "Cargo.lock", "src", "test-srcs", "build.rs"] build = "build.rs" From a98152fb946b88dd7fc8a2255279ef5a15f1d441 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 16:21:42 -0400 Subject: [PATCH 02/12] Fail the build if the version is updated and carnix isn't --- default.nix | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index e499969..eefd8e7 100644 --- a/default.nix +++ b/default.nix @@ -23,9 +23,6 @@ in { in pkgs.runCommand "ofborg-rs-symlink-compat" { src = stripDeps build; } '' - - set -x - mkdir -p $out/bin for f in $(find $src -type f); do bn=$(basename "$f") @@ -43,6 +40,32 @@ in { test -e $out/bin/github_comment_poster test -e $out/bin/log_message_collector test -e $out/bin/evaluation_filter + + # Verify that the outpath contains the version number matching the + # Cargo.toml + if ! grep -q 'version = "${drv.crateVersion}"' ${./ofborg/Cargo.toml}; then + cat < Date: Tue, 7 Aug 2018 16:23:27 -0400 Subject: [PATCH 03/12] Run carnix! --- nix/ofborg-carnix.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/ofborg-carnix.nix b/nix/ofborg-carnix.nix index 5875ff2..d86dfeb 100644 --- a/nix/ofborg-carnix.nix +++ b/nix/ofborg-carnix.nix @@ -45,7 +45,7 @@ let kernel = buildPlatform.parsed.kernel.name; ) [] (builtins.attrNames feat); in rec { - ofborg = f: ofborg_0_1_6 { features = ofborg_0_1_6_features { ofborg_0_1_6 = f; }; }; + ofborg = f: ofborg_0_1_7 { features = ofborg_0_1_7_features { ofborg_0_1_7 = f; }; }; aho_corasick_0_5_3_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "aho-corasick"; version = "0.5.3"; From 8df71dffdcc07defcf4aaecb3b19de51e7375c3e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 17:03:53 -0400 Subject: [PATCH 04/12] fixup: no longer import buildstatus --- ofborg/src/tasks/log_message_collector.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 47ad006..6de4e41 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -9,7 +9,7 @@ use std::io::Write; use ofborg::writetoline::LineWriter; use ofborg::message::buildlogmsg::{BuildLogStart, BuildLogMsg}; -use ofborg::message::buildresult::{BuildStatus, BuildResult}; +use ofborg::message::buildresult::BuildResult; use ofborg::worker; use amqp::protocol::basic::{Deliver, BasicProperties}; From 9ccce84eb90c8e6bac148a8f929f1c3b676ab0f4 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 17:05:42 -0400 Subject: [PATCH 05/12] Update the carnix updater to do a cargo build prior to the carnix update --- nix/update-carnix.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nix/update-carnix.sh b/nix/update-carnix.sh index d46e546..a711c01 100755 --- a/nix/update-carnix.sh +++ b/nix/update-carnix.sh @@ -1,11 +1,18 @@ #!/bin/sh +set -eu + cd nix patched_carnix() { src=$1 result=$2 + ( + cd "$(dirname "$src")" + cargo build + ) + carnix "$src" --output "$result" patch -p1 "$result" ./carnix.patch } From c5b65f4ead7be9fb656a815e48ccf88b4a3eb82d Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 17:06:15 -0400 Subject: [PATCH 06/12] finishing up the version bump --- nix/ofborg-carnix.nix | 10 +++++----- ofborg/Cargo.lock | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nix/ofborg-carnix.nix b/nix/ofborg-carnix.nix index d86dfeb..74bc4d8 100644 --- a/nix/ofborg-carnix.nix +++ b/nix/ofborg-carnix.nix @@ -427,9 +427,9 @@ rec { sha256 = "1y6qnd9r8ga6y8mvlabdrr73nc8cshjjlzbvnanzyj9b8zzkfwk2"; inherit dependencies buildDependencies features; }; - ofborg_0_1_6_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { + ofborg_0_1_7_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate { crateName = "ofborg"; - version = "0.1.6"; + version = "0.1.7"; authors = [ "Graham Christensen " ]; src = include [ "Cargo.toml" "Cargo.lock" "src" "test-srcs" "build.rs" ] ./../ofborg; build = "build.rs"; @@ -1449,10 +1449,10 @@ rec { libc_0_2_40.default = true; num_cpus_1_8_0.default = (f.num_cpus_1_8_0.default or true); }) [ libc_0_2_40_features ]; - ofborg_0_1_6 = { features?(ofborg_0_1_6_features {}) }: ofborg_0_1_6_ { + ofborg_0_1_7 = { features?(ofborg_0_1_7_features {}) }: ofborg_0_1_7_ { dependencies = mapFeatures features ([ amqp_0_1_0 either_1_5_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_7 nom_4_0_0_beta3 serde_1_0_43 serde_derive_1_0_43 serde_json_1_0_16 sys_info_0_5_6 tempfile_2_2_0 uuid_0_4_0 ]); }; - ofborg_0_1_6_features = f: updateFeatures f (rec { + ofborg_0_1_7_features = f: updateFeatures f (rec { amqp_0_1_0.default = true; either_1_5_0.default = true; env_logger_0_4_3.default = true; @@ -1464,7 +1464,7 @@ rec { lru_cache_0_1_1.default = true; md5_0_3_7.default = true; nom_4_0_0_beta3.default = true; - ofborg_0_1_6.default = (f.ofborg_0_1_6.default or true); + ofborg_0_1_7.default = (f.ofborg_0_1_7.default or true); serde_1_0_43.default = true; serde_derive_1_0_43.default = true; serde_json_1_0_16.default = true; diff --git a/ofborg/Cargo.lock b/ofborg/Cargo.lock index 1d4f51a..e4a4263 100644 --- a/ofborg/Cargo.lock +++ b/ofborg/Cargo.lock @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "ofborg" -version = "0.1.6" +version = "0.1.7" dependencies = [ "amqp 0.1.0 (git+https://github.com/grahamc/rust-amqp.git)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", From 5cf27d9f6cbb0e28fd67603a6f749b8ea841214f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 19:20:29 -0400 Subject: [PATCH 07/12] Fixup cleanup --- ofborg/src/tasks/log_message_collector.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 6de4e41..a0ede83 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -248,6 +248,7 @@ mod tests { use std::path::PathBuf; use ofborg::worker::SimpleWorker; use ofborg::test_scratch::TestScratch; + use ofborg::message::buildresult::BuildResult; use ofborg::message::{Pr,Repo}; fn make_worker(path: PathBuf) -> LogMessageCollector { From 17f13b6e7d17f793d3bea345927040dc86ff5e9c Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 22:21:30 -0400 Subject: [PATCH 08/12] fixup: tests --- ofborg/src/tasks/log_message_collector.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index a0ede83..2c7cd5c 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -248,7 +248,7 @@ mod tests { use std::path::PathBuf; use ofborg::worker::SimpleWorker; use ofborg::test_scratch::TestScratch; - use ofborg::message::buildresult::BuildResult; + use ofborg::message::buildresult::BuildStatus; use ofborg::message::{Pr,Repo}; fn make_worker(path: PathBuf) -> LogMessageCollector { From b882a7a01c957f85bea4d9e3ea279481ccf304bc Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Aug 2018 22:35:09 -0400 Subject: [PATCH 09/12] Unique vars --- ofborg/src/tasks/log_message_collector.rs | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 2c7cd5c..e63a595 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -456,18 +456,18 @@ mod tests { ); } - 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\",\"attempted_attrs\":[\"foo\"],\"skipped_attrs\":[\"bar\"]}"); + let mut prm = p.path(); + let mut sm = String::new(); + prm.push("routing-key-foo/attempt-id-foo.metadata.json"); + File::open(prm).unwrap().read_to_string(&mut sm).unwrap(); + assert_eq!(&sm, "{\"system\":\"foobar-x8664\",\"identity\":\"my-identity\",\"attempt_id\":\"my-attempt-id\",\"attempted_attrs\":[\"foo\"],\"skipped_attrs\":[\"bar\"]}"); - let mut pr = p.path(); - let mut s = String::new(); - pr.push("routing-key-foo/attempt-id-foo"); - File::open(pr).unwrap().read_to_string(&mut s).unwrap(); - assert_eq!(&s, "line-1\n\n\n\nline-5\n"); + let mut prf = p.path(); + let mut sf = String::new(); + prf.push("routing-key-foo/attempt-id-foo"); + File::open(prf).unwrap().read_to_string(&mut sf).unwrap(); + assert_eq!(&sf, "line-1\n\n\n\nline-5\n"); let mut pr = p.path(); @@ -476,10 +476,10 @@ mod tests { File::open(pr).unwrap().read_to_string(&mut s).unwrap(); assert_eq!(&s, "\n\nline-3\n"); - let mut pr = p.path(); - let mut s = String::new(); - pr.push("routing-key-foo/attempt-id-foo.result.json"); - File::open(pr).unwrap().read_to_string(&mut s).unwrap(); - assert_eq!(&s, "{\"repo\":{\"owner\":\"NixOS\",\"name\":\"ofborg\",\"full_name\":\"NixOS/ofborg\",\"clone_url\":\"https://github.com/nixos/ofborg.git\"},\"pr\":{\"target_branch\":\"scratch\",\"number\":42,\"head_sha\":\"6dd9f0265d52b946dd13daf996f30b64e4edb446\"},\"system\":\"x86_64-linux\",\"output\":[],\"attempt_id\":\"attempt-id-foo\",\"request_id\":\"bogus-request-id\",\"success\":true,\"status\":\"Success\",\"skipped_attrs\":[\"bar\"],\"attempted_attrs\":[\"foo\"]}"); + let mut prr = p.path(); + let mut sr = String::new(); + prr.push("routing-key-foo/attempt-id-foo.result.json"); + File::open(prr).unwrap().read_to_string(&mut sr).unwrap(); + assert_eq!(&sr, "{\"repo\":{\"owner\":\"NixOS\",\"name\":\"ofborg\",\"full_name\":\"NixOS/ofborg\",\"clone_url\":\"https://github.com/nixos/ofborg.git\"},\"pr\":{\"target_branch\":\"scratch\",\"number\":42,\"head_sha\":\"6dd9f0265d52b946dd13daf996f30b64e4edb446\"},\"system\":\"x86_64-linux\",\"output\":[],\"attempt_id\":\"attempt-id-foo\",\"request_id\":\"bogus-request-id\",\"success\":true,\"status\":\"Success\",\"skipped_attrs\":[\"bar\"],\"attempted_attrs\":[\"foo\"]}"); } } From a923e71a793e15584c6fca14f2cf66379eb8be4c Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 8 Aug 2018 08:52:15 -0400 Subject: [PATCH 10/12] Add debugging to the test scratch test --- ofborg/src/test_scratch.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ofborg/src/test_scratch.rs b/ofborg/src/test_scratch.rs index cec800b..1904ee0 100644 --- a/ofborg/src/test_scratch.rs +++ b/ofborg/src/test_scratch.rs @@ -8,27 +8,34 @@ pub struct TestScratch { impl TestScratch { pub fn new_dir(ident: &str) -> TestScratch { - let path = TestScratch { + let scratch = TestScratch { root: Path::new(env!("CARGO_MANIFEST_DIR")) .join("test-scratch") .join("dirs") .join(&format!("dir-{}", ident)), }; - fs::create_dir_all(path.root.parent().unwrap()).unwrap(); - return path; + TestScratch::create_dir(&scratch); + + return scratch; } pub fn new_file(ident: &str) -> TestScratch { - let path = TestScratch { + let scratch = TestScratch { root: Path::new(env!("CARGO_MANIFEST_DIR")) .join("test-scratch") .join("files") .join(&format!("file-{}", ident)), }; - fs::create_dir_all(path.root.parent().unwrap()).unwrap(); - return path; + TestScratch::create_dir(&scratch); + return scratch; + } + + fn create_dir(path: &TestScratch) { + let target = path.root.parent().unwrap(); + debug!("Creating directory {:?}", target); + fs::create_dir_all(target).unwrap(); } pub fn path(&self) -> PathBuf { @@ -42,6 +49,7 @@ impl TestScratch { impl Drop for TestScratch { fn drop(&mut self) { + debug!("Deleting root {:?}", self.root); Command::new("rm") .arg("-rf") .arg(self.root.clone()) From 8772eba53e8edcaefa055a99defc2e574f783479 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 8 Aug 2018 08:58:30 -0400 Subject: [PATCH 11/12] Split out the ofborg builds in to separate jobs --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 45d6696..694c088 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: nix matrix: include: - - script: - - nix-shell --run checkPhase - - nix-shell --run checkPhase --arg useNix1 true - - nix-build -A ofborg.rs + - name: checkPhase - Nix 2 + script: nix-shell --run checkPhase --arg useNix1 false + - name: checkPhase - Nix 1 + script: nix-shell --run checkPhase --arg useNix1 true + - name: nix-build + script: nix-build -A ofborg.rs From 5e2747cc13600a6e9262860c6aa2d946f6f95867 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 8 Aug 2018 09:04:18 -0400 Subject: [PATCH 12/12] builtins.storePath the configured nix shell --- ofborg/test-srcs/build-pr/default.nix | 4 ++-- ofborg/test-srcs/build/default.nix | 4 ++-- ofborg/test-srcs/eval-mixed-failure/default.nix | 6 +++--- ofborg/test-srcs/eval/default.nix | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ofborg/test-srcs/build-pr/default.nix b/ofborg/test-srcs/build-pr/default.nix index 6c8596c..35e2ada 100644 --- a/ofborg/test-srcs/build-pr/default.nix +++ b/ofborg/test-srcs/build-pr/default.nix @@ -4,7 +4,7 @@ in { success = derivation { name = "success"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ]; @@ -13,7 +13,7 @@ in { failed = derivation { name = "failed"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime}" ]; diff --git a/ofborg/test-srcs/build/default.nix b/ofborg/test-srcs/build/default.nix index 840aa12..ba7eb25 100644 --- a/ofborg/test-srcs/build/default.nix +++ b/ofborg/test-srcs/build/default.nix @@ -4,7 +4,7 @@ in { success = derivation { name = "success"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ]; @@ -13,7 +13,7 @@ in { failed = derivation { name = "failed"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime}" ]; diff --git a/ofborg/test-srcs/eval-mixed-failure/default.nix b/ofborg/test-srcs/eval-mixed-failure/default.nix index 8d157ac..a4f5290 100644 --- a/ofborg/test-srcs/eval-mixed-failure/default.nix +++ b/ofborg/test-srcs/eval-mixed-failure/default.nix @@ -4,7 +4,7 @@ in rec { success = derivation { name = "success"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ]; @@ -13,7 +13,7 @@ in rec { failed = derivation { name = "failed"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ]; @@ -22,7 +22,7 @@ in rec { passes-instantiation = derivation { name = "passes-instantiation"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo this ones cool" ]; diff --git a/ofborg/test-srcs/eval/default.nix b/ofborg/test-srcs/eval/default.nix index 35981f7..34a7247 100644 --- a/ofborg/test-srcs/eval/default.nix +++ b/ofborg/test-srcs/eval/default.nix @@ -4,7 +4,7 @@ in rec { success = derivation { name = "success"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ]; @@ -13,7 +13,7 @@ in rec { failed = derivation { name = "failed"; system = builtins.currentSystem; - builder = nix.shell; + builder = builtins.storePath nix.shell; args = [ "-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];