Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .config/determinator-live.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Which changed files can affect the live suites, read by `nemoclaw-build changes live`.
# A file inside a crate marks that crate changed; the command then checks whether the
# live build uses it: the packages whose tests run live, and the CLI and providers the
# bundle ships, with their development dependencies. Any other file outside a crate runs
# the live suites unless a rule below ignores it. Rules apply in order, before
# determinator's defaults.

# A workspace package under examples/: map it to its package.
[[path-rule]]
globs = ["examples/onboarding-tui/**"]
mark-changed = []
post-rule = "skip-rules"

# Inputs the live tests and the bundle read outside crates.
[[path-rule]]
globs = [
"examples/**",
"image/**",
"runtimes/**",
"schemas/**",
"versions.json",
"rust-toolchain.toml",
".config/nextest.toml",
".github/actions/**",
".github/workflows/live-*.yml",
]
mark-changed = "all"

# Not read by the live tests, the bundle, or their workflows.
[[path-rule]]
globs = [
"docs/**",
"fern/**",
"tools/**",
".github/**",
".config/**",
".agents/**",
".claude/**",
"deny.toml",
".pre-commit-config.yaml",
"AGENTS.md",
"WRITING.md",
]
mark-changed = []
32 changes: 28 additions & 4 deletions .github/workflows/live-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ name: Live / Docker
on:
push:
# Dispatch needs this file on the default branch; push a
# run-live-docker/ branch to run it before merging.
# run-live-docker/ branch to run it outside a pull request.
branches: [v1, run-live-docker/**]
# Pull requests run the suite when they change its build or inputs; see
# docs/contributing/testing.md.
pull_request:
branches: [v1]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: live-docker-${{ github.ref }}
cancel-in-progress: false
group: live-docker-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
live-docker:
name: Live / Docker / ${{ matrix.platform }}
Expand All @@ -37,27 +41,47 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The second commit is a pull request merge commit's base.
fetch-depth: 2
- name: Decide whether this change can affect the live suites
id: changes
env:
EVENT: ${{ github.event_name }}
run: |
# Pushes and manual runs always run the suite.
if [ "$EVENT" != pull_request ]; then
echo live=true >> "$GITHUB_OUTPUT"
exit 0
fi
base=$(git rev-parse HEAD^1)
cargo run --locked --quiet -p nemoclaw-build --no-default-features --target-dir target/ci-runner -- \
changes live --base "$base" >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/setup-rust
if: steps.changes.outputs.live == 'true'
with:
platform: ${{ matrix.platform }}
save-cache: "false"
- name: Build test executables
if: steps.changes.outputs.live == 'true'
run: cargo ci build
- name: Build and verify bundle
if: steps.changes.outputs.live == 'true'
run: cargo ci bundle
# The tests use local images by digest and load OCI archives, which need
# Docker's containerd image store; hosted runners use the classic store.
- name: Use the containerd image store
if: steps.changes.outputs.live == 'true'
run: |
config=/etc/docker/daemon.json
if [ -s "$config" ]; then current=$(sudo cat "$config"); else current='{}'; fi
printf '%s' "$current" | jq '.features["containerd-snapshotter"] = true' | sudo tee "$config" >/dev/null
sudo systemctl restart docker
docker info --format '{{json .DriverStatus}}' | grep -q io.containerd.snapshotter.v1
- name: Run Docker live tests
if: steps.changes.outputs.live == 'true'
run: cargo ci live-docker
- name: Upload live test results
if: always()
if: always() && steps.changes.outputs.live == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: live-docker-${{ matrix.platform }}-${{ github.run_attempt }}
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/live-kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ name: Live / Kind
on:
push:
# Dispatch needs this file on the default branch; push a
# run-live-kind/ branch to run it before merging.
# run-live-kind/ branch to run it outside a pull request.
branches: [v1, run-live-kind/**]
# Pull requests run the suite when they change its build or inputs; see
# docs/contributing/testing.md.
pull_request:
branches: [v1]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: live-kind-${{ github.ref }}
cancel-in-progress: false
group: live-kind-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
live-kind:
name: Live / Kind / ${{ matrix.platform }}
Expand All @@ -37,27 +41,47 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The second commit is a pull request merge commit's base.
fetch-depth: 2
- name: Decide whether this change can affect the live suites
id: changes
env:
EVENT: ${{ github.event_name }}
run: |
# Pushes and manual runs always run the suite.
if [ "$EVENT" != pull_request ]; then
echo live=true >> "$GITHUB_OUTPUT"
exit 0
fi
base=$(git rev-parse HEAD^1)
cargo run --locked --quiet -p nemoclaw-build --no-default-features --target-dir target/ci-runner -- \
changes live --base "$base" >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/setup-rust
if: steps.changes.outputs.live == 'true'
with:
platform: ${{ matrix.platform }}
save-cache: "false"
- name: Build test executables
if: steps.changes.outputs.live == 'true'
run: cargo ci build
- name: Build and verify bundle
if: steps.changes.outputs.live == 'true'
run: cargo ci bundle
# The agent image's metadata bundle is read from an OCI index, which
# Docker writes only with its containerd image store.
- name: Use the containerd image store
if: steps.changes.outputs.live == 'true'
run: |
config=/etc/docker/daemon.json
if [ -s "$config" ]; then current=$(sudo cat "$config"); else current='{}'; fi
printf '%s' "$current" | jq '.features["containerd-snapshotter"] = true' | sudo tee "$config" >/dev/null
sudo systemctl restart docker
docker info --format '{{json .DriverStatus}}' | grep -q io.containerd.snapshotter.v1
- name: Run Kubernetes live tests
if: steps.changes.outputs.live == 'true'
run: cargo ci live-kind
- name: Upload live test results
if: always()
if: always() && steps.changes.outputs.live == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: live-kind-${{ matrix.platform }}-${{ github.run_attempt }}
Expand Down
104 changes: 86 additions & 18 deletions crates/nemoclaw-build/src/changes.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//! Decide whether changes since a base revision can affect `CI / Images`.
//! Decide whether changes since a base revision can affect `CI / Images` or the
//! live suites.
//!
//! determinator maps changed files to workspace packages, using the rules in
//! [`RULES`] for files outside crates. guppy then simulates the image build:
//! nemoclaw-build without default features, including the dev-dependencies its
//! `bake::` tests compile, and the Ollama proxy with its defaults and tests.
//! The images are affected when a changed package is in that build, or when
//! its third-party dependencies or enabled features differ from the base.
//! determinator maps changed files to workspace packages, using each workflow's
//! path rules for files outside crates. guppy then simulates the workflow's build.
//! The image build is nemoclaw-build without default features, including the
//! dev-dependencies its `bake::` tests compile, and the Ollama proxy with its
//! defaults and tests. The live build is [`LIVE_PACKAGES`] with their defaults and
//! tests. A workflow is affected when a changed package is in its build, or when its
//! build's third-party dependencies or enabled features differ from the base.

use determinator::{Determinator, Utf8Paths0, rules::DeterminatorRules};
use guppy::{
Expand All @@ -22,6 +24,43 @@ use std::{collections::BTreeSet, fs, path::Path, process::Command};

/// Path rules for files outside crates, relative to the repository root.
pub const RULES: &str = ".config/determinator-images.toml";
/// The live suites' path rules.
pub const LIVE_RULES: &str = ".config/determinator-live.toml";
/// Packages whose tests run in the live suites, and the CLI and providers the
/// bundle they test ships.
pub const LIVE_PACKAGES: [&str; 8] = [
"nemoclaw-build",
"nemoclaw-cli",
"nemoclaw-e2e",
"nemoclaw-provider",
"nemoclaw-runtime",
"nemoclaw-sdk",
"openshell-provider",
"fabric-provider",
];

/// A CI workflow whose steps run only when a change can affect them.
#[derive(Clone, Copy)]
pub enum Workflow {
/// `CI / Images`.
Images,
/// `Live / Docker` and `Live / Kind`.
Live,
}
impl Workflow {
fn rules(self) -> &'static str {
match self {
Self::Images => RULES,
Self::Live => LIVE_RULES,
}
}
fn subject(self) -> &'static str {
match self {
Self::Images => "image",
Self::Live => "live",
}
}
}

type Result<T> = std::result::Result<T, String>;

Expand All @@ -35,15 +74,22 @@ pub struct Decision {
///
/// Any failure to analyze the change runs the checks rather than skipping them.
pub fn images(root: &Path, base: &str) -> Decision {
analyze(root, base).unwrap_or_else(|error| Decision {
decide(root, base, Workflow::Images)
}

/// Decide for `workflow`; any failure to analyze the change runs it.
pub fn decide(root: &Path, base: &str, workflow: Workflow) -> Decision {
analyze(root, base, workflow).unwrap_or_else(|error| Decision {
run: true,
reason: format!(
"could not analyze changes since {base} ({error}); running the image checks"
"could not analyze changes since {base} ({error}); running the {} checks",
workflow.subject()
),
})
}

fn analyze(root: &Path, base: &str) -> Result<Decision> {
fn analyze(root: &Path, base: &str, workflow: Workflow) -> Result<Decision> {
let rules_path = workflow.rules();
let base = String::from_utf8(git(
root,
&["rev-parse", "--verify", &format!("{base}^{{commit}}")],
Expand All @@ -57,9 +103,10 @@ fn analyze(root: &Path, base: &str) -> Result<Decision> {
&["diff", "-z", "--name-only", "--no-renames", &base, "HEAD"],
)?;
let paths = Utf8Paths0::from_bytes(changed).map_err(|_| "a changed path is not UTF-8")?;
let rules = fs::read_to_string(root.join(rules_path))
.map_err(|e| format!("cannot read {rules_path}: {e}"))?;
let rules =
fs::read_to_string(root.join(RULES)).map_err(|e| format!("cannot read {RULES}: {e}"))?;
let rules = DeterminatorRules::parse(&rules).map_err(|e| format!("invalid {RULES}: {e}"))?;
DeterminatorRules::parse(&rules).map_err(|e| format!("invalid {rules_path}: {e}"))?;

let new = graph(root)?;
let base_tree = tempfile::tempdir().map_err(|e| e.to_string())?;
Expand All @@ -72,31 +119,39 @@ fn analyze(root: &Path, base: &str) -> Result<Decision> {
let mut determinator = Determinator::new(&old, &new);
determinator
.set_rules(&rules)
.map_err(|e| format!("invalid {RULES}: {e}"))?;
.map_err(|e| format!("invalid {rules_path}: {e}"))?;
determinator.add_changed_paths(&paths);
let path_changed = determinator.compute().path_changed_set;

let build = image_build(&new)?;
let build_for = |graph| match workflow {
Workflow::Images => image_build(graph),
Workflow::Live => live_build(graph),
};
let subject = workflow.subject();
let build = build_for(&new)?;
for package in packages(&build).packages(DependencyDirection::Forward) {
if path_changed
.contains(package.id())
.map_err(|e| e.to_string())?
{
return Ok(Decision {
run: true,
reason: format!("{} is part of the image build and changed", package.name()),
reason: format!(
"{} is part of the {subject} build and changed",
package.name()
),
});
}
}
if summary(&build) != summary(&image_build(&old)?) {
if summary(&build) != summary(&build_for(&old)?) {
return Ok(Decision {
run: true,
reason: "the image build's dependencies or features changed".into(),
reason: format!("the {subject} build's dependencies or features changed"),
});
}
Ok(Decision {
run: false,
reason: format!("no image inputs changed since {base}"),
reason: format!("no {subject} inputs changed since {base}"),
})
}

Expand Down Expand Up @@ -143,6 +198,19 @@ fn image_build(graph: &PackageGraph) -> Result<CargoSet<'_>> {
.map_err(|e| e.to_string())
}

fn live_build(graph: &PackageGraph) -> Result<CargoSet<'_>> {
let initials = graph
.resolve_workspace_names(LIVE_PACKAGES)
.map_err(|e| format!("workspace lacks a live package: {e}"))?
.to_feature_set(StandardFeatures::Default);
CargoSet::new(
initials,
graph.feature_graph().resolve_none(),
&CargoOptions::new(),
)
.map_err(|e| e.to_string())
}

fn packages<'g>(build: &CargoSet<'g>) -> PackageSet<'g> {
build
.target_features()
Expand Down
11 changes: 8 additions & 3 deletions crates/nemoclaw-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ enum Action {
enum ChangedWorkflow {
/// `CI / Images`.
Images,
/// `Live / Docker` and `Live / Kind`.
Live,
}
#[cfg(feature = "sdk")]
#[derive(Subcommand)]
Expand Down Expand Up @@ -476,10 +478,13 @@ async fn main() -> Result<()> {
.map_err(Into::into);
}
if let Action::Changes { workflow, base } = &cli.command {
let ChangedWorkflow::Images = workflow;
let decision = nemoclaw_build::changes::images(Path::new("."), base);
let (workflow, name) = match workflow {
ChangedWorkflow::Images => (nemoclaw_build::changes::Workflow::Images, "images"),
ChangedWorkflow::Live => (nemoclaw_build::changes::Workflow::Live, "live"),
};
let decision = nemoclaw_build::changes::decide(Path::new("."), base, workflow);
eprintln!("{}", decision.reason);
println!("images={}", decision.run);
println!("{name}={}", decision.run);
return Ok(());
}
let pins: Pins = serde_json::from_slice(&fs::read("versions.json")?)?;
Expand Down
Loading