obnoxious debug stuff

This commit is contained in:
Graham Christensen 2018-01-24 21:33:14 -05:00
parent 6995551d16
commit 1ef1c2f7e3
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
4 changed files with 96 additions and 1 deletions

2
ofborg/Cargo.lock generated
View file

@ -30,7 +30,7 @@ dependencies = [
[[package]]
name = "amqp"
version = "0.1.0"
source = "git+https://github.com/grahamc/rust-amqp.git#8325f89a947c4917d61adbe37b779413697a2c27"
source = "git+https://github.com/grahamc/rust-amqp.git#6fab84aa9446c00ce0fbfd0605ec8b63394f0350"
dependencies = [
"amq-proto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -19,3 +19,7 @@ hubcaps = { git = "https://github.com/grahamc/hubcaps.git" }
hyper = "0.10.*"
hyper-native-tls = "0.2.4"
lru-cache = "0.1.1"
#[patch.crates-io]
#amq-proto = { path = "rust-amq-proto" }

View file

@ -0,0 +1,88 @@
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::Session;
use ofborg::config;
use ofborg::worker;
use ofborg::notifyworker;
use ofborg::notifyworker::NotificationReceiver;
use ofborg::commentparser;
use ofborg::message::buildjob;
use ofborg::message::{Pr,Repo};
use ofborg::tasks;
fn main() {
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
ofborg::setup_log();
println!("Hello, world!");
let mut session = Session::open_url(&cfg.rabbitmq.as_uri()).unwrap();
println!("Connected to rabbitmq");
{
println!("About to open channel #1");
let hbchan = session.open_channel(1).unwrap();
println!("Opened channel #1");
tasks::heartbeat::start_on_channel(hbchan, cfg.whoami());
}
let mut channel = session.open_channel(2).unwrap();
let repo_msg = Repo {
clone_url: "https://github.com/nixos/ofborg.git".to_owned(),
full_name: "NixOS/ofborg".to_owned(),
owner: "NixOS".to_owned(),
name: "ofborg".to_owned(),
};
let pr_msg = Pr {
number: 42,
head_sha: "5d0a172338d08001787b4e0e59f0e08978764fc1".to_owned(),
target_branch: Some("scratch".to_owned()),
};
let logbackrk = "NixOS/ofborg.42".to_owned();
let msg = buildjob::BuildJob {
repo: repo_msg.clone(),
pr: pr_msg.clone(),
subset: Some(commentparser::Subset::Nixpkgs),
attrs: vec![ "success".to_owned() ],
logs: Some((Some("logs".to_owned()), Some(logbackrk.to_lowercase()))),
statusreport: Some((None, Some("scratch".to_owned()))),
};
{
let mut recv = notifyworker::ChannelNotificationReceiver::new(&mut channel, 0);
for i in 1..10 {
recv.tell(worker::publish_serde_action(
None,
Some("build-inputs-x86_64-darwin".to_owned()),
&msg,
));
}
}
channel.close(200, "Bye").unwrap();
println!("Closed the channel");
session.close(200, "Good Bye");
println!("Closed the session... EOF");
}

View file

@ -282,7 +282,9 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
for line in spawned.lines().iter() {
if self.full_logs {
println!("Sending a log line ");
actions.log_line(&line);
println!("Sent the line ");
}
if snippet_log.len() >= 10 {
@ -291,6 +293,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
snippet_log.push_back(line.to_owned());
}
println!("Done sending log messages =)");
let success = match spawned.wait() {