Skip to content

Commit e3cbd2d

Browse files
committed
refactor: dogfood pipelines use rust.project() high-level API
1 parent 845e3a8 commit e3cbd2d

2 files changed

Lines changed: 31 additions & 49 deletions

File tree

.harmont/ci.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,26 @@
22
from __future__ import annotations
33

44
import harmont as hm
5-
from harmont.cache import CacheOnChange
65
from harmont.py.uv import UvProject
7-
from harmont.rust import RustToolchain
8-
9-
ALL_APT = (
10-
"curl",
11-
"ca-certificates",
12-
"build-essential",
13-
"pkg-config",
14-
"libssl-dev",
15-
"python3",
16-
"python3-venv",
17-
)
6+
from harmont.rust import RustProject
187

198

209
@hm.target()
2110
def shared_base() -> hm.Step:
22-
return hm.apt_base(packages=ALL_APT)
11+
return hm.apt_base(packages=(
12+
"curl",
13+
"ca-certificates",
14+
"build-essential",
15+
"pkg-config",
16+
"libssl-dev",
17+
"python3",
18+
"python3-venv",
19+
))
2320

2421

2522
@hm.target()
26-
def rust_project(shared_base: hm.Target[hm.Step]) -> RustToolchain:
27-
return hm.rust(path=".", base=shared_base)
23+
def rust_project(shared_base: hm.Target[hm.Step]) -> RustProject:
24+
return hm.rust.project(path=".", base=shared_base, test_flags=("--lib",))
2825

2926

3027
@hm.target()
@@ -42,20 +39,13 @@ def py_project(shared_base: hm.Target[hm.Step]) -> UvProject:
4239
],
4340
)
4441
def ci(
45-
rust_project: hm.Target[RustToolchain],
42+
rust_project: hm.Target[RustProject],
4643
py_project: hm.Target[UvProject],
4744
) -> tuple[hm.Step, ...]:
48-
warm = rust_project.warmup(cache=CacheOnChange(paths=("Cargo.lock",)))
4945
return (
50-
warm.sh(
51-
". $HOME/.cargo/env && cd . && cargo test --workspace --lib --locked --no-fail-fast",
52-
label=":rust: test",
53-
),
54-
warm.sh(
55-
". $HOME/.cargo/env && cd . && cargo clippy --workspace --tests --locked -- -D warnings",
56-
label=":rust: clippy",
57-
),
58-
rust_project.fmt(),
46+
rust_project.test,
47+
rust_project.clippy,
48+
rust_project.fmt,
5949
py_project.lint(),
6050
py_project.fmt(),
6151
py_project.typecheck(paths="harmont"),

.harmont/ci.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,33 @@ import {
33
push,
44
pullRequest,
55
aptBase,
6-
onChange,
76
type PipelineDefinition,
87
} from "harmont";
98
import { rust, py } from "harmont/toolchains";
109

11-
const ALL_APT = [
12-
"curl",
13-
"ca-certificates",
14-
"build-essential",
15-
"pkg-config",
16-
"libssl-dev",
17-
"python3",
18-
"python3-venv",
19-
] as const;
10+
const base = aptBase({
11+
packages: [
12+
"curl",
13+
"ca-certificates",
14+
"build-essential",
15+
"pkg-config",
16+
"libssl-dev",
17+
"python3",
18+
"python3-venv",
19+
],
20+
});
2021

21-
const base = aptBase({ packages: ALL_APT });
22-
const rustProject = rust({ path: ".", base });
22+
const rustProject = rust.project({ path: ".", base, testFlags: ["--lib"] });
2323
const pyProject = py.uv({ path: "dsls/harmont-py", base });
2424

25-
const warm = rustProject.warmup({ cache: onChange("Cargo.lock") });
26-
2725
const pipelines: PipelineDefinition[] = [
2826
{
2927
slug: "ci",
3028
triggers: [push({ branch: "main" }), pullRequest({ branches: ["main"] })],
3129
pipeline: pipeline(
32-
warm.sh(
33-
`. $HOME/.cargo/env && cd . && cargo test --workspace --lib --locked --no-fail-fast`,
34-
{ label: ":rust: test" },
35-
),
36-
warm.sh(
37-
`. $HOME/.cargo/env && cd . && cargo clippy --workspace --tests --locked -- -D warnings`,
38-
{ label: ":rust: clippy" },
39-
),
40-
rustProject.fmt(),
30+
rustProject.test,
31+
rustProject.clippy,
32+
rustProject.fmt,
4133
pyProject.lint(),
4234
pyProject.fmt(),
4335
pyProject.typecheck({ paths: "harmont" }),

0 commit comments

Comments
 (0)