add "cargo xtask local" to run buildomat locally#91
Conversation
0ca9b1b to
8186d35
Compare
|
Rebased to fix merge conflicts. |
| pub subnet: ConfigFileAwsSubnets, | ||
| pub tag: String, | ||
| pub key: String, | ||
| #[serde(default)] |
There was a problem hiding this comment.
Do you need the serde(default) attribute for Option members? Presumably it's just None if not present?
There was a problem hiding this comment.
Good call, I don't know how I left it there 😅
| pub key: Option<String>, | ||
| pub security_group: String, | ||
| pub limit_total: usize, | ||
| #[serde(default = "default_false")] |
There was a problem hiding this comment.
I think false is already the Default::default() value for bool isn't it?
There was a problem hiding this comment.
So, while that is correct, I personally prefer to add an explicit default value rather than deferring to Default::default. That way it's obvious what the default value is by glancing at the source code.
If you prefer to replace it with #[serde(default)] I can do the switch.
| eprintln!(); | ||
| eprintln!("buildomat-github-server setup"); | ||
| eprintln!("============================="); |
There was a problem hiding this comment.
I think all the regular text in here ought to just use println!() so that it comes out on stdout?
| root.join("etc").join("app.toml"), | ||
| toml::to_string_pretty(&Config { | ||
| id: app.id, | ||
| secret: String::new(), /* XXX this seems unused? */ |
There was a problem hiding this comment.
I think this probably is unused at this point. I think it used to hold an oauth client secret, but that doesn't end up getting used by the GitHub client we're using at this point.
Maybe just remove secret altogether?
| let db = SQLite::open(root.join("var/data.sqlite3")) | ||
| .context("failed to create the database")?; | ||
| db.query_row("PRAGMA journal_mode=WAL;", (), |_| Ok(()))?; |
There was a problem hiding this comment.
From what I recall, I think it's sufficient to just create an empty file here (as with, e.g., touch)? Then we can leave the specifics (like WAL mode) to the database wrapper.
There was a problem hiding this comment.
I do remember somewhere that it wasn't enough (maybe on facade?), but I checked and it indeed works. I'll switch it to just touching the file.
| let db = SQLite::open(root.join("data/data.sqlite3")) | ||
| .context("failed to create the database")?; | ||
| db.query_row("PRAGMA journal_mode=WAL;", (), |_| Ok(()))?; |
There was a problem hiding this comment.
I think this could also just be analogous to touch to create an empty file (if missing)?
| eprintln!(); | ||
| eprintln!("buildomat-server setup"); | ||
| eprintln!("======================"); |
There was a problem hiding this comment.
Probably println!() throughout this file too?
| The first thing to do is setting it up. You will need [a configured AWS | ||
| profile] pointing to the AWS account that will host storage and compute, and |
There was a problem hiding this comment.
What does square brackets mean in markdown like this?
| * We are intentionally building the x86_64-unknown-linux-musl variant of | ||
| * the agent. Linux is what the AWS factory configures to run, and the musl | ||
| * variant prevents issues with older glibcs or building on NixOS. | ||
| */ | ||
| eprintln!("building the agent..."); | ||
| let status = cargo() | ||
| .args(["build", "--bin", "buildomat-agent"]) | ||
| .arg("--release") | ||
| .arg("--target=x86_64-unknown-linux-musl") | ||
| .status()?; | ||
| if !status.success() { | ||
| std::process::exit(status.code().unwrap_or(1)); | ||
| } | ||
| std::fs::copy( | ||
| local | ||
| .join("../..") | ||
| .join("target/x86_64-unknown-linux-musl/release/buildomat-agent"), | ||
| local.join("buildomat-agent-linux"), | ||
| )?; |
There was a problem hiding this comment.
I think it would be better if we built the illumos buildomat-agent binary here rather than the Linux one, as that's generally the primary focus here.
There was a problem hiding this comment.
I can change it to also build the illumos one if the current host is illumos, but last time I tried creating a cross-compilation environment from NixOS to illumos I didn't have much success. A Linux MUSL build AFAIK can be done from either Linux or illumos.
This PR adds the
cargo xtask localfamily of commands to run a local instance of buildomat with minimal configuration.The centerpiece if the
cargo xtask local setupcommand, backed by thextask-setupcrate (it's split fromxtaskas it requires a lot of dependencies). It currently supports configuringbuildomat-server,buildomat-github-server, andbuildomat-factory-aws, and at startup asks which components the user wants to be configured.There are then the
cargo xtask local BINARYcommands, which invokes the binary with the flags required to use the local setup.cargo xtask local buildomatalso gives access to the CLI, pointed to the local server.Other changes included in the PR:
BUILDOMAT_CONFIGenvironment variable to thebuildomatCLI to point to a separate configuration file, so thatcargo xtask local buildomatcan transparently use the correct credentials.