Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Seanaye/feat/lazy xtask (#4551)

Sean Ayedb4d9613a821
diff --git a/.github/workflows/assign-author.yml b/.github/workflows/assign-author.yml
index 3889abbf52..93b318578f 100644
--- a/.github/workflows/assign-author.yml
+++ b/.github/workflows/assign-author.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/assign_author.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/assign_author.rs
name: Pull Request
'on':
pull_request:
diff --git a/.github/workflows/assign-labels.yml b/.github/workflows/assign-labels.yml
index 8832b712b2..b449b9a380 100644
--- a/.github/workflows/assign-labels.yml
+++ b/.github/workflows/assign-labels.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/assign_labels.rs
name: Auto Label PRs
'on':
pull_request:
diff --git a/.github/workflows/build_appimage_on_tag.yml b/.github/workflows/build_appimage_on_tag.yml
index a2d2ca78ef..514f4ff1e8 100644
--- a/.github/workflows/build_appimage_on_tag.yml
+++ b/.github/workflows/build_appimage_on_tag.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_appimage_on_tag.rs
name: Build AppImage
'on':
workflow_call:
diff --git a/.github/workflows/build_desktop_on_tag.yml b/.github/workflows/build_desktop_on_tag.yml
index 2086dcaa67..e40e676c04 100644
--- a/.github/workflows/build_desktop_on_tag.yml
+++ b/.github/workflows/build_desktop_on_tag.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag.rs
name: Build Desktop on Tag
'on':
push:
diff --git a/.github/workflows/build_dmg_on_tag.yml b/.github/workflows/build_dmg_on_tag.yml
index 988e5b4c75..bc39b181de 100644
--- a/.github/workflows/build_dmg_on_tag.yml
+++ b/.github/workflows/build_dmg_on_tag.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs
name: Build macOS DMG
'on':
workflow_call:
diff --git a/.github/workflows/cancel_stuck_cloud_storage_deploys.yml b/.github/workflows/cancel_stuck_cloud_storage_deploys.yml
index c3bbb52b6b..a21e2bc9ba 100644
--- a/.github/workflows/cancel_stuck_cloud_storage_deploys.yml
+++ b/.github/workflows/cancel_stuck_cloud_storage_deploys.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/cancel_stuck_cloud_storage_deploys.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs
name: Cancel Stuck Cloud Storage Deploys
on:
schedule:
diff --git a/.github/workflows/cargo_deny.yml b/.github/workflows/cargo_deny.yml
index a9e4edc4bc..20a91eaa19 100644
--- a/.github/workflows/cargo_deny.yml
+++ b/.github/workflows/cargo_deny.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
name: cargo deny check
'on':
pull_request:
diff --git a/.github/workflows/cargo_workspace_dependency_check.yml b/.github/workflows/cargo_workspace_dependency_check.yml
index 339d274950..299621f2e4 100644
--- a/.github/workflows/cargo_workspace_dependency_check.yml
+++ b/.github/workflows/cargo_workspace_dependency_check.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
name: cargo workspace dependency check
'on':
pull_request:
diff --git a/.github/workflows/check_generated.yml b/.github/workflows/check_generated.yml
index 8752a2a538..33564d175d 100644
--- a/.github/workflows/check_generated.yml
+++ b/.github/workflows/check_generated.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/check_generated.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
name: check generated workflows
'on':
pull_request:
diff --git a/.github/workflows/check_node_modules_nix.yml b/.github/workflows/check_node_modules_nix.yml
index f785dfd024..91c2bdf6de 100644
--- a/.github/workflows/check_node_modules_nix.yml
+++ b/.github/workflows/check_node_modules_nix.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
name: check node_modules nix
'on':
pull_request:
diff --git a/.github/workflows/cleanup_preview.yml b/.github/workflows/cleanup_preview.yml
index dadb322bf0..69ca2628bb 100644
--- a/.github/workflows/cleanup_preview.yml
+++ b/.github/workflows/cleanup_preview.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rs
name: Cleanup Preview
env:
PREVIEW_BUCKET: macro-preview-assets-dev
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.yml
index 3b9bbeeb26..7714355b1f 100644
--- a/.github/workflows/code_check_cloud_storage.yml
+++ b/.github/workflows/code_check_cloud_storage.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
name: cloud storage code check
env:
CARGO_INCREMENTAL: '0'
diff --git a/.github/workflows/code_check_infra.yml b/.github/workflows/code_check_infra.yml
index 83ca5794e1..c560952455 100644
--- a/.github/workflows/code_check_infra.yml
+++ b/.github/workflows/code_check_infra.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/code_check_infra.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
name: infra code check
'on':
pull_request:
diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml
index fd92d80f4e..93878fa18b 100644
--- a/.github/workflows/deploy_preview.yml
+++ b/.github/workflows/deploy_preview.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs
name: Deploy Preview
env:
PREVIEW_BUCKET: macro-preview-assets-dev
diff --git a/.github/workflows/deploy_web_app.yml b/.github/workflows/deploy_web_app.yml
index 81a799ff2b..78b5631875 100644
--- a/.github/workflows/deploy_web_app.yml
+++ b/.github/workflows/deploy_web_app.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/deploy_web_app.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs
name: Deploy Web App
on:
workflow_call:
diff --git a/.github/workflows/deploy_web_app_dev_push.yml b/.github/workflows/deploy_web_app_dev_push.yml
index 9100ef1491..75c9f36c92 100644
--- a/.github/workflows/deploy_web_app_dev_push.yml
+++ b/.github/workflows/deploy_web_app_dev_push.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/deploy_web_app_dev_push.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs
name: Deploy web app dev on push to main
on:
push:
diff --git a/.github/workflows/pulumi_preview_pr.yml b/.github/workflows/pulumi_preview_pr.yml
index f85c344eae..7065896a1c 100644
--- a/.github/workflows/pulumi_preview_pr.yml
+++ b/.github/workflows/pulumi_preview_pr.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/pulumi_preview_pr.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/pulumi_preview_pr.rs
name: Pulumi Preview on PR
on:
pull_request:
diff --git a/.github/workflows/reusable_preview_service.yml b/.github/workflows/reusable_preview_service.yml
index f58d7a47e7..c69376ca3c 100644
--- a/.github/workflows/reusable_preview_service.yml
+++ b/.github/workflows/reusable_preview_service.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/reusable_preview_service.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/reusable_preview_service.rs
name: Reusable Preview Service
on:
workflow_call:
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index fdb6663bef..f939cfc0e2 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -1,5 +1,5 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).
-# Source: rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs
+# Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
name: Web App Pr Checks
'on':
pull_request:
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.json
index 08c8ca860c..7440e15c91 100644
--- a/.github/workspace-dep-closures.json
+++ b/.github/workspace-dep-closures.json
@@ -4741,13 +4741,57 @@
"workspace-hack"
],
"xtask": [
+ "tools/xtask"
+ ],
+ "xtask_cache_wasm": [
+ "tools/xtask/crates/xtask_cache_wasm",
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_deps": [
+ "tools/xtask/crates/xtask_deps",
+ "tools/xtask/crates/xtask_graph",
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_doppler_bins": [
+ "tools/xtask/crates/xtask_doppler_bins",
+ "tools/xtask/crates/xtask_graph",
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_graph": [
+ "tools/xtask/crates/xtask_graph",
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_graphql_soup_schema": [
+ "tools/xtask/crates/xtask_graphql_soup_schema",
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_kafka_topics": [
+ "macro_event_topics",
+ "tools/xtask/crates/xtask_kafka_topics",
+ "tools/xtask/crates/xtask_paths",
+ "workspace-hack"
+ ],
+ "xtask_local": [
"macro_aws_config",
"macro_env",
"macro_env_var",
"macro_event_topics",
"macro_queues",
- "tools/xtask",
+ "tools/xtask/crates/xtask_local",
+ "tools/xtask/crates/xtask_paths",
"workspace-hack"
+ ],
+ "xtask_nextest_filter": [
+ "tools/xtask/crates/xtask_graph",
+ "tools/xtask/crates/xtask_nextest_filter",
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_paths": [
+ "tools/xtask/crates/xtask_paths"
+ ],
+ "xtask_workflows": [
+ "tools/xtask/crates/xtask_paths",
+ "tools/xtask/crates/xtask_workflows"
]
}
}
diff --git a/js/app/justfile b/js/app/justfile
index a944515264..99231c8121 100644
--- a/js/app/justfile
+++ b/js/app/justfile
@@ -162,6 +162,6 @@ build-cache-wasm:
# Dev fast path: build the wasm pkg only when missing or its version drifts
# from client/cache-wasm/Cargo.toml (bump that version to push a rebuild to
-# dev machines). See rust/cloud-storage/tools/xtask/src/cache_wasm.rs.
+# dev machines). See rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/src/main.rs.
ensure-cache-wasm:
cd {{justfile_directory()}}/../../rust/cloud-storage && SQLX_OFFLINE=true cargo run -q -p xtask -- cache-wasm
diff --git a/just/xtask.just b/just/xtask.just
index 312def0e10..5836655e46 100644
--- a/just/xtask.just
+++ b/just/xtask.just
@@ -1,7 +1,9 @@
-# xtask owns all local/dev orchestration; these recipes are thin delegates.
-# `local-stack` (off by default so bare CI builds of xtask skip librdkafka)
-# enables the Kafka topic provisioning that run-local needs.
-xtask := "cargo run --quiet --manifest-path rust/cloud-storage/Cargo.toml -p xtask --features local-stack --"
+# The xtask_local crate owns all local/dev orchestration; these recipes are
+# thin delegates. They target xtask_local directly (rather than the `cargo x`
+# launcher) so the `local-stack` feature — off by default so bare CI builds
+# skip librdkafka — can be enabled to turn on the Kafka topic provisioning that
+# run-local needs.
+xtask := "cargo run --quiet --manifest-path rust/cloud-storage/Cargo.toml -p xtask_local --features local-stack --"
# Start a fully local stack (xtask: zigbuild + runtime image + infra + proxy + frontend).
# just run_local # default instance
diff --git a/rust/cloud-storage/.cargo/config.toml b/rust/cloud-storage/.cargo/config.toml
index 6aefdbcfd3..2b80efdc32 100644
--- a/rust/cloud-storage/.cargo/config.toml
+++ b/rust/cloud-storage/.cargo/config.toml
@@ -1,11 +1,18 @@
# Cargo aliases for the cloud-storage workspace.
#
-# `cargo x <subcommand>` runs the xtask repo-automation tool from anywhere inside
-# rust/cloud-storage:
+# `cargo x <subcommand>` runs xtask from anywhere inside rust/cloud-storage:
# cargo x workflows [--check] # regenerate / verify .github/workflows
# cargo x deps [--check] # regenerate / verify workspace-hack + dep closures
# cargo x nextest-filter <file> # nextest rdeps filter for changed files
# cargo x doppler-bins <file> # Doppler config-validation bins affected by changed files
# cargo x graphql-soup-schema <file> # export GraphQL Soup SDL to a file
+# cargo x cache-wasm [--force] # build the browser cache wasm package
+# cargo x kafka-topics [--check] # regenerate / verify kafka-cluster-topics.json
+# (anything else) # local/dev orchestration (xtask_local)
+#
+# `xtask` is a dependency-free launcher: it maps the subcommand to its own
+# command crate under tools/xtask/crates/ and re-invokes `cargo run -p
+# xtask_<command>`, so each command compiles only its own dependency set
+# (e.g. `cargo x cache-wasm` never builds guppy/hakari/aws-sdk/tokio).
[alias]
x = "run -p xtask --"
diff --git a/rust/cloud-storage/.config/hakari.toml b/rust/cloud-storage/.config/hakari.toml
index bd1bd72c41..1d5a97442b 100644
--- a/rust/cloud-storage/.config/hakari.toml
+++ b/rust/cloud-storage/.config/hakari.toml
@@ -42,6 +42,18 @@ platforms = [
# features.
workspace-members = [
"xtask",
+ # xtask command crates: dev-only automation split out of xtask so each
+ # `cargo x <cmd>` compiles only its own dependency set.
+ "xtask_paths",
+ "xtask_graph",
+ "xtask_deps",
+ "xtask_nextest_filter",
+ "xtask_doppler_bins",
+ "xtask_graphql_soup_schema",
+ "xtask_cache_wasm",
+ "xtask_kafka_topics",
+ "xtask_workflows",
+ "xtask_local",
"macro_sync_service_jwt",
# client/*: browser/Tauri cache crates (cache-core compiles to wasm32 via
# cache-wasm; cache-sqlite ships in the Tauri app, not services). They
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 1600b2643c..b3d7bd7eb1 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -15510,6 +15510,66 @@ checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"
[[package]]
name = "xtask"
version = "0.1.0"
+
+[[package]]
+name = "xtask_cache_wasm"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "serde_json",
+ "xtask_paths",
+]
+
+[[package]]
+name = "xtask_deps"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "guppy",
+ "hakari",
+ "serde_json",
+ "xtask_graph",
+]
+
+[[package]]
+name = "xtask_doppler_bins"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "guppy",
+ "xtask_graph",
+]
+
+[[package]]
+name = "xtask_graph"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "guppy",
+ "xtask_paths",
+]
+
+[[package]]
+name = "xtask_graphql_soup_schema"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "xtask_paths",
+]
+
+[[package]]
+name = "xtask_kafka_topics"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "macro_event_topics",
+ "serde_json",
+ "xtask_paths",
+]
+
+[[package]]
+name = "xtask_local"
+version = "0.1.0"
dependencies = [
"anyhow",
"aws-sdk-dynamodb",
@@ -15520,12 +15580,8 @@ dependencies = [
"console 0.15.11",
"docker-compose-types",
"dotenvy",
- "gh-workflow",
- "guppy",
- "hakari",
"indexmap 2.14.0",
"indicatif",
- "indoc",
"libc",
"macro_aws_config",
"macro_env_var",
@@ -15537,6 +15593,32 @@ dependencies = [
"serde_yaml",
"strum",
"tokio",
+ "xtask_paths",
+]
+
+[[package]]
+name = "xtask_nextest_filter"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "guppy",
+ "xtask_graph",
+]
+
+[[package]]
+name = "xtask_paths"
+version = "0.1.0"
+
+[[package]]
+name = "xtask_workflows"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "gh-workflow",
+ "indoc",
+ "serde_json",
+ "serde_yaml",
+ "xtask_paths",
]
[[package]]
diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.toml
index daf941b52e..ae843d964b 100644
--- a/rust/cloud-storage/Cargo.toml
+++ b/rust/cloud-storage/Cargo.toml
@@ -64,6 +64,7 @@ members = [
"task_dedup",
"tools/native_app_server",
"tools/xtask",
+ "tools/xtask/crates/*",
"unfurl",
"unfurl_service",
"upload_extractor_lambda_handler",
@@ -116,6 +117,11 @@ dotenvy = "0.15.7"
ego-tree = "0.6.2"
either = "1"
futures = "0.3.31"
+# Pinned engine for the generated dependency artifacts (used by the xtask
+# graph/deps commands). This version lives in Cargo.lock, so dev machines and
+# CI always run the identical generator; guppy is pinned to the version the
+# hakari release is built against.
+guppy = "0.17.24"
hex = "0.4.3"
hmac = "0.12.1"
http = "1"
@@ -183,6 +189,7 @@ serde_json = { version = "1.0.132" }
serde-wasm-bindgen = "0.6"
serde_repr = "0.1"
serde_with = { version = "3.12.0", features = ["base64"] }
+serde_yaml = "0.9"
sha2 = "0.10.8"
sqlx = { version = "0.8.6", features = [
"chrono",
diff --git a/rust/cloud-storage/tools/xtask/Cargo.toml b/rust/cloud-storage/tools/xtask/Cargo.toml
index 7e5abce912..8938dd08ce 100644
--- a/rust/cloud-storage/tools/xtask/Cargo.toml
+++ b/rust/cloud-storage/tools/xtask/Cargo.toml
@@ -1,63 +1,12 @@
[package]
-description = "Repo automation: regenerates workspace-hack and the deploy dep-closure map"
+description = "cargo x launcher: delegates each subcommand to its own xtask-<command> crate so only that command's deps compile"
edition = "2024"
name = "xtask"
publish = false
version = "0.1.0"
+# Intentionally dependency-free: the launcher only maps a subcommand to its
+# command crate and re-invokes `cargo run -p xtask_<command>`. Keeping it free
+# of dependencies means `cargo x` never compiles guppy/hakari/aws-sdk/etc. just
+# to dispatch. The command crates live under `crates/*`.
[dependencies]
-anyhow = { workspace = true }
-serde_json = { workspace = true }
-# Pinned engine for the generated dependency artifacts. These versions live in
-# Cargo.lock, so dev machines and CI always run the identical generator —
-# upgrading it is an explicit, reviewed lock change. guppy is pinned to the
-# version this hakari release is built against.
-guppy = "0.17.24"
-hakari = { version = "0.17.9", features = ["cli-support"] }
-# Define GitHub Actions workflows in Rust (`cargo run -p xtask -- workflows`).
-# xtask is excluded from hakari traversal, so these stay out of workspace-hack.
-gh-workflow = "0.8"
-indoc = "2"
-# Local/dev orchestration (`cargo x run-local` etc.). xtask is excluded from
-# hakari traversal, so these deps never enter workspace-hack. We reuse the
-# workspace-pinned versions so the orchestrator builds against the same crate
-# graph as the services it launches.
-aws-sdk-dynamodb = { workspace = true }
-aws-sdk-s3 = { workspace = true }
-aws-sdk-sqs = { workspace = true }
-clap = { workspace = true }
-macro_aws_config = { path = "../../macro_aws_config" }
-macro_queues = { path = "../../macro_queues" }
-serde = { workspace = true }
-tokio = { workspace = true }
-# Source of truth for `cargo x kafka-topics`, which generates
-# .github/kafka-cluster-topics.json from the crate's declared topics, and for
-# the local-stack topic provisioning (local::kafka).
-macro_event_topics = { path = "../../macro_event_topics" }
-# AdminClient for creating the declared topics on the local broker. Optional
-# (behind `local-stack`): the workspace links librdkafka dynamically, and the
-# CI jobs that build xtask on bare runners (path filters, generated-file
-# checks) have no system librdkafka to link against.
-rdkafka = { workspace = true, optional = true }
-# Typed docker-compose model (build the override as structs, not strings) +
-# Docker Engine API client for the discrete container/image ops.
-bollard = "0.21"
-console = "0.15"
-docker-compose-types = { version = "0.24", features = ["indexmap"] }
-indexmap = { workspace = true }
-indicatif = "0.18"
-serde_yaml = "0.9"
-# Parse user-provided `--env-file` overlays (reading only; no crate emits the
-# docker-compose `env_file` format we generate). EnumIter derives the port list.
-dotenvy = { workspace = true }
-strum = { workspace = true, features = ["derive"] }
-# Signal the frontend dev server's whole process group on shutdown (kill bun +
-# the Vite child it spawns, not just bun).
-libc = "0.2"
-macro_env_var = { path = "../../macro_env_var" }
-
-[features]
-# Local Kafka topic provisioning (`run-local` / `kafka-provision`). Off by
-# default so plain `cargo run -p xtask` builds without a system librdkafka;
-# the just recipes (just/xtask.just) enable it.
-local-stack = ["dep:rdkafka"]
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/Cargo.toml
new file mode 100644
index 0000000000..0dbb20558d
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+description = "xtask cache-wasm: build the browser cache wasm package when missing or version-drifted"
+edition = "2024"
+name = "xtask_cache_wasm"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_cache_wasm"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+serde_json = { workspace = true }
+xtask_paths = { path = "../xtask_paths" }
diff --git a/rust/cloud-storage/tools/xtask/src/cache_wasm.rs b/rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/src/main.rs
similarity index 85%
rename from rust/cloud-storage/tools/xtask/src/cache_wasm.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/src/main.rs
index 01d71f518d..9a9bf3f83a 100644
--- a/rust/cloud-storage/tools/xtask/src/cache_wasm.rs
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_cache_wasm/src/main.rs
@@ -1,4 +1,4 @@
-//! `cargo run -p xtask -- cache-wasm [--force]`
+//! `cargo x cache-wasm [--force]`
//!
//! Ensures the browser cache wasm package (`client/cache-wasm`, built by
//! wasm-pack into the gitignored `js/app/packages/graphql-cache/wasm/`) is
@@ -13,27 +13,26 @@
//! this check — they always rebuild (`just build-cache-wasm` → `--force`),
//! so deploys never depend on version-bump discipline.
-use std::{
- path::{Path, PathBuf},
- process::Command,
-};
+use std::{path::Path, process::Command};
use anyhow::{Context, Result, bail};
const CRATE_REL: &str = "client/cache-wasm";
const PKG_REL: &str = "js/app/packages/graphql-cache/wasm";
-pub(crate) fn run(force: bool) -> Result<()> {
- let workspace_dir: PathBuf = Path::new(env!("CARGO_MANIFEST_DIR"))
- .ancestors()
- .nth(2)
- .context("xtask manifest dir has no workspace root two levels up")?
- .to_path_buf();
- let repo_root = workspace_dir
- .ancestors()
- .nth(2)
- .context("workspace root has no repo root two levels up")?
- .to_path_buf();
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ let force = match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [] => false,
+ ["--force"] => true,
+ _ => bail!("usage: cargo x cache-wasm [--force]"),
+ };
+ run(force)
+}
+
+fn run(force: bool) -> Result<()> {
+ let workspace_dir = xtask_paths::workspace_root();
+ let repo_root = xtask_paths::repo_root();
let crate_version = crate_version(&workspace_dir.join(CRATE_REL).join("Cargo.toml"))?;
let pkg_dir = repo_root.join(PKG_REL);
@@ -76,7 +75,7 @@ pub(crate) fn run(force: bool) -> Result<()> {
/// Reads `version = "…"` from the crate's `[package]` section. A focused
/// line scan (the first `version =` in the manifest precedes any other
-/// section) keeps xtask free of a toml dependency.
+/// section) keeps the task free of a toml dependency.
fn crate_version(manifest: &Path) -> Result<String> {
let text = std::fs::read_to_string(manifest)
.with_context(|| format!("reading {}", manifest.display()))?;
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_deps/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_deps/Cargo.toml
new file mode 100644
index 0000000000..6fa809d897
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_deps/Cargo.toml
@@ -0,0 +1,20 @@
+[package]
+description = "xtask deps: regenerate/verify workspace-hack and the deploy dep-closure map"
+edition = "2024"
+name = "xtask_deps"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_deps"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+serde_json = { workspace = true }
+guppy = { workspace = true }
+# Pinned engine for the generated dependency artifacts. This version lives in
+# Cargo.lock, so dev machines and CI always run the identical generator —
+# upgrading it is an explicit, reviewed lock change.
+hakari = { version = "0.17.9", features = ["cli-support"] }
+xtask_graph = { path = "../xtask_graph" }
diff --git a/rust/cloud-storage/tools/xtask/src/closures.rs b/rust/cloud-storage/tools/xtask/crates/xtask_deps/src/closures.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/closures.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_deps/src/closures.rs
diff --git a/rust/cloud-storage/tools/xtask/src/hakari_ops.rs b/rust/cloud-storage/tools/xtask/crates/xtask_deps/src/hakari_ops.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/hakari_ops.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_deps/src/hakari_ops.rs
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_deps/src/main.rs b/rust/cloud-storage/tools/xtask/crates/xtask_deps/src/main.rs
new file mode 100644
index 0000000000..b1040441c8
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_deps/src/main.rs
@@ -0,0 +1,55 @@
+//! `cargo x deps [--check]` regenerates (or, with `--check`, verifies) the two
+//! generated dependency artifacts:
+//!
+//! - `workspace-hack/Cargo.toml` (via the hakari engine): pins every
+//! third-party dep to its union feature set so a solo `cargo build -p X`
+//! resolves the same features as the union-built crane dep layers, keeping
+//! the warm dependency caches exact fingerprint matches.
+//! - `.github/workspace-dep-closures.json`: every workspace crate's
+//! transitive workspace dependency closure, consumed by flake.nix to build
+//! pruned per-artifact deploy sources.
+//!
+//! Both run from the hakari/guppy versions pinned in Cargo.lock, so local
+//! runs and CI cannot disagree about generator versions. `just hakari` wraps
+//! the regenerate mode; CI runs `--check` and fails on drift.
+
+mod closures;
+mod hakari_ops;
+
+use anyhow::{Result, bail};
+use guppy::graph::PackageGraph;
+use xtask_graph::build_graph;
+
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [] => run_deps(false),
+ ["--check"] => run_deps(true),
+ _ => bail!("usage: cargo x deps [--check]"),
+ }
+}
+
+fn run_deps(check: bool) -> Result<()> {
+ let graph = build_graph(check)?;
+
+ let mut drift: Vec<String> = Vec::new();
+ let hakari_changed = hakari_ops::run(&graph, check, &mut drift)?;
+
+ // The hakari step may have edited manifests (hack contents or member dep
+ // lines); recompute the graph so the closure map sees the result. The
+ // fresh `cargo metadata` also refreshes Cargo.lock after those edits.
+ let graph: PackageGraph = if hakari_changed {
+ build_graph(false)?
+ } else {
+ graph
+ };
+ closures::run(&graph, check, &mut drift)?;
+
+ if !drift.is_empty() {
+ bail!(
+ "generated dependency artifacts are stale:\n - {}\nrun `just hakari` (or `cargo x deps`) from rust/cloud-storage and commit the result",
+ drift.join("\n - ")
+ );
+ }
+ Ok(())
+}
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_doppler_bins/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_doppler_bins/Cargo.toml
new file mode 100644
index 0000000000..aa8b57bdc2
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_doppler_bins/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+description = "xtask doppler-bins: doppler config-validation bins affected by a set of changed files"
+edition = "2024"
+name = "xtask_doppler_bins"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_doppler_bins"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+guppy = { workspace = true }
+xtask_graph = { path = "../xtask_graph" }
diff --git a/rust/cloud-storage/tools/xtask/src/doppler_bins.rs b/rust/cloud-storage/tools/xtask/crates/xtask_doppler_bins/src/main.rs
similarity index 80%
rename from rust/cloud-storage/tools/xtask/src/doppler_bins.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_doppler_bins/src/main.rs
index f4125df269..64276d7830 100644
--- a/rust/cloud-storage/tools/xtask/src/doppler_bins.rs
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_doppler_bins/src/main.rs
@@ -1,3 +1,5 @@
+//! `cargo x doppler-bins <changed-files-path>`
+//!
//! Computes which "doppler config" validation binaries are affected by a set of
//! changed files, for cloud-storage CI.
//!
@@ -11,20 +13,31 @@
//!
//! Input is a newline-delimited file of paths relative to the repository root
//! (typically `git diff --name-only ...`). Output is the affected bin names, one
-//! per line, sorted and deduplicated. This is the native replacement for the
-//! previous bash + python script and reuses the same guppy package graph as
-//! [`crate::nextest_filter`].
+//! per line, sorted and deduplicated.
use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
-use anyhow::{Context, Result};
+use anyhow::{Context, Result, bail};
use guppy::graph::{BuildTargetId, PackageGraph};
+use xtask_graph::build_graph;
/// Source path (relative to a crate root) of a service's doppler-config binary.
const DOPPLER_CONFIG_SRC: &str = "src/doppler_config.rs";
-pub fn run(graph: &PackageGraph, changed_files_path: &Path) -> Result<()> {
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [changed_files_path] => {
+ // Read-only: `--locked` so computing the filter never rewrites Cargo.lock.
+ let graph = build_graph(true)?;
+ run(&graph, Path::new(changed_files_path))
+ }
+ _ => bail!("usage: cargo x doppler-bins <changed-files-path>"),
+ }
+}
+
+fn run(graph: &PackageGraph, changed_files_path: &Path) -> Result<()> {
let workspace = graph.workspace();
let ws_root = workspace.root();
let repo_root = ws_root
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_graph/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_graph/Cargo.toml
new file mode 100644
index 0000000000..30dec9f9d2
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_graph/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+description = "Shared guppy PackageGraph builder for the graph-based xtask commands"
+edition = "2024"
+name = "xtask_graph"
+publish = false
+version = "0.1.0"
+
+[dependencies]
+anyhow = { workspace = true }
+guppy = { workspace = true }
+xtask_paths = { path = "../xtask_paths" }
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_graph/src/lib.rs b/rust/cloud-storage/tools/xtask/crates/xtask_graph/src/lib.rs
new file mode 100644
index 0000000000..b08e98af7a
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_graph/src/lib.rs
@@ -0,0 +1,31 @@
+#![deny(missing_docs)]
+//! Shared guppy [`PackageGraph`] construction for the graph-based xtask
+//! commands (`deps`, `nextest-filter`, `doppler-bins`).
+//!
+//! Anchors `cargo metadata` on the workspace root (from [`xtask_paths`]) so
+//! the task works from anywhere in the repo.
+
+use anyhow::{Context, Result};
+use guppy::MetadataCommand;
+use guppy::graph::PackageGraph;
+
+/// Build the workspace [`PackageGraph`] via `cargo metadata`.
+///
+/// When `locked` is set, `--locked` is passed so a stale `Cargo.lock` surfaces
+/// as an error (it is itself drift for the generator) instead of being
+/// silently rewritten.
+pub fn build_graph(locked: bool) -> Result<PackageGraph> {
+ let workspace_dir = xtask_paths::workspace_root();
+ let mut cmd = MetadataCommand::new();
+ cmd.current_dir(&workspace_dir);
+ if locked {
+ cmd.other_options(vec!["--locked".to_owned()]);
+ }
+ cmd.build_graph().with_context(|| {
+ if locked {
+ "running cargo metadata --locked (a stale Cargo.lock is drift: run `just hakari` and commit)"
+ } else {
+ "running cargo metadata"
+ }
+ })
+}
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_graphql_soup_schema/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_graphql_soup_schema/Cargo.toml
new file mode 100644
index 0000000000..4d4937e204
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_graphql_soup_schema/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+description = "xtask graphql-soup-schema: export the GraphQL Soup SDL to a file"
+edition = "2024"
+name = "xtask_graphql_soup_schema"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_graphql_soup_schema"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+xtask_paths = { path = "../xtask_paths" }
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_graphql_soup_schema/src/main.rs b/rust/cloud-storage/tools/xtask/crates/xtask_graphql_soup_schema/src/main.rs
new file mode 100644
index 0000000000..c5da6ee939
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_graphql_soup_schema/src/main.rs
@@ -0,0 +1,41 @@
+//! `cargo x graphql-soup-schema <output-path>`
+//!
+//! Exports the GraphQL Soup SDL to a file by running the `graphql_soup`
+//! crate's schema-export bin with `SQLX_OFFLINE` so it needs no database.
+
+use std::{path::Path, process::Command};
+
+use anyhow::{Context, Result, bail};
+
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [output_path] => run(Path::new(output_path)),
+ _ => bail!("usage: cargo x graphql-soup-schema <output-path>"),
+ }
+}
+
+fn run(output_path: &Path) -> Result<()> {
+ let workspace_dir = xtask_paths::workspace_root();
+
+ let status = Command::new("cargo")
+ .current_dir(&workspace_dir)
+ .arg("run")
+ .arg("--config")
+ .arg("env.SQLX_OFFLINE=\"true\"")
+ .arg("--quiet")
+ .arg("-p")
+ .arg("graphql_soup")
+ .arg("--bin")
+ .arg("graphql_soup_schema")
+ .arg("--")
+ .arg(output_path)
+ .status()
+ .with_context(|| format!("exporting GraphQL Soup schema to {}", output_path.display()))?;
+
+ if !status.success() {
+ bail!("GraphQL Soup schema export failed with status {status}");
+ }
+
+ Ok(())
+}
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_kafka_topics/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_kafka_topics/Cargo.toml
new file mode 100644
index 0000000000..1dcde5045d
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_kafka_topics/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+description = "xtask kafka-topics: generate/verify .github/kafka-cluster-topics.json from macro_event_topics"
+edition = "2024"
+name = "xtask_kafka_topics"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_kafka_topics"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+serde_json = { workspace = true }
+# Source of truth for the declared topics.
+macro_event_topics = { path = "../../../../macro_event_topics" }
+xtask_paths = { path = "../xtask_paths" }
diff --git a/rust/cloud-storage/tools/xtask/src/kafka_topics.rs b/rust/cloud-storage/tools/xtask/crates/xtask_kafka_topics/src/main.rs
similarity index 75%
rename from rust/cloud-storage/tools/xtask/src/kafka_topics.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_kafka_topics/src/main.rs
index 0d50cd23c1..9b17fdb6ae 100644
--- a/rust/cloud-storage/tools/xtask/src/kafka_topics.rs
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_kafka_topics/src/main.rs
@@ -1,3 +1,5 @@
+//! `cargo x kafka-topics [--check]`
+//!
//! Generates `.github/kafka-cluster-topics.json`: the name of every Kafka
//! topic declared in the `macro_event_topics` crate, consumed by infra
//! (alongside `services-config.json`) to ensure all cluster topics are
@@ -5,22 +7,23 @@
//! can guarantee the checked-in file always matches the crate.
use std::collections::BTreeSet;
-use std::path::Path;
use anyhow::{Context, Result, bail};
const OUTPUT_REL: &str = ".github/kafka-cluster-topics.json";
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [] => run(false),
+ ["--check"] => run(true),
+ _ => bail!("usage: cargo x kafka-topics [--check]"),
+ }
+}
+
/// Regenerates (or, in check mode, diffs) the topics file.
-pub fn run(check: bool) -> Result<()> {
- // Anchor on the manifest dir, not the invocation cwd, so the task works
- // from anywhere in the repo. The crate lives at
- // `<repo-root>/rust/cloud-storage/tools/xtask`, i.e. four ancestors up.
- let repo_root = Path::new(env!("CARGO_MANIFEST_DIR"))
- .ancestors()
- .nth(4)
- .context("xtask manifest dir has no repo root four levels up")?;
- let output_path = repo_root.join(OUTPUT_REL);
+fn run(check: bool) -> Result<()> {
+ let output_path = xtask_paths::repo_root().join(OUTPUT_REL);
// Sorted for a deterministic file regardless of declaration order. A bare
// array (no disclaimer wrapper) so infra can parse the file directly.
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_local/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_local/Cargo.toml
new file mode 100644
index 0000000000..afbc0b9337
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_local/Cargo.toml
@@ -0,0 +1,53 @@
+[package]
+description = "xtask local: Macro local & dev stack orchestration (infra + binaries + proxy + frontend)"
+edition = "2024"
+name = "xtask_local"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_local"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+serde_json = { workspace = true }
+# Local/dev orchestration. These deps reuse the workspace-pinned versions so
+# the orchestrator builds against the same crate graph as the services it
+# launches.
+aws-sdk-dynamodb = { workspace = true }
+aws-sdk-s3 = { workspace = true }
+aws-sdk-sqs = { workspace = true }
+clap = { workspace = true }
+macro_aws_config = { path = "../../../../macro_aws_config" }
+macro_queues = { path = "../../../../macro_queues" }
+serde = { workspace = true }
+tokio = { workspace = true }
+# Source of truth for the declared Kafka topics (local-stack provisioning).
+macro_event_topics = { path = "../../../../macro_event_topics" }
+# AdminClient for creating the declared topics on the local broker. Optional
+# (behind `local-stack`): the workspace links librdkafka dynamically, and the
+# CI jobs that build this on bare runners have no system librdkafka to link
+# against.
+rdkafka = { workspace = true, optional = true }
+# Typed docker-compose model (build the override as structs, not strings) +
+# Docker Engine API client for the discrete container/image ops.
+bollard = "0.21"
+console = "0.15"
+docker-compose-types = { version = "0.24", features = ["indexmap"] }
+indexmap = { workspace = true }
+indicatif = "0.18"
+serde_yaml = { workspace = true }
+# Parse user-provided `--env-file` overlays. EnumIter derives the port list.
+dotenvy = { workspace = true }
+strum = { workspace = true, features = ["derive"] }
+# Signal the frontend dev server's whole process group on shutdown.
+libc = "0.2"
+macro_env_var = { path = "../../../../macro_env_var" }
+xtask_paths = { path = "../xtask_paths" }
+
+[features]
+# Local Kafka topic provisioning (`run-local` / `kafka-provision`). Off by
+# default so a plain build works without a system librdkafka; the just recipes
+# enable it.
+local-stack = ["dep:rdkafka"]
diff --git a/rust/cloud-storage/tools/xtask/src/local/arch.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/arch.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/arch.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/arch.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/build/binaries_dir.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/binaries_dir.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/build/binaries_dir.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/binaries_dir.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/build/mod.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/mod.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/build/mod.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/mod.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/build/runtime_image.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/runtime_image.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/build/runtime_image.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/runtime_image.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/build/zigbuild.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/zigbuild.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/build/zigbuild.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/build/zigbuild.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/cli.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/cli.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/cli.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/cli.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/db.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/db.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/db.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/db.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/docker.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/docker.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/docker.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/docker.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/doctor.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/doctor.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/doctor.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/doctor.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/env_layer.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/env_layer.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/env_layer.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/env_layer.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/frontend.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/frontend.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/frontend.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/frontend.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/fusionauth.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/fusionauth.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/fusionauth.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/fusionauth.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/gen_compose.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/gen_compose.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/gen_compose.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/gen_compose.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/identity.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/identity.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/identity.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/identity.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/instance.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/instance.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/instance.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/instance.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/instance/test.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/instance/test.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/instance/test.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/instance/test.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/inventory.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/inventory.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/inventory.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/inventory.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/inventory/test.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/inventory/test.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/inventory/test.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/inventory/test.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/kafka.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/kafka.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/kafka.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/kafka.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/kickstart.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/kickstart.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/kickstart.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/kickstart.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/local_env.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/local_env.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/local_env.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/local_env.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/local_env/test.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/local_env/test.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/local_env/test.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/local_env/test.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/localstack.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/localstack.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/localstack.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/localstack.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/mailpit.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/mailpit.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/mailpit.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/mailpit.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/mod.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/mod.rs
similarity index 98%
rename from rust/cloud-storage/tools/xtask/src/local/mod.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/mod.rs
index 870266c70a..4163833794 100644
--- a/rust/cloud-storage/tools/xtask/src/local/mod.rs
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/mod.rs
@@ -11,7 +11,7 @@
//! Design invariant: Docker never compiles Rust. Binaries are built on the host
//! and bind-mounted read-only into the runtime image at `/app/out`.
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
pub mod arch;
pub mod build;
@@ -132,25 +132,17 @@ impl Mode {
}
/// The cloud-storage cargo workspace root (`rust/cloud-storage`). Anchored on
-/// the crate manifest dir rather than the invocation cwd so the orchestrator
-/// works from anywhere, exactly like `main::build_graph`.
+/// the manifest dir rather than the invocation cwd so the orchestrator works
+/// from anywhere.
pub fn workspace_root() -> PathBuf {
- Path::new(env!("CARGO_MANIFEST_DIR"))
- .ancestors()
- .nth(2)
- .expect("xtask manifest dir has no workspace root two levels up")
- .to_owned()
+ xtask_paths::workspace_root()
}
/// The repository root (two levels above the cloud-storage workspace:
/// `<repo>/rust/cloud-storage`). This is where `docker-compose.yml`,
/// `infra/`, `js/`, and the root `justfile` live.
pub fn repo_root() -> PathBuf {
- workspace_root()
- .ancestors()
- .nth(2)
- .expect("cloud-storage workspace has no repo root two levels up")
- .to_owned()
+ xtask_paths::repo_root()
}
use std::process::Command;
diff --git a/rust/cloud-storage/tools/xtask/src/local/opensearch.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/opensearch.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/opensearch.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/opensearch.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/proxy.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/proxy.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/proxy.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/proxy.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/proxy/test.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/proxy/test.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/proxy/test.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/proxy/test.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/resources.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/resources.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/resources.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/resources.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/resources/test.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/resources/test.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/resources/test.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/resources/test.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/stage.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/stage.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/stage.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/stage.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/summary.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/summary.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/summary.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/summary.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/test.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/test.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/test.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/test.rs
diff --git a/rust/cloud-storage/tools/xtask/src/local/validate.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/validate.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/local/validate.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_local/src/local/validate.rs
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_local/src/main.rs b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/main.rs
new file mode 100644
index 0000000000..e77248b44b
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_local/src/main.rs
@@ -0,0 +1,21 @@
+//! `cargo x <local-orchestration-command>`
+//!
+//! The local/dev orchestration surface (`run-local`, `run-dev`, `zigbuild`,
+//! `doctor-local`, …). It has many subcommands each with several flags, so it
+//! uses a real (clap) parser rather than fixed-arity slice patterns. The
+//! launcher forwards any command it does not recognize as a repo-automation
+//! verb here, so unknown input surfaces both this parser's help and the
+//! repo-automation verbs (via [`LAUNCHER_USAGE`]).
+
+mod local;
+
+use anyhow::Result;
+
+/// The repo-automation verbs handled by the launcher. Shown alongside this
+/// crate's own clap usage when an unrecognized command reaches the parser.
+const LAUNCHER_USAGE: &str = "repo automation (from rust/cloud-storage):\n cargo x deps [--check]\n cargo x nextest-filter <changed-files-path>\n cargo x doppler-bins <changed-files-path>\n cargo x graphql-soup-schema <output-path>\n cargo x cache-wasm [--force]\n cargo x kafka-topics [--check]\n cargo x workflows [--check]";
+
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ local::cli::dispatch(&args, LAUNCHER_USAGE)
+}
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_nextest_filter/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_nextest_filter/Cargo.toml
new file mode 100644
index 0000000000..ffb8dc6460
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_nextest_filter/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+description = "xtask nextest-filter: nextest rdeps package filter for a set of changed files"
+edition = "2024"
+name = "xtask_nextest_filter"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_nextest_filter"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+guppy = { workspace = true }
+xtask_graph = { path = "../xtask_graph" }
diff --git a/rust/cloud-storage/tools/xtask/src/nextest_filter.rs b/rust/cloud-storage/tools/xtask/crates/xtask_nextest_filter/src/main.rs
similarity index 78%
rename from rust/cloud-storage/tools/xtask/src/nextest_filter.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_nextest_filter/src/main.rs
index e2c8054231..5dc578c7b0 100644
--- a/rust/cloud-storage/tools/xtask/src/nextest_filter.rs
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_nextest_filter/src/main.rs
@@ -1,3 +1,5 @@
+//! `cargo x nextest-filter <changed-files-path>`
+//!
//! Computes the cargo-nextest package filter for cloud-storage CI.
//!
//! Input is a newline-delimited file of paths relative to the repository root
@@ -9,10 +11,23 @@
use std::collections::BTreeSet;
use std::path::{Path, PathBuf};
-use anyhow::{Context, Result};
+use anyhow::{Context, Result, bail};
use guppy::graph::PackageGraph;
+use xtask_graph::build_graph;
+
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [changed_files_path] => {
+ // Read-only: `--locked` so computing the filter never rewrites Cargo.lock.
+ let graph = build_graph(true)?;
+ run(&graph, Path::new(changed_files_path))
+ }
+ _ => bail!("usage: cargo x nextest-filter <changed-files-path>"),
+ }
+}
-pub fn run(graph: &PackageGraph, changed_files_path: &Path) -> Result<()> {
+fn run(graph: &PackageGraph, changed_files_path: &Path) -> Result<()> {
let workspace = graph.workspace();
let ws_root = workspace.root();
let repo_root = ws_root
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_paths/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_paths/Cargo.toml
new file mode 100644
index 0000000000..35771cbdf7
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_paths/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+description = "Shared path discovery for the xtask command crates (workspace + repo roots)"
+edition = "2024"
+name = "xtask_paths"
+publish = false
+version = "0.1.0"
+
+[dependencies]
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_paths/src/lib.rs b/rust/cloud-storage/tools/xtask/crates/xtask_paths/src/lib.rs
new file mode 100644
index 0000000000..3940d39b08
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_paths/src/lib.rs
@@ -0,0 +1,39 @@
+#![deny(missing_docs)]
+//! Shared path discovery for the xtask command crates.
+//!
+//! Every xtask command needs to locate the cloud-storage workspace root (to
+//! anchor `cargo metadata`, read member manifests, spawn `wasm-pack`, …) and
+//! the repository root above it (where `docker-compose.yml`, `infra/`, `js/`,
+//! and the root `justfile` live). Both are derived from this crate's own
+//! manifest dir rather than the invocation cwd, so the commands work from
+//! anywhere in the repo.
+//!
+//! Centralizing the ancestor walk here means the hardcoded depth lives in one
+//! place: this crate sits at `<workspace>/tools/xtask/crates/xtask_paths`, so
+//! the workspace root is four levels up regardless of which command crate
+//! calls in.
+
+use std::path::{Path, PathBuf};
+
+/// The cloud-storage cargo workspace root (`rust/cloud-storage`).
+///
+/// `env!("CARGO_MANIFEST_DIR")` expands to this crate's directory, which is a
+/// fixed location, so the depth here does not depend on the caller.
+pub fn workspace_root() -> PathBuf {
+ // <workspace>/tools/xtask/crates/xtask_paths -> nth(4) == <workspace>.
+ Path::new(env!("CARGO_MANIFEST_DIR"))
+ .ancestors()
+ .nth(4)
+ .expect("xtask_paths manifest dir has no workspace root four levels up")
+ .to_owned()
+}
+
+/// The repository root (two levels above the cloud-storage workspace:
+/// `<repo>/rust/cloud-storage`).
+pub fn repo_root() -> PathBuf {
+ workspace_root()
+ .ancestors()
+ .nth(2)
+ .expect("cloud-storage workspace has no repo root two levels up")
+ .to_owned()
+}
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_workflows/Cargo.toml b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/Cargo.toml
new file mode 100644
index 0000000000..51e13889cf
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+description = "xtask workflows: generate/verify the repo's GitHub Actions workflows from Rust"
+edition = "2024"
+name = "xtask_workflows"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "xtask_workflows"
+path = "src/main.rs"
+
+[dependencies]
+anyhow = { workspace = true }
+serde_json = { workspace = true }
+# Define GitHub Actions workflows in Rust.
+gh-workflow = "0.8"
+indoc = "2"
+serde_yaml = { workspace = true }
+xtask_paths = { path = "../xtask_paths" }
diff --git a/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/main.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/main.rs
new file mode 100644
index 0000000000..ff65082517
--- /dev/null
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/main.rs
@@ -0,0 +1,19 @@
+//! `cargo x workflows [--check]`
+//!
+//! Generates the repo's GitHub Actions workflows from Rust (see the
+//! [`workflows`] module). The `--check` variant regenerates them in memory and
+//! fails if the committed YAML has drifted, so CI can guarantee the checked-in
+//! YAML always matches this source.
+
+mod workflows;
+
+use anyhow::{Result, bail};
+
+fn main() -> Result<()> {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
+ [] => workflows::generate(),
+ ["--check"] => workflows::check(),
+ _ => bail!("usage: cargo x workflows [--check]"),
+ }
+}
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/assign_author.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/assign_author.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/assign_author.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/assign_author.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/assign_labels.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/assign_labels.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/assign_labels.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_appimage_on_tag.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/build_appimage_on_tag.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_appimage_on_tag.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/build_desktop_on_tag.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/build_dmg_on_tag.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/cancel_stuck_cloud_storage_deploys.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/cancel_stuck_cloud_storage_deploys.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/cargo_deny.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cargo_deny.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/cargo_workspace_dependency_check.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cargo_workspace_dependency_check.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/check_generated.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/check_generated.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/check_generated.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/check_node_modules_nix.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/check_node_modules_nix.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/cleanup_preview.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/code_check_cloud_storage.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/code_check_infra.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/code_check_infra.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/code_check_infra.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/deploy_preview.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_preview.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/deploy_web_app.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/deploy_web_app.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/deploy_web_app_dev_push.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/deploy_web_app_dev_push.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/mod.rs
similarity index 93%
rename from rust/cloud-storage/tools/xtask/src/workflows/mod.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/mod.rs
index ad5adf2261..551ded7fce 100644
--- a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs
+++ b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/mod.rs
@@ -1,6 +1,6 @@
//! Generate the repo's GitHub Actions workflows from Rust.
//!
-//! `cargo run -p xtask -- workflows` writes every entry in [`WORKFLOWS`] to
+//! `cargo x workflows` writes every entry in [`WORKFLOWS`] to
//! `<repo-root>/.github/workflows/<filename>`. The `--check` variant regenerates
//! them in memory and fails if the committed YAML has drifted, so CI can
//! guarantee the checked-in YAML always matches this source.
@@ -33,7 +33,7 @@ mod vars;
mod web_app_check_main;
use std::fs;
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
use anyhow::{Context, Result, bail};
use gh_workflow::Workflow;
@@ -250,19 +250,14 @@ fn render(workflow: &WorkflowFile) -> Result<String> {
fn disclaimer(source: &str) -> String {
format!(
"# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).\n\
- # Source: rust/cloud-storage/tools/xtask/src/workflows/{source}.rs\n",
+ # Source: rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/{source}.rs\n",
)
}
-/// `<repo-root>/.github/workflows`, anchored on the crate's manifest dir so the
-/// task works from any cwd. This crate lives at
-/// `<repo-root>/rust/cloud-storage/tools/xtask`, i.e. four ancestors up.
+/// `<repo-root>/.github/workflows`. Anchored on the repo root (from
+/// [`xtask_paths`]) so the task works from any cwd.
fn workflows_dir() -> Result<PathBuf> {
- let repo_root = Path::new(env!("CARGO_MANIFEST_DIR"))
- .ancestors()
- .nth(4)
- .context("xtask manifest dir has no repo root four levels up")?;
- let dir = repo_root.join(".github").join("workflows");
+ let dir = xtask_paths::repo_root().join(".github").join("workflows");
if !dir.is_dir() {
bail!("expected a workflows directory at {}", dir.display());
}
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/pulumi_preview_pr.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/pulumi_preview_pr.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/pulumi_preview_pr.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/pulumi_preview_pr.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/reusable_preview_service.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/reusable_preview_service.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/reusable_preview_service.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/reusable_preview_service.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/runners.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/runners.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/runners.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/runners.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/build_appimage.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/build_appimage.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/build_appimage.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/build_appimage.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/build_dmg.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/build_dmg.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/build_dmg.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/build_dmg.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_appimage.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/collect_appimage.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_appimage.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/collect_appimage.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_dmg.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/collect_dmg.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/collect_dmg.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/collect_dmg.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/compute_changed_files.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/compute_changed_files.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/compute_changed_files.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/compute_changed_files.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/compute_doppler_bins.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/compute_doppler_bins.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/compute_doppler_bins.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/compute_doppler_bins.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/compute_nextest_filter.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/compute_nextest_filter.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/compute_nextest_filter.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/compute_nextest_filter.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/configure_postgres.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/configure_postgres.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/configure_postgres.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/configure_postgres.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/configure_signing_identity.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/configure_signing_identity.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/configure_signing_identity.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/configure_signing_identity.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/install_nix_macos.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/install_nix_macos.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/install_nix_macos.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/install_nix_macos.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/resolve_desktop_ref.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/resolve_desktop_ref.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/resolve_desktop_ref.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/resolve_desktop_ref.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/run_tests.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/run_tests.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/run_tests.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/run_tests.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_doppler_configs.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/validate_doppler_configs.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_doppler_configs.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/validate_doppler_configs.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_signed_dmg.sh b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/validate_signed_dmg.sh
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/scripts/validate_signed_dmg.sh
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/scripts/validate_signed_dmg.sh
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/steps.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/steps.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/steps.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/steps.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/vars.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/vars.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/vars.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/vars.rs
diff --git a/rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs b/rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
similarity index 100%
rename from rust/cloud-storage/tools/xtask/src/workflows/web_app_check_main.rs
rename to rust/cloud-storage/tools/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
diff --git a/rust/cloud-storage/tools/xtask/src/graphql_soup_schema.rs b/rust/cloud-storage/tools/xtask/src/graphql_soup_schema.rs
deleted file mode 100644
index 7fc11adce6..0000000000
--- a/rust/cloud-storage/tools/xtask/src/graphql_soup_schema.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-use std::{path::Path, process::Command};
-
-use anyhow::{Context, Result, bail};
-
-pub(crate) fn run(output_path: &Path) -> Result<()> {
- let workspace_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
- .ancestors()
- .nth(2)
- .context("xtask manifest dir has no workspace root two levels up")?;
-
- let status = Command::new("cargo")
- .current_dir(workspace_dir)
- .arg("run")
- .arg("--config")
- .arg("env.SQLX_OFFLINE=\"true\"")
- .arg("--quiet")
- .arg("-p")
- .arg("graphql_soup")
- .arg("--bin")
- .arg("graphql_soup_schema")
- .arg("--")
- .arg(output_path)
- .status()
- .with_context(|| format!("exporting GraphQL Soup schema to {}", output_path.display()))?;
-
- if !status.success() {
- bail!("GraphQL Soup schema export failed with status {status}");
- }
-
- Ok(())
-}
diff --git a/rust/cloud-storage/tools/xtask/src/main.rs b/rust/cloud-storage/tools/xtask/src/main.rs
index e895c2035a..80109dbac0 100644
--- a/rust/cloud-storage/tools/xtask/src/main.rs
+++ b/rust/cloud-storage/tools/xtask/src/main.rs
@@ -1,114 +1,82 @@
-//! Repo automation tasks (the cargo-xtask pattern).
+//! `cargo x <command>` launcher.
//!
-//! `cargo run -p xtask -- deps [--check]` regenerates (or, with `--check`,
-//! verifies) the two generated dependency artifacts:
+//! Each xtask command lives in its own crate under `tools/xtask/crates/` so
+//! that `cargo x <command>` compiles only that command's dependency set — e.g.
+//! `cargo x cache-wasm` (needs only anyhow) does not drag in guppy/hakari,
+//! aws-sdk, tokio, or bollard.
//!
-//! - `workspace-hack/Cargo.toml` (via the hakari engine): pins every
-//! third-party dep to its union feature set so a solo `cargo build -p X`
-//! resolves the same features as the union-built crane dep layers, keeping
-//! the warm dependency caches exact fingerprint matches.
-//! - `.github/workspace-dep-closures.json`: every workspace crate's
-//! transitive workspace dependency closure, consumed by flake.nix to build
-//! pruned per-artifact deploy sources.
+//! The cargo alias (`x = "run -p xtask --"`) is static, so it always builds one
+//! fixed package: this launcher. The launcher itself has no dependencies (it
+//! compiles in a blink and stays warm), maps the subcommand to its command
+//! crate, and re-invokes `cargo run -p xtask_<command>`. Only that crate then
+//! compiles.
//!
-//! Both run from the hakari/guppy versions pinned in Cargo.lock, so local
-//! runs and CI cannot disagree about generator versions. `just hakari` wraps
-//! the regenerate mode; CI runs `--check` and fails on drift.
-
-mod cache_wasm;
-mod closures;
-mod doppler_bins;
-mod graphql_soup_schema;
-mod hakari_ops;
-mod kafka_topics;
-mod local;
-mod nextest_filter;
-mod workflows;
+//! The nested `cargo run` is pinned to the workspace via `--manifest-path`
+//! (derived from this crate's own location at compile time) rather than by
+//! changing the working directory. That makes it work no matter where the
+//! launcher was invoked from — including outside the workspace, as CI does via
+//! `cargo run --manifest-path .../tools/xtask/Cargo.toml -- <command>` — while
+//! leaving the command's own working directory unchanged, so relative path
+//! arguments still resolve against the caller's cwd.
+//!
+//! Repo-automation verbs each map to a dedicated crate; everything else is the
+//! local/dev orchestration surface, forwarded wholesale to `xtask_local`'s clap
+//! parser (which also prints the combined usage on unrecognized input).
-use std::path::Path;
+use std::process::{Command, exit};
-use anyhow::{Context, Result, bail};
-use guppy::MetadataCommand;
-use guppy::graph::PackageGraph;
+/// The workspace root manifest, resolved from this launcher crate's location
+/// (`<workspace>/tools/xtask`) at compile time so the nested `cargo run`
+/// resolves the workspace from any cwd.
+const WORKSPACE_MANIFEST: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../Cargo.toml");
-fn main() -> Result<()> {
+fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
- match args.iter().map(String::as_str).collect::<Vec<_>>()[..] {
- ["deps"] => run_deps(false),
- ["deps", "--check"] => run_deps(true),
- ["nextest-filter", changed_files_path] => {
- let graph = build_graph(false)?;
- nextest_filter::run(&graph, Path::new(changed_files_path))
- }
- ["doppler-bins", changed_files_path] => {
- let graph = build_graph(false)?;
- doppler_bins::run(&graph, Path::new(changed_files_path))
- }
- ["graphql-soup-schema", output_path] => graphql_soup_schema::run(Path::new(output_path)),
- ["cache-wasm"] => cache_wasm::run(false),
- ["cache-wasm", "--force"] => cache_wasm::run(true),
- ["kafka-topics"] => kafka_topics::run(false),
- ["kafka-topics", "--check"] => kafka_topics::run(true),
- ["workflows"] => workflows::generate(),
- ["workflows", "--check"] => workflows::check(),
- // Everything else is the local/dev orchestration surface. It has many
- // subcommands each with several flags, so it uses a real (clap) parser
- // rather than fixed-arity slice patterns. Unknown input falls through
- // to a combined usage message inside `local::cli::dispatch`.
- _ => local::cli::dispatch(&args, LEGACY_USAGE),
- }
-}
-
-/// Usage for the repo-automation verbs handled by the slice match above. The
-/// local orchestration parser appends its own usage and prints both on an
-/// unrecognized command.
-const LEGACY_USAGE: &str = "repo automation (from rust/cloud-storage):\n cargo x deps [--check]\n cargo x nextest-filter <changed-files-path>\n cargo x doppler-bins <changed-files-path>\n cargo x graphql-soup-schema <output-path>\n cargo x cache-wasm [--force]\n cargo x kafka-topics [--check]\n cargo x workflows [--check]";
-fn run_deps(check: bool) -> Result<()> {
- let graph = build_graph(check)?;
-
- let mut drift: Vec<String> = Vec::new();
- let hakari_changed = hakari_ops::run(&graph, check, &mut drift)?;
+ let package = match args.first().map(String::as_str) {
+ Some("deps") => "xtask_deps",
+ Some("nextest-filter") => "xtask_nextest_filter",
+ Some("doppler-bins") => "xtask_doppler_bins",
+ Some("graphql-soup-schema") => "xtask_graphql_soup_schema",
+ Some("cache-wasm") => "xtask_cache_wasm",
+ Some("kafka-topics") => "xtask_kafka_topics",
+ Some("workflows") => "xtask_workflows",
+ // Everything else (including no args) is the local/dev orchestration
+ // surface. Forward every arg — the subcommand is its clap parser's
+ // first positional.
+ _ => "xtask_local",
+ };
- // The hakari step may have edited manifests (hack contents or member dep
- // lines); recompute the graph so the closure map sees the result. The
- // fresh `cargo metadata` also refreshes Cargo.lock after those edits.
- let graph = if hakari_changed {
- build_graph(false)?
+ // Known verbs forward the args after the verb; the local fallthrough keeps
+ // the subcommand as its first argument.
+ let forwarded: &[String] = if package == "xtask_local" {
+ &args
} else {
- graph
+ &args[1..]
};
- closures::run(&graph, check, &mut drift)?;
- if !drift.is_empty() {
- bail!(
- "generated dependency artifacts are stale:\n - {}\nrun `just hakari` (or `cargo run -p xtask -- deps`) from rust/cloud-storage and commit the result",
- drift.join("\n - ")
- );
- }
- Ok(())
-}
+ // Cargo sets $CARGO to its own path when it runs the alias; fall back to
+ // the plain name otherwise.
+ #[allow(
+ clippy::disallowed_methods,
+ reason = "This is not application runtime code"
+ )]
+ let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
+ let status = Command::new(cargo)
+ .arg("run")
+ .arg("--manifest-path")
+ .arg(WORKSPACE_MANIFEST)
+ .arg("-p")
+ .arg(package)
+ .arg("--")
+ .args(forwarded)
+ .status();
-fn build_graph(locked: bool) -> Result<PackageGraph> {
- // Anchor on the manifest dir, not the invocation cwd, so the task works
- // from anywhere in the repo. The crate lives at <workspace>/tools/xtask.
- let workspace_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
- .ancestors()
- .nth(2)
- .context("xtask manifest dir has no workspace root two levels up")?
- .to_owned();
- let mut cmd = MetadataCommand::new();
- cmd.current_dir(&workspace_dir);
- if locked {
- // In check mode a stale lockfile is itself drift; surface it instead
- // of silently rewriting it.
- cmd.other_options(vec!["--locked".to_owned()]);
- }
- cmd.build_graph().with_context(|| {
- if locked {
- "running cargo metadata --locked (a stale Cargo.lock is drift: run `just hakari` and commit)"
- } else {
- "running cargo metadata"
+ match status {
+ Ok(status) => exit(status.code().unwrap_or(1)),
+ Err(e) => {
+ eprintln!("xtask: failed to launch `cargo run -p {package}`: {e}");
+ exit(1);
}
- })
+ }
}