Skip to content

Commit 991a535

Browse files
refactor: Cleanup config (#179)
1 parent 7210ae4 commit 991a535

78 files changed

Lines changed: 1277 additions & 1367 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CLAUDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The `cli/` directory is a Cargo workspace.
22

33
- `crates/hm/` — the `hm` binary (today's CLI body).
4-
- `crates/hm-exec/` — the `ExecutionBackend` trait + `LocalDockerBackend` (in-process Docker DAG scheduler) + `CloudBackend` (submit+watch over the SDK). The `hm` binary renders the emitted `BuildEvent` stream (via `hm-render`) and owns Ctrl-C; auth is injected (the crate takes a built `HarmontClient`).
4+
- `crates/hm-core/` — the shared core: `config` (layered project/user/env config + credential storage), `exec` (the `ExecutionBackend` trait + `LocalBackend` in-process Docker DAG scheduler + `CloudBackend` submit+watch over the SDK), and `sys_runtime` (the process-wide git/python/dirs/cwd runtime). The `hm` binary renders the emitted `BuildEvent` stream (via `hm-render`) and owns Ctrl-C; auth is injected (the backends take a built `HarmontClient`).
55
- `crates/hm-render/` — `drive_stream`: consumes an `EventStream` and writes terminal/JSON output. No I/O beyond stdout.
66
- `crates/hm-pipeline-ir/` — pipeline IR schema (serde structs only, no runtime).
77
- `crates/hm-common/` — shared utilities (OS/filesystem, formatting, and other cross-crate helpers). This is the source of truth for common code; prefer adding shared helpers here.

‎CONTRIBUTING.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,11 @@ cargo insta review
174174
| Crate | What it is |
175175
|---|---|
176176
| `crates/hm` | The `hm` binary (package `harmont-cli`) — command-line client for the Harmont CI platform. |
177-
| `crates/hm-exec` | Pluggable CI execution backends: local and cloud. |
177+
| `crates/hm-core` | Shared core: layered configuration/credential storage, the pluggable CI execution backends (local and cloud), and the process-wide system runtime. |
178178
| `crates/hm-vm` | Local Docker backends that run pipeline steps on your machine. |
179179
| `crates/hm-render` | Build-event renderers (human, with progress bars, and JSON). |
180180
| `crates/hm-dsl-engine` | Evaluates Python pipeline definitions; contains the `harmont` Python package (`harmont-py/`). |
181181
| `crates/hm-pipeline-ir` | The pipeline IR wire-format schema. |
182-
| `crates/hm-config` | Layered configuration and credential storage. |
183182
| `crates/hm-plugin-cloud` | Cloud client library. |
184183
| `crates/hm-plugin-protocol` | Wire types shared between `hm` crate internals. |
185184
| `crates/hm-util` | Shared OS and filesystem utilities. |
@@ -201,7 +200,7 @@ from; a maintainer will regenerate the published docs during review.
201200

202201
Every `hm` command accepts `-v`/`--verbose` for debug-level logging. For
203202
finer control, set `RUST_LOG` with standard tracing filter directives
204-
(for example `RUST_LOG=hm_exec=trace`); when set, it takes precedence over
203+
(for example `RUST_LOG=hm_core::exec=trace`); when set, it takes precedence over
205204
the flag. To see the raw `BuildEvent` stream that the renderers consume,
206205
run with `hm run --format json`.
207206

‎Cargo.lock‎

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,23 @@ resolver = "2"
33
members = [
44
"crates/hm",
55
"crates/hm-common",
6-
"crates/hm-config",
6+
"crates/hm-core",
77
"crates/hm-plugin-protocol",
88
"crates/hm-pipeline-ir",
99
"crates/hm-plugin-cloud",
1010
"crates/hm-dsl-engine",
1111
"crates/hm-render",
12-
"crates/hm-exec",
1312
"crates/hm-vm",
1413
]
1514
default-members = [
1615
"crates/hm",
1716
"crates/hm-common",
18-
"crates/hm-config",
17+
"crates/hm-core",
1918
"crates/hm-plugin-protocol",
2019
"crates/hm-pipeline-ir",
2120
"crates/hm-plugin-cloud",
2221
"crates/hm-dsl-engine",
2322
"crates/hm-render",
24-
"crates/hm-exec",
2523
"crates/hm-vm",
2624
]
2725

@@ -31,11 +29,10 @@ license = "MIT OR Apache-2.0"
3129
repository = "https://github.com/harmont-dev/harmont-cli"
3230

3331
[workspace.dependencies]
34-
hm-exec = { path = "crates/hm-exec", version = "0.0.0-dev" }
32+
hm-core = { path = "crates/hm-core", version = "0.0.0-dev" }
3533
hm-plugin-protocol = { path = "crates/hm-plugin-protocol", version = "0.0.0-dev" }
3634
hm-plugin-cloud = { path = "crates/hm-plugin-cloud", version = "0.0.0-dev" }
3735
hm-pipeline-ir = { path = "crates/hm-pipeline-ir", version = "0.0.0-dev" }
38-
hm-config = { path = "crates/hm-config", version = "0.0.0-dev" }
3936
hm-dsl-engine = { path = "crates/hm-dsl-engine", version = "0.0.0-dev" }
4037
hm-render = { path = "crates/hm-render", version = "0.0.0-dev" }
4138
hm-vm = { path = "crates/hm-vm", version = "0.0.0-dev" }

‎RELEASING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ index yet — which `cargo publish --dry-run` would), then publishes the
4545
crates to crates.io in dependency (topological) order:
4646

4747
```
48-
hm-util → hm-pipeline-ir → hm-config → hm-plugin-protocol → hm-render
49-
→ hm-vm → hm-exec → hm-plugin-cloud → hm-dsl-engine → harmont-cli
48+
hm-common → hm-pipeline-ir → hm-plugin-protocol → hm-render
49+
→ hm-vm → hm-core → hm-plugin-cloud → hm-dsl-engine → harmont-cli
5050
```
5151

5252
`harmont-cli` (the `hm` binary) depends on every other crate, so they

‎crates/hm-common/Cargo.toml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ categories = ["command-line-utilities"]
1111
[lib]
1212
path = "src/lib.rs"
1313

14-
[features]
15-
sys-runtime = []
16-
1714
[dependencies]
1815
anyhow = { workspace = true }
1916
async-trait = { workspace = true }

‎crates/hm-common/src/dir_provider.rs‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::path::{Path, PathBuf};
1717
/// accessor instead of reconstructing one per call.
1818
#[derive(Debug, Clone)]
1919
pub struct DirProvider {
20+
home: PathBuf,
2021
config: PathBuf,
2122
cache: PathBuf,
2223
}
@@ -28,15 +29,23 @@ impl DirProvider {
2829
/// directory.
2930
#[must_use]
3031
pub fn new() -> Option<Self> {
32+
let home = dirs::home_dir()?;
3133
#[cfg(windows)]
3234
let (config, cache) = (dirs::config_dir()?, dirs::cache_dir()?);
3335
#[cfg(not(windows))]
34-
let (config, cache) = {
35-
let home = dirs::home_dir()?;
36-
(home.join(".config"), home.join(".cache"))
37-
};
36+
let (config, cache) = (home.join(".config"), home.join(".cache"));
3837

39-
Some(Self { config, cache })
38+
Some(Self {
39+
home,
40+
config,
41+
cache,
42+
})
43+
}
44+
45+
/// The user home directory.
46+
#[must_use]
47+
pub fn home(&self) -> &Path {
48+
&self.home
4049
}
4150

4251
/// The user configuration root (`~/.config` on non-Windows).
@@ -63,7 +72,11 @@ mod tests {
6372
let dirs = DirProvider::new().unwrap();
6473
assert!(dirs.config().is_absolute(), "got {:?}", dirs.config());
6574
#[cfg(not(windows))]
66-
assert!(dirs.config().ends_with(".config"), "got {:?}", dirs.config());
75+
assert!(
76+
dirs.config().ends_with(".config"),
77+
"got {:?}",
78+
dirs.config()
79+
);
6780
}
6881

6982
#[rstest]

‎crates/hm-common/src/git.rs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Git<'bin> {
2121
}
2222

2323
impl<'bin> Git<'bin> {
24-
/// Wrap a `git` executable, typically via `SysRuntime::git()`.
24+
/// Wrap a `git` executable, typically via `AppCtx::git()`.
2525
#[must_use]
2626
pub const fn new(bin: &'bin Path) -> Self {
2727
Self { bin }
@@ -206,7 +206,11 @@ mod tests {
206206
#[case::wrong_prefix("refs/heads/main", "origin", None)]
207207
#[case::trailing_slash("refs/remotes/origin/", "origin", None)]
208208
#[case::empty("", "origin", None)]
209-
fn parses_default_branch(#[case] line: &str, #[case] remote: &str, #[case] expected: Option<&str>) {
209+
fn parses_default_branch(
210+
#[case] line: &str,
211+
#[case] remote: &str,
212+
#[case] expected: Option<&str>,
213+
) {
210214
let got = parse_default_branch(line.into(), remote);
211215
assert_eq!(got, expected.map(BString::from));
212216
}
@@ -263,7 +267,11 @@ mod tests {
263267
Command::new("git")
264268
.arg("-C")
265269
.arg(dir.path())
266-
.args(["symbolic-ref", "refs/remotes/origin/HEAD", "refs/remotes/origin/main"])
270+
.args([
271+
"symbolic-ref",
272+
"refs/remotes/origin/HEAD",
273+
"refs/remotes/origin/main",
274+
])
267275
.captured()
268276
.unwrap()
269277
.success()

‎crates/hm-common/src/lib.rs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Harmont common utilities shared across the `hm` workspace.
22
3-
#[cfg(feature = "sys-runtime")]
4-
pub mod sys_runtime;
53
pub mod dir_provider;
64
pub mod format;
75
pub mod fs;

‎crates/hm-common/src/process/capture.rs‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ fn render_capture_error(c: &Captured) -> String {
7474
if !stderr.is_empty() {
7575
const MAX: usize = 2000;
7676
let snippet: String = stderr.chars().take(MAX).collect();
77-
let ellipsis = if snippet.len() < stderr.len() { "…" } else { "" };
77+
let ellipsis = if snippet.len() < stderr.len() {
78+
"…"
79+
} else {
80+
""
81+
};
7882
let _ = write!(msg, ": {snippet}{ellipsis}");
7983
}
8084
msg
@@ -114,23 +118,35 @@ pub trait CapturedStreams: sealed::Sealed {
114118
}
115119

116120
/// stdout as `&str`, **panicking** if not valid UTF-8.
117-
#[allow(clippy::expect_used, reason = "callers opt into panic-on-invalid by calling _unwrap")]
121+
#[allow(
122+
clippy::expect_used,
123+
reason = "callers opt into panic-on-invalid by calling _unwrap"
124+
)]
118125
fn stdout_str_unwrap(&self) -> &str {
119126
self.stdout_str().expect("stdout was not valid UTF-8")
120127
}
121128
/// stderr as `&str`, **panicking** if not valid UTF-8.
122-
#[allow(clippy::expect_used, reason = "callers opt into panic-on-invalid by calling _unwrap")]
129+
#[allow(
130+
clippy::expect_used,
131+
reason = "callers opt into panic-on-invalid by calling _unwrap"
132+
)]
123133
fn stderr_str_unwrap(&self) -> &str {
124134
self.stderr_str().expect("stderr was not valid UTF-8")
125135
}
126136

127137
/// stdout as an owned `String`, **panicking** if not valid UTF-8.
128-
#[allow(clippy::expect_used, reason = "callers opt into panic-on-invalid by calling _unwrap")]
138+
#[allow(
139+
clippy::expect_used,
140+
reason = "callers opt into panic-on-invalid by calling _unwrap"
141+
)]
129142
fn stdout_string_unwrap(&self) -> String {
130143
self.stdout_string().expect("stdout was not valid UTF-8")
131144
}
132145
/// stderr as an owned `String`, **panicking** if not valid UTF-8.
133-
#[allow(clippy::expect_used, reason = "callers opt into panic-on-invalid by calling _unwrap")]
146+
#[allow(
147+
clippy::expect_used,
148+
reason = "callers opt into panic-on-invalid by calling _unwrap"
149+
)]
134150
fn stderr_string_unwrap(&self) -> String {
135151
self.stderr_string().expect("stderr was not valid UTF-8")
136152
}

0 commit comments

Comments
 (0)