Skip to content

Commit fcb10d9

Browse files
authored
Merge pull request #53 from stackhands/fix/eon-smoke-fixture
fix(ci): point the eOn smoke step at eOn 2.17.10
2 parents e6e74e3 + 1b73699 commit fcb10d9

3 files changed

Lines changed: 137 additions & 5 deletions

File tree

‎.github/workflows/ci_test.yml‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,28 @@ jobs:
291291
run: |
292292
set -euo pipefail
293293
BIN=./target/release/eb-stack
294-
# Drafts alone leave stack deps missing; exit non-zero is correct.
295-
# Still exercises parse + packaging_gate on the draft-PR snapshot.
294+
# Drafts alone leave stack deps missing, so recipe check must fail on
295+
# unresolved dependencies after parse and packaging_gate pass on the
296+
# draft-PR snapshot, with the drafts supplying their own packages.
297+
OUT=$(mktemp -d)
296298
if "$BIN" recipe check \
297-
--recipe fixtures/eon_core_rgpot/easyconfigs/e/eOn/eOn-2.17.2-foss-2026.1.eb \
299+
--recipe fixtures/eon_core_rgpot/easyconfigs/e/eOn/eOn-2.17.10-foss-2026.1.eb \
298300
--easyconfigs fixtures/eon_core_rgpot/easyconfigs \
299-
--require-configopt=-Dwith_rgpot=true; then
301+
--require-configopt=-Dwith_rgpot=true >"$OUT/check.out" 2>"$OUT/check.err"; then
300302
echo "expected recipe check to fail without robot deps" >&2
301303
exit 1
302304
fi
305+
cat "$OUT/check.err"
306+
if ! grep -qx 'error: recipe has [0-9][0-9]* unresolved dependencies' "$OUT/check.err"; then
307+
echo "expected recipe check to fail on unresolved dependencies only" >&2
308+
exit 1
309+
fi
310+
for draft in quill readcon-core rgpot; do
311+
if ! grep -q "\"runtime:$draft-" "$OUT/check.out"; then
312+
echo "expected the drafts to supply $draft" >&2
313+
exit 1
314+
fi
315+
done
303316
304317
portable-candidate:
305318
name: portable Linux candidate (no publication)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The CI smoke step on the eOn core fixture checks `eOn-2.17.10-foss-2026.1.eb`, the recipe the fixture holds, and passes only when `recipe check` fails on the stack dependencies the drafts leave out, with the drafts supplying quill, readcon-core and rgpot. It named the 2.17.2 recipe the fixture no longer has, so it passed on "No such file or directory" without checking anything. `tests/eon_core_rgpot.rs` runs the step as CI runs it.

‎tests/eon_core_rgpot.rs‎

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
use eb_stack::{
1414
check_recipe_deps, packaging_gate, parse_easyconfig_trees, resolve_easyconfig_file,
1515
};
16-
use std::path::PathBuf;
16+
use std::os::unix::fs::PermissionsExt;
17+
use std::path::{Path, PathBuf};
18+
use std::process::Command;
1719

1820
mod common;
1921

