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 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 <" ]; 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/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 } 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)", 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" diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 47ad006..e63a595 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}; @@ -248,6 +248,7 @@ mod tests { use std::path::PathBuf; use ofborg::worker::SimpleWorker; use ofborg::test_scratch::TestScratch; + use ofborg::message::buildresult::BuildStatus; use ofborg::message::{Pr,Repo}; fn make_worker(path: PathBuf) -> LogMessageCollector { @@ -455,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(); @@ -475,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\"]}"); } } 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()) 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}" ];