All checks were successful
Run Check Script / check (pull_request) Successful in 1m59s
74 lines
2.4 KiB
Rust
74 lines
2.4 KiB
Rust
//! Render the example app's chart from its real `docker-compose.yml` and
|
|
//! validate it with actual `helm` — the chart our importer emits must be
|
|
//! something helm accepts and that renders to valid k8s. Skips when helm
|
|
//! isn't on PATH so CI without helm stays green.
|
|
|
|
use std::path::Path;
|
|
use std::process::Command;
|
|
|
|
use harmony_app::{ComposeApp, DeployConfig, chart::build_chart};
|
|
|
|
fn helm_present() -> bool {
|
|
Command::new("helm")
|
|
.arg("version")
|
|
.output()
|
|
.map(|o| o.status.success())
|
|
.unwrap_or(false)
|
|
}
|
|
|
|
#[test]
|
|
fn generated_chart_passes_helm_lint_and_template() {
|
|
if !helm_present() {
|
|
eprintln!("helm not on PATH — skipping chart validation");
|
|
return;
|
|
}
|
|
|
|
let app_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../examples/compose_java_react/app");
|
|
let app = ComposeApp::from_dir(&app_dir).expect("import compose");
|
|
let cfg = DeployConfig {
|
|
app_name: "timesheet".to_string(),
|
|
chart_version: "0.1.0".to_string(),
|
|
registry: "hub.example".to_string(),
|
|
project: "harmony".to_string(),
|
|
version: "0.1.0".to_string(),
|
|
storage_class: Some("cephfs".to_string()),
|
|
volume_size: "1Gi".to_string(),
|
|
replicas: 2,
|
|
rolling: true,
|
|
extra_env: vec![],
|
|
secret_file_mounts: vec![],
|
|
image_pull_secrets: vec![],
|
|
images: Default::default(),
|
|
};
|
|
|
|
let tmp = tempfile::tempdir().unwrap();
|
|
let chart = build_chart(&app, &cfg, tmp.path()).expect("render chart");
|
|
let chart = chart.to_str().unwrap();
|
|
|
|
let lint = Command::new("helm").args(["lint", chart]).output().unwrap();
|
|
assert!(
|
|
lint.status.success(),
|
|
"helm lint failed:\n{}",
|
|
String::from_utf8_lossy(&lint.stdout)
|
|
);
|
|
|
|
let out = Command::new("helm")
|
|
.args(["template", "timesheet", chart])
|
|
.output()
|
|
.unwrap();
|
|
assert!(
|
|
out.status.success(),
|
|
"helm template failed:\n{}",
|
|
String::from_utf8_lossy(&out.stderr)
|
|
);
|
|
let rendered = String::from_utf8_lossy(&out.stdout);
|
|
// Both services + the RWX PVC must survive a real render.
|
|
assert!(rendered.contains("kind: Deployment"), "{rendered}");
|
|
assert!(rendered.contains("kind: Service"), "{rendered}");
|
|
assert!(
|
|
rendered.contains("kind: PersistentVolumeClaim"),
|
|
"{rendered}"
|
|
);
|
|
assert!(rendered.contains("ReadWriteMany"), "{rendered}");
|
|
}
|