@@ -344,3 +346,119 @@ fn eon_core_recipe_copies_do_not_drift() {
344346
assert_eq!(canonical, copy, "{copy_rel} drifted from {canonical_rel}");
345347
}
346348
}
349+
350+
const SMOKE_STEP: &str = "recipe packaging gate on eOn core fixture";
351+
352+
/// The `run: |` script of the ci_test.yml step named `name`, dedented.
353+
fn ci_step(name: &str) -> String {
354+
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
355+
let ci = std::fs::read_to_string(manifest.join(".github/workflows/ci_test.yml"))
356+
.expect("read ci_test.yml");
357+
let header = format!("- name: {name}");
358+
let mut lines = ci
359+
.lines()
360+
.skip_while(|line| line.trim() != header)
361+
.skip(1)
362+
.peekable();
363+
assert_eq!(
364+
lines.next().map(str::trim),
365+
Some("run: |"),
366+
"ci_test.yml has no step {name:?} with a run block"
367+
);
368+
let indent = lines
369+
.peek()
370+
.map(|line| line.len() - line.trim_start().len())
371+
.expect("the run block has a body");
372+
lines
373+
.take_while(|line| line.trim().is_empty() || line.len() - line.trim_start().len() >= indent)
374+
.map(|line| format!("{}\n", line.get(indent..).unwrap_or("")))
375+
.collect()
376+
}
377+
378+
/// Run a CI step's script as the runner's bash does, with `BIN` set to `bin`
379+
/// instead of the release build.
380+
fn run_step(script: &str, bin: &Path) -> std::process::Output {
381+
let release = "BIN=./target/release/eb-stack\n";
382+
assert!(script.contains(release), "the step sets {release:?}");
383+
let quoted = bin.display().to_string().replace('\'', r"'\''");
384+
Command::new("bash")
385+
.arg("-ec")
386+
.arg(script.replace(release, &format!("BIN='{quoted}'\n")))
387+
.current_dir(env!("CARGO_MANIFEST_DIR"))
388+
.output()
389+
.expect("run bash")
390+
}
391+
392+
/// A smoke step that expects `recipe check` to fail passes on any error, so a
393+
/// recipe renamed under it leaves it passing on "No such file or directory".
394+
#[test]
395+
fn ci_smoke_step_names_paths_that_exist() {
396+
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
397+
let step = ci_step(SMOKE_STEP);
398+
let named: Vec<_> = step
399+
.split_whitespace()
400+
.filter(|word| word.starts_with("fixtures/"))
401+
.collect();
402+
assert!(!named.is_empty(), "the step names no fixture:\n{step}");
403+
for path in named {
404+
assert!(
405+
manifest.join(path).exists(),
406+
"{SMOKE_STEP:?} names {path}, which does not exist"
407+
);
408+
}
409+
}
410+
411+
/// The step expects `recipe check` to fail only because the drafts leave the
412+
/// stack's own dependencies unresolved. Run as CI runs it, it passes with
413+
/// eb-stack and fails when the check fails for any other reason.
414+
#[test]
415+
fn ci_smoke_step_accepts_only_the_unresolved_stack_dependencies() {
416+
let step = ci_step(SMOKE_STEP);
417+
let real = run_step(&step, Path::new(env!("CARGO_BIN_EXE_eb-stack")));
418+
assert!(
419+
real.status.success(),
420+
"the step fails with eb-stack:\n{}{}",
421+
String::from_utf8_lossy(&real.stdout),
422+
String::from_utf8_lossy(&real.stderr)
423+
);
424+
425+
let impostors = [
426+
(
427+
"a recipe that does not exist",
428+
"",
429+
"error: --recipe fixtures/eon_core_rgpot/easyconfigs/e/eOn/eOn-2.17.2-foss-2026.1.eb: No such file or directory (os error 2)",
430+
),
431+
(
432+
"a failed packaging gate",
433+
"",
434+
"error: packaging gate failed: configopts lack -Dwith_rgpot=true",
435+
),
436+
(
437+
"drafts that do not resolve",
438+
r#" "found": []"#,
439+
"error: recipe has 14 unresolved dependencies",
440+
),
441+
];
442+
let dir = tempfile::tempdir().expect("tempdir");
443+
let stubs: Vec<_> = impostors
444+
.iter()
445+
.enumerate()
446+
.map(|(i, (_, stdout, stderr))| {
447+
let stub = dir.path().join(format!("eb-stack-{i}"));
448+
std::fs::write(
449+
&stub,
450+
format!("#!/bin/sh\necho '{stdout}'\necho '{stderr}' >&2\nexit 1\n"),
451+
)
452+
.expect("write stub");
453+
std::fs::set_permissions(&stub, std::fs::Permissions::from_mode(0o755))
454+
.expect("chmod stub");
455+
stub
456+
})
457+
.collect();
458+
for ((why, _, _), stub) in impostors.iter().zip(&stubs) {
459+
assert!(
460+
!run_step(&step, stub).status.success(),
461+
"the step passes when recipe check fails on {why}"
462+
);
463+
}
464+
}

0 commit comments

Comments
 (0)