Skip to content
Merged
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
12 changes: 12 additions & 0 deletions pkgs/fleet/Cargo.lock

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

2 changes: 2 additions & 0 deletions pkgs/fleet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
"crates/fleet-proxy-proto",
"crates/fleet-queue",
"crates/fleet-dispatch",
"crates/fleet-dispatch-test",
"crates/fleet-proxy",
"crates/fleet-search",
"crates/fleet",
Expand All @@ -38,6 +39,7 @@ fleet-secrets = { path = "crates/fleet-secrets" }
fleet-proxy-proto = { path = "crates/fleet-proxy-proto" }
fleet-queue = { path = "crates/fleet-queue" }
fleet-dispatch = { path = "crates/fleet-dispatch" }
fleet-dispatch-test = { path = "crates/fleet-dispatch-test" }
fleet-proxy = { path = "crates/fleet-proxy" }
fleet-search = { path = "crates/fleet-search" }
serde = { version = "1", features = ["derive"] }
Expand Down
98 changes: 98 additions & 0 deletions pkgs/fleet/crates/fleet-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ pub const PORT_DISPATCH: u16 = 4879;
/// only.
pub const DEFAULT_DISPATCH_TOKEN_NAME: &str = "pm-dispatch.api-token";

/// The fleet-secrets name the dispatch-test domain resolves its
/// GitHub token by (design developing-today/code#6580).
pub const DEFAULT_DISPATCH_TEST_TOKEN_NAME: &str = "github.ghcr-classic-pat";

/// The fleet-secrets name the dispatch-test domain resolves its
/// Turso jobs-store token by.
pub const DEFAULT_DISPATCH_TEST_TURSO_TOKEN_NAME: &str = "turso.fleet-dispatch-jobs-token";

/// The Turso jobs store the dispatch-test domain records jobs in.
pub const DEFAULT_DISPATCH_TEST_TURSO_URL: &str =
"https://fleet-dispatch-jobs-dezren39.aws-us-east-1.turso.io";

/// The default Actions-capacity threshold for dispatch-test scope
/// selection: a scope is eligible below this many active jobs.
pub const DEFAULT_DISPATCH_TEST_THRESHOLD: u64 = 40;

/// The default dispatch-test scope repos, in selection order.
pub const DEFAULT_DISPATCH_TEST_SCOPES: &[&str] = &[
"developing-today/code",
"developing-today-forks/opencode",
"developing-today-forks/openchamber",
"dezren39/darwin-nix",
"dezren39/hatch",
];

#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct Config {
Expand All @@ -110,6 +135,8 @@ pub struct Config {
pub proxy: ProxyConfig,
pub secrets: SecretsConfig,
pub dispatch: DispatchConfig,
#[serde(rename = "dispatch-test")]
pub dispatch_test: DispatchTestConfig,
pub search: SearchConfig,
}

Expand Down Expand Up @@ -191,6 +218,31 @@ pub struct DispatchConfig {
pub port: Option<u16>,
}

/// `[dispatch-test]` — the dispatch-test domain's view
/// (developing-today/code#6580). All optional: the defaults name
/// the live GitHub token, the Turso jobs store, and the scope
/// repos used for capacity-based selection.
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct DispatchTestConfig {
/// The fleet-secrets name the GitHub token resolves by
/// (default [`DEFAULT_DISPATCH_TEST_TOKEN_NAME`]).
pub token_name: Option<String>,
/// The fleet-secrets name the Turso token resolves by
/// (default [`DEFAULT_DISPATCH_TEST_TURSO_TOKEN_NAME`]).
pub turso_token_name: Option<String>,
/// The Turso database URL (default
/// [`DEFAULT_DISPATCH_TEST_TURSO_URL`]).
pub turso_url: Option<String>,
/// Actions-capacity threshold (default
/// [`DEFAULT_DISPATCH_TEST_THRESHOLD`]).
pub threshold: Option<u64>,
/// Scope repos, in selection order. Empty means the built-in
/// list ([`DEFAULT_DISPATCH_TEST_SCOPES`]).
#[serde(default)]
pub scopes: Vec<String>,
}

#[derive(Debug)]
pub enum ConfigError {
/// The config file exists but does not parse. Carries the path and
Expand Down Expand Up @@ -511,6 +563,52 @@ impl Config {
self.dispatch.port.unwrap_or(PORT_DISPATCH)
}

/// The fleet-secrets name the dispatch-test GitHub token
/// resolves by.
pub fn dispatch_test_token_name(&self) -> &str {
self.dispatch_test
.token_name
.as_deref()
.unwrap_or(DEFAULT_DISPATCH_TEST_TOKEN_NAME)
}

/// The fleet-secrets name the dispatch-test Turso token
/// resolves by.
pub fn dispatch_test_turso_token_name(&self) -> &str {
self.dispatch_test
.turso_token_name
.as_deref()
.unwrap_or(DEFAULT_DISPATCH_TEST_TURSO_TOKEN_NAME)
}

/// The dispatch-test Turso jobs-store URL.
pub fn dispatch_test_turso_url(&self) -> &str {
self.dispatch_test
.turso_url
.as_deref()
.unwrap_or(DEFAULT_DISPATCH_TEST_TURSO_URL)
}

/// The dispatch-test Actions-capacity threshold.
pub fn dispatch_test_threshold(&self) -> u64 {
self.dispatch_test
.threshold
.unwrap_or(DEFAULT_DISPATCH_TEST_THRESHOLD)
}

/// The dispatch-test scope repos, in selection order: the
/// configured list, or the built-in defaults when unset/empty.
pub fn dispatch_test_scopes(&self) -> Vec<String> {
if self.dispatch_test.scopes.is_empty() {
DEFAULT_DISPATCH_TEST_SCOPES
.iter()
.map(|s| s.to_string())
.collect()
} else {
self.dispatch_test.scopes.clone()
}
}

/// The search domain's routing preference from `[search] via`
/// ("service" | "standalone"), when configured.
pub fn search_via(&self) -> Option<String> {
Expand Down
17 changes: 17 additions & 0 deletions pkgs/fleet/crates/fleet-dispatch-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "fleet-dispatch-test"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
description = "The fleet dispatch-test domain: explicit-dispatch CI test — scan fleet repos for free GitHub Actions capacity, submit a job to the Turso-backed jobs store, dispatch the pilot workflow, and track the job's stored status."

[dependencies]
fleet-config = { workspace = true }
fleet-secrets = { workspace = true }
serde = { workspace = true }
# preserve_order, as in fleet-dispatch: stored-row JSON key order is
# the schema's column order, part of the output shape agents consume.
serde_json = { version = "1", features = ["preserve_order"] }
# Same pin as fleet-search / fleet-queue.
ureq = { version = "3", features = ["rustls", "json"] }
Loading
Loading