use std::fs;
use chrono::Utc;
use uuid::Uuid;
use crate::schema::*;
use crate::session::SESSION;
pub fn write_report(){
let session=
SESSION.lock().unwrap();
let report=
MartianReport{
martian_version:
"0.3.0".into(),
mission:Mission{
id:Uuid::new_v4()
.to_string(),
entry_point:
"main.rs".into(),
adapter:
"martian-rust".into(),
adapter_version:
"0.1".into(),
status:
Status::Success,
started_at:
Utc::now()
.to_rfc3339(),
duration_ms:0.0,
environment:
Environment{
language:
"rust".into(),
language_version:
env!(
"CARGO_PKG_VERSION"
).into(),
platform:
std::env::consts::OS
.into(),
runtime:
Some(
"cargo".into()
)
}
},
execution:
session.nodes.clone()
};
fs::create_dir_all(
".martian"
).unwrap();
fs::write(
".martian/report.json",
serde_json::to_string_pretty(
&report
).unwrap()
).unwrap();
println!(
"wrote .martian/report.json"
);
}