8000 chore!: rip old support for old harnesses/ dir by twitchyliquid64 · Pull Request #424 · gominimal/minimal · GitHub
[go: up one dir, main page]

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
4 changes: 2 additions & 2 deletions .minimal/minimal.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[upstream] # Source of software & tooling
repo = "https://github.com/gominimal/pkgs"
branch = "main"
locked_commit = "64e6866"
locked_commit = "560b0d09914758441770363ed60823dff6c921b4"

[harness]
[stack]
use = "rust"
runtime_packages = ["socat"]

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ remote-client = { version = "0.0.1", path = "crates/remote-client" }
sandbox2 = { version = "0.0.1", path = "crates/sandbox2" }
sessions = { version = "0.0.1", path = "crates/sessions" }

stdlib = { version = "0.0.15", path = "crates/stdlib" }
stdlib = { version = "0.0.16", path = "crates/stdlib" }
7 changes: 1 addition & 6 deletions crates/check/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ pub(crate) async fn check_stack(
use nickel_lang_core::program::{BuilderError, ProgramBuilder};
use nickel_lang_core::{error::NullReporter, eval::cache::CacheImpl, program::Program};

// TODO: Transitioning from 'harness' => 'stack', remove after May 2026
let entry_file = if stacks_dir.join(&stack).join("harness.ncl").exists() {
stacks_dir.join(&stack).join("harness.ncl")
} else {
stacks_dir.join(&stack).join("stack.ncl")
};
let entry_file = stacks_dir.join(&stack).join("stack.ncl");

let program_res: Result<Program<CacheImpl>, _> = ProgramBuilder::new()
.add_source(
Expand Down
30 changes: 6 additions & 24 deletions crates/decode/src/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,6 @@ impl Loader {
}
}
src.push_str("\tstacks = [\n");
// TODO: Remove after May 2026 (harnesses kept for compatibility).
match std::fs::read_dir(layer_dir.as_ref().join("harnesses")) {
Err(e) => {
if e.kind() != std::io::ErrorKind::NotFound {
return Err(e.into());
}
}
Ok(d) => {
for e in d {
let e = e?;
if e.file_type()?.is_dir() {
src.push_str(" import \"");
src.push_str(e.path().to_str().unwrap());
src.push_str("/harness.ncl\",\n");
}
}
}
}
match std::fs::read_dir(layer_dir.as_ref().join("stacks")) {
Err(e) => {
if e.kind() != std::io::ErrorKind::NotFound {
Expand Down Expand Up @@ -572,7 +554,7 @@ mod tests {
let temp_dir = tempfile::tempdir().unwrap();
std::fs::create_dir(temp_dir.path().join("packages")).unwrap();
std::fs::create_dir(temp_dir.path().join("profiles")).unwrap();
std::fs::create_dir(temp_dir.path().join("harnesses")).unwrap();
std::fs::create_dir(temp_dir.path().join("stacks")).unwrap();

// Create multiple packages
for pkg_name in &["package-a", "package-b", "package-c"] {
Expand Down Expand Up @@ -609,15 +591,15 @@ mod tests {
},
)
.unwrap();
// Make a harness called rust
let harness_dir = temp_dir.path().join("harnesses").join("rust");
// Make a stack called rust
let harness_dir = temp_dir.path().join("stacks").join("rust");
std::fs::create_dir(&harness_dir).unwrap();
std::fs::write(
harness_dir.join("harness.ncl"),
harness_dir.join("stack.ncl"),
indoc! {
"
let {harness, ..} = import \"minimal.ncl\" in
harness {
let {stack, ..} = import \"minimal.ncl\" in
stack {
name = \"rust\"
}
"
Expand Down
92 changes: 0 additions & 92 deletions crates/decode/src/stacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,98 +556,6 @@ mod tests {
use crate::load::*;
use indoc::indoc;

#[test]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This duped another test exactly, except just using harness{} instead of stack{}, so it doesnt reduce coverage to remove entirely.

fn parse_harness_syntax() {
let (term, mut program, _origin, _target) = Loader::new(
indoc! {
"
let {harness, ..} = import \"minimal.ncl\" in
harness {
name = \"rust\",

build_packages = [\"gcc\", \"rust\", \"binutils\"],
build_cmd = \"cargo build --release\",
build_env_vars.CC = \"gcc\",

matches_project_if_any = [{
file_regexes = {
\"Cargo.toml\" = \"*\",
},

file_predicates = {
\"Cargo.toml\" = \".workspace.dependencies.dirs == '6'\",
},

build_package_if_any.\"openssl\" = [
{
file_predicates.\"Cargo.toml\" = \".workspace.dependencies.reqwest.features | contains(\\\"native-tls\\\")\",
}
],
}],
matches_project_priority = 1,
}
"
}
.to_string(),None,
&LoadOptions::for_test(),
)
.unwrap_or_else(|e| {
e.report_to_stderr();
panic!("load failed");
})
.finish()
.unwrap_or_else(|e| {
e.report_to_stderr();
panic!("finish failed");
});

let p = Stack::from_term(&term, &mut program).unwrap();

assert_eq!(
p,
Stack {
name: "rust".to_string(),
build_packages: vec![
"gcc".to_string(),
"rust".to_string(),
"binutils".to_string()
],
build_cmds: Some(vec![vec![
"cargo".to_string(),
"build".to_string(),
"--release".to_string()
]]),
build_env_vars: IndexMap::from_iter([(
"CC".to_string(),
EnvVarValue::Value("gcc".to_string())
)]),
matches_project_if_any: Some(vec![StackMatcher {
file_regexes: [("Cargo.toml".to_string(), "*".to_string())].into(),
file_predicates: [(
"Cargo.toml".to_string(),
".workspace.dependencies.dirs == '6'".to_string()
)]
.into(),
build_package_matchers: [(
"openssl".to_string(),
vec![PackageMatcherPredicate {
file_predicates: [(
"Cargo.toml".to_string(),
".workspace.dependencies.reqwest.features | contains(\"native-tls\")".to_string()
)]
.into(),
..Default::default()
}]
)]
.into(),
runtime_package_matchers: Default::default(),
}]),
matches_project_priority: 1,
..Default::default()
}
)
}

#[test]
fn parse() {
let (term, mut program, _origin, _target) = Loader::new(
Expand Down
2 changes: 2 additions & 0 deletions crates/mfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ pub struct File {
#[serde(default, alias = "default")]
pub defaults: Defaults,
/// The stack configured on this repository, if any.
///
/// TODO: Remove `harness` alias after July 2026.
#[serde(default, alias = "harness")]
pub stack: Option<Stack>,

Expand Down
7 changes: 1 addition & 6 deletions crates/minimal/src/cmd_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ pub async fn cmd_check(args: CheckArgs, ctx: &mut Context) -> Result<(), Error>
None
},
if args.kind.check_stacks() {
// TODO: Remove after May 2026.
if upstream_dir.join("harnesses").exists() {
Some(upstream_dir.join("harnesses"))
} else {
Some(upstream_dir.join("stacks"))
}
Some(upstream_dir.join("stacks"))
} else {
None
},
Expand Down
1 change: 1 addition & 0 deletions crates/minimal/src/cmd_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub async fn cmd_update(_args: UpdateArgs, ctx: &mut Context) -> Result<(), Erro
.map_err(|e| Error::Other(anyhow::Error::from(e)))?;

let mut did_upgrade_fmt = false;
// TODO: Remove after June 2026.
if let Some(t) = doc.remove("harness") {
println!("Renamed `[harness]` to its new name `[stack]`");
doc.insert("stack", t);
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stdlib"
version = "0.0.15"
version = "0.0.16"
rust-version = "1.91"
license = "MIT OR Apache-2.0"
edition.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions crates/stdlib/minimal-ncl/minimal.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ let CmdSpec = std.contract.any_of [
matches_project_if_any | Array StackMatcherEntry | optional,
matches_project_priority | Number | optional,
},
# TODO: Remove after May 2026.
harness | Dyn -> Stack | doc "Constructs a stack." =
fun spec => spec | Stack,
stack | Dyn -> Stack | doc "Constructs a stack." =
fun spec => spec | Stack,

Expand Down
0