diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 41a0062..4bd2e22 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,4 +29,4 @@ jobs: rosdep update rosdep resolve -q ament_cmake std_msgs example_interfaces | sed '/^#/d' | xargs sudo apt install -y - name: cargo test - run: . /ros_entrypoint.sh && cargo test + run: . /ros_entrypoint.sh && cargo test --all-features diff --git a/Cargo.toml b/Cargo.toml index 3326a52..7cfb8e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ name = "redf" version = "0.1.0" edition = "2021" default-run = "redf" -license = "Apache-2.0" license-file = "LICENSE" [[bin]] diff --git a/redf.schema.json b/redf.schema.json index 782bcf1..363aeab 100644 --- a/redf.schema.json +++ b/redf.schema.json @@ -78,7 +78,7 @@ "description", "message_type", "title", - "topic", + "topic_name", "type" ], "properties": { @@ -101,7 +101,7 @@ "title": { "type": "string" }, - "topic": { + "topic_name": { "type": "string" }, "type": { diff --git a/src/generate-schema.rs b/src/generate-schema.rs index f4658af..bca5b24 100644 --- a/src/generate-schema.rs +++ b/src/generate-schema.rs @@ -5,6 +5,32 @@ use schemars::schema_for; fn main() -> Result<(), Box> { let schema = schema_for!(Redf); - std::fs::write("redf.schema.json", serde_json::to_string_pretty(&schema)?)?; + let f = std::fs::OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open("redf.schema.json") + .unwrap(); + serde_json::to_writer_pretty(f, &schema).unwrap(); Ok(()) } + +#[cfg(test)] +mod test { + use super::*; + use std::iter::zip; + + #[test] + fn check_schema_changes() -> Result<(), String> { + let cur_schema_json = std::fs::read("redf.schema.json").unwrap(); + let schema = schema_for!(Redf); + let new_schema_json = serde_json::to_vec_pretty(&schema).unwrap(); + + if cur_schema_json.len() != new_schema_json.len() + || zip(cur_schema_json, new_schema_json).any(|(a, b)| a != b) + { + return Err(String::from("There are changes in the json schema, please run `cargo run -F json_schema --bin generate-schema` to regenerate it")); + } + Ok(()) + } +}