Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Introduce an one-off-build command to reproduce ofBorg locally #562

Draft
wants to merge 2 commits into
base: released
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions ofborg/src/bin/one-off-builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/// Build attributes within a Nixpkgs PR the way that ofBorg does
use ofborg::nix::Nix;
use ofborg::notifyworker::SimpleNotifyWorker;
use ofborg::tasks::build::BuildWorker;

fn main() -> Result<(), Box<dyn std::error::Error>> {
ofborg::setup_log();
let current_system = "x86_64-linux";

let attrs = vec!["pulseview".to_owned()];

let nix = Nix::new(
current_system.to_owned(),
"daemon".to_owned(),
90 * 60,
None,
);
let p: std::path::PathBuf = "/tmp/ofborg".into();
let cloner = ofborg::checkout::cached_cloner(&p);
let worker = BuildWorker::new(
cloner,
nix,
current_system.to_owned(),
"one-off".to_string(),
);
let repo = ofborg::message::Repo {
owner: "nixos".to_owned(),
name: "nixpkgs".to_owned(),
full_name: "NixOS/nixpkgs".to_owned(),
clone_url: "https://github.com/nixos/nixpkgs.git".to_owned(),
};

let mut dummy_receiver = ofborg::notifyworker::DummyNotificationReceiver::new();

let pr = ofborg::message::Pr {
target_branch: Some("nixos-unstable".to_owned()),
number: 123170,
head_sha: "ec28b5d7a54fd1f8c2eba5e4ba238769d281755e".to_owned(),
};

let job = ofborg::message::buildjob::BuildJob::new(
repo,
pr,
ofborg::commentparser::Subset::Nixpkgs,
/* attrs */ attrs,
/* logs */ None,
/* statusreport: */ None,
/*request_id: */ "one-off".to_string(),
);

worker.consumer(&job, &mut dummy_receiver);

for message in dummy_receiver.actions {
use ofborg::worker::Action;
match message {
Action::Ack | Action::NackRequeue | Action::NackDump => println!("{:?}", message),
Action::Publish(msg) => match msg.content_type {
Some(x) if x == "application/json" => {
let data: serde_json::Value = serde_json::from_slice(&msg.content).unwrap();
println!("Action::Publish: {:?}", data);
}
_ => {
println!("Action::Publish: {:?}", msg);
}
},
}
}

Ok(())
}
2 changes: 1 addition & 1 deletion ofborg/src/tasks/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {

let target_branch = match job.pr.target_branch.clone() {
Some(x) => x,
None => String::from("origin/master"),
None => String::from("master"),
};

let buildfile = match job.subset {
Expand Down