Skip to content
Open
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/target

#
# Files needed when running buildomat locally with xtask.
#
/.local

#
# Files needed when running buildomat locally without xtask.
#
/config.toml
/data.sqlite3
/cache
Expand Down
59 changes: 59 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ members = [
"sse",
"types",
"xtask",
"xtask-setup",
]
resolver = "2"

Expand All @@ -37,6 +38,7 @@ ansi-to-html = { version = "0.2", features = [ "lazy-init" ] }
anyhow = "1"
aws-config = "1"
aws-credential-types = "1"
aws-runtime = "1"
aws-sdk-ec2 = "1"
aws-sdk-s3 = "1"
aws-types = "1"
Expand All @@ -45,6 +47,7 @@ bytes = "1.1"
chrono = { version = "0.4", features = [ "serde" ] }
debug_parser = "0.1"
devinfo = { version = "0.1", features = [ "private" ] }
dialoguer = { version = "0.12.0", default-features = false }
dirs-next = "2"
dropshot = "0.16"
futures = "0.3"
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,36 @@ Configuration properties supported for basic jobs include:
environment running in an ephemeral virtual machine, with a reasonable set
of build tools. 32GB of RAM and 200GB of disk should be available.

## Running Buildomat locally

The `cargo xtask local` set of commands helps you run a local buildomat.

The first thing to do is setting it up. You will need [a configured AWS
profile][aws-profile] pointing to the AWS account that will host storage and
compute, and public DNS records pointing to ports 9979 (for `buildomat-server`)
and 4021 (for `buildomat-github-server`). Once you have those, you can run the
setup:

```
$ cargo xtask local setup
```

The setup will ask which components to configure, ask you a few questions, and
create all the resources and configuration files you'll need. Afterwards, you
can start the individual components:

* `cargo xtask local buildomat-server`
* `cargo xtask local buildomat-factory-aws`
* `cargo xtask local buildomat-github-server`

You can also interact with the local server using the CLI:

```
$ cargo xtask local buildomat COMMAND
```

[aws-profile]: https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-authentication.html

## Licence

Unless otherwise noted, all components are licenced under the [Mozilla Public
Expand Down
12 changes: 8 additions & 4 deletions bin/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ pub fn load(profile_name: Option<&str>) -> Result<Profile> {
/*
* Next, locate our configuration file.
*/
let mut path = dirs_next::config_dir()
.ok_or_else(|| anyhow!("could not find config directory"))?;
path.push("buildomat");
path.push("config.toml");
let path = if let Some(path) = std::env::var_os("BUILDOMAT_CONFIG") {
path.into()
} else {
dirs_next::config_dir()
.ok_or_else(|| anyhow!("could not find config directory"))?
.join("buildomat")
.join("config.toml")
};

let c: Config =
read_file(&path).with_context(|| anyhow!("reading file {:?}", path))?;
Expand Down
4 changes: 2 additions & 2 deletions factory/aws/src/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async fn create_instance(
.run_instances()
.image_id(&target.ami)
.instance_type(InstanceType::from_str(&target.instance_type)?)
.key_name(&config.aws.key)
.set_key_name(config.aws.key.clone())
.min_count(1)
.max_count(1)
.tag_specifications(
Expand Down Expand Up @@ -192,7 +192,7 @@ async fn create_instance(
InstanceNetworkInterfaceSpecification::builder()
.subnet_id(subnet)
.device_index(0)
.associate_public_ip_address(false)
.associate_public_ip_address(config.aws.public_ip)
.groups(&config.aws.security_group)
.build(),
)
Expand Down
7 changes: 6 additions & 1 deletion factory/aws/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ pub(crate) struct ConfigFileAws {
pub vpc: String,
pub subnet: ConfigFileAwsSubnets,
pub tag: String,
pub key: String,
pub key: Option<String>,
pub security_group: String,
pub limit_total: usize,
#[serde(default = "default_false")]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think false is already the Default::default() value for bool isn't it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

pub public_ip: bool,
}

impl ConfigFileAws {
Expand Down Expand Up @@ -82,3 +84,6 @@ impl ConfigFileAwsSubnets {
}
}
}
fn default_false() -> bool {
false
}
2 changes: 0 additions & 2 deletions github/ghtool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use serde::Deserialize;
#[derive(Deserialize)]
pub struct Config {
pub id: u64,
#[allow(unused)]
pub secret: String,
}

pub fn load_bytes<P: AsRef<Path>>(p: P) -> Result<Vec<u8>> {
Expand Down
2 changes: 0 additions & 2 deletions github/server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ pub struct Buildomat {
#[derive(Deserialize)]
pub struct Config {
pub id: u64,
#[allow(unused)]
pub secret: String,
pub webhook_secret: String,
pub base_url: String,
pub confroot: String,
Expand Down
27 changes: 27 additions & 0 deletions xtask-setup/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "xtask-setup"
edition.workspace = true
license.workspace = true
version.workspace = true

[dependencies]
buildomat-common = { path = "../common" }
buildomat-client = { path = "../client" }

anyhow = { workspace = true }
aws-config = { workspace = true }
aws-runtime = { workspace = true }
aws-sdk-ec2 = { workspace = true }
aws-sdk-s3 = { workspace = true }
aws-types = { workspace = true }
dialoguer = { workspace = true }
dropshot = { workspace = true }
http = { workspace = true }
rand = { workspace = true }
reqwest = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
slog = { workspace = true }
tokio = { workspace = true }
toml = { workspace = true }
Loading