diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml new file mode 100644 index 0000000..91130b0 --- /dev/null +++ b/.github/workflows/cargo.yml @@ -0,0 +1,43 @@ +name: cargo +on: [push] + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: rustup component add rustfmt + - run: cargo fmt --all --check + cargo: + strategy: + matrix: + task: ["clippy", "build", "test"] + feature_set: ["default", "no-std", "no-std-alloc", "no-std-alloc-serde", "no-serde"] + include: + - task: "clippy" + extra_flags: "--deny warnings" + - task: "build" + extra_flags: "" + - task: "test" + extra_flags: "" + - feature_set: "default" + feature_flags: "" + target_flags: "--all-targets" + - feature_set: "no-std" + feature_flags: "--no-default-features --features libm" + target_flags: "--lib" + - feature_set: "no-std-alloc" + feature_flags: "--no-default-features --features libm --features alloc" + target_flags: "--lib" + - feature_set: "no-std-alloc-serde" + feature_flags: "--no-default-features --features libm --features alloc --features serde" + target_flags: "--lib" + - feature_set: "no-serde" + feature_flags: "--no-default-features --features std" + target_flags: "--lib --tests --benches --example tle --example tle_afspc" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo ${{ matrix.task }} ${{ matrix.feature_flags }} ${{ matrix.target_flags }} -- ${{ matrix.extra_flags }} diff --git a/.github/workflows/ci_no_std.yml b/.github/workflows/ci_no_std.yml deleted file mode 100644 index 8091d31..0000000 --- a/.github/workflows/ci_no_std.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: no-std check -on: [push] - -jobs: - format_check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all --check - lib: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --no-default-features --features libm -- -D warnings - - uses: actions-rs/cargo@v1 - with: - command: build - args: --no-default-features --features libm - - tests: - needs: lib - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - args: --tests --no-default-features --features libm --features serde --features alloc \ No newline at end of file diff --git a/.github/workflows/ci_std.yml b/.github/workflows/ci_std.yml deleted file mode 100644 index a712bac..0000000 --- a/.github/workflows/ci_std.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: std check -on: [push] - -jobs: - format_check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all --check - lib: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings - - uses: actions-rs/cargo@v1 - with: - command: build - - tests: - needs: lib - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --tests -- -D warnings - - uses: actions-rs/cargo@v1 - with: - command: test - - examples: - needs: lib - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --examples -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index 7eb033d..033e9c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,28 +19,26 @@ categories = [ ] keywords = ["SGP4", "SDP4", "TLE", "OMM"] edition = "2021" +resolver = "2" [dependencies] -anyhow = { version = "1.0", default-features = false, optional = true } -chrono = { version = "0.4.38", default-features = false } -serde = { version = "1.0", default-features = false, optional = true } -serde_json = { version = "1.0", default-features = false, optional = true } -num-traits = { version = "0.2.19", default-features = false, optional = true } +chrono = {version = "0.4.38", default-features = false} +serde = {version = "1.0", default-features = false, optional = true} +serde_json = {version = "1.0", default-features = false, optional = true} +num-traits = {version = "0.2.19", default-features = false, optional = true} [dev-dependencies] +anyhow = {version = "1.0", default-features = false} criterion = "0.5.1" toml = "0.8.13" -ureq = { version = "2.9.7", features = ["json"] } -serde_json = { version = "1.0", default-features = false } -serde = { version = "1.0", default-features = false } -anyhow = { version = "1.0", default-features = false } +ureq = {version = "2.9.7", features = ["json"]} [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] [features] -default = ["alloc", "serde", "std"] -alloc = ["anyhow"] +default = ["alloc", "std", "serde"] +alloc = [] serde = [ "alloc", "chrono/serde", @@ -49,7 +47,7 @@ serde = [ "serde_json/alloc", ] std = ["alloc", "anyhow/std", "chrono/std", "serde?/std", "serde_json?/std"] -libm = ["num-traits/libm"] +libm = ["dep:num-traits", "num-traits/libm"] [[bench]] name = "propagate" diff --git a/benches/propagate.rs b/benches/propagate.rs index 2eb7a3f..6c09afe 100644 --- a/benches/propagate.rs +++ b/benches/propagate.rs @@ -1,10 +1,10 @@ use criterion::{criterion_group, criterion_main, Criterion}; -#[path = "../test_cases.rs"] +#[path = "../tests/test_cases.rs"] mod test_cases; use test_cases::*; pub fn criterion_benchmark(criterion: &mut Criterion) { - let test_cases: TestCases = toml::from_str(include_str!("../test_cases.toml")).unwrap(); + let test_cases: TestCases = toml::from_str(include_str!("../tests/test_cases.toml")).unwrap(); criterion.bench_function("propagate all", |b| { b.iter(|| { let mut predictions = Vec::new(); diff --git a/src/tle.rs b/src/tle.rs index 5a3ffc6..b1e694b 100644 --- a/src/tle.rs +++ b/src/tle.rs @@ -991,11 +991,11 @@ pub fn parse_3les(tles: &str) -> core::result::Result, Ok(elements_vec) } +#[cfg(feature = "serde")] #[cfg(test)] mod tests { use super::*; - #[cfg(feature = "serde")] fn assert_eq_f64(first: f64, second: f64) { if second == 0.0 { assert_eq!(first, 0.0); @@ -1004,7 +1004,6 @@ mod tests { } } - #[cfg(feature = "serde")] #[test] fn test_from_celestrak_omm() -> anyhow::Result<()> { let elements: Elements = serde_json::from_str( @@ -1069,7 +1068,6 @@ mod tests { } #[test] - #[cfg(feature = "alloc")] fn test_from_space_track_omm() -> anyhow::Result<()> { let elements: Elements = serde_json::from_str( r#"{"CCSDS_OMM_VERS":"2.0", @@ -1152,7 +1150,6 @@ mod tests { } #[test] - #[cfg(feature = "alloc")] fn test_from_celestrak_omms() -> anyhow::Result<()> { let elements_vec: [Elements; 2] = serde_json::from_str( r#"[{ @@ -1199,7 +1196,6 @@ mod tests { } #[test] - #[cfg(feature = "alloc")] fn test_from_tle() -> core::result::Result<(), Error> { let elements = Elements::from_tle( Some("ISS (ZARYA)".into()), @@ -1283,9 +1279,9 @@ mod tests { } #[test] - fn from_tle_rounding_error_prone_epoch() -> core::result::Result<(), Error> { + fn test_rounding_error_prone_epoch() -> core::result::Result<(), Error> { let elements = Elements::from_tle( - Some("ISS (ZARYA)".to_string()), + None, "1 25544U 98067A 23001.00031250 .00023190 00000-0 40700-3 0 9996".as_bytes(), "2 25544 51.6422 151.7482 0002260 30.8955 315.0781 15.50422841429866".as_bytes(), )?; @@ -1300,7 +1296,6 @@ mod tests { } #[test] - #[cfg(feature = "alloc")] fn test_parse_2les() -> core::result::Result<(), Error> { let elements_vec = parse_2les( "1 25544U 98067A 20194.88612269 -.00002218 00000-0 -31515-4 0 9992\n\ @@ -1313,7 +1308,6 @@ mod tests { } #[test] - #[cfg(feature = "alloc")] fn test_parse_3les() -> core::result::Result<(), Error> { let elements_vec = parse_3les( "ISS (ZARYA)\n\ diff --git a/tests/propagate.rs b/tests/propagate.rs index 4e7c553..a454f60 100644 --- a/tests/propagate.rs +++ b/tests/propagate.rs @@ -1,10 +1,10 @@ -#[path = "../test_cases.rs"] +#[path = "test_cases.rs"] mod test_cases; use test_cases::*; #[test] fn propagate() -> anyhow::Result<()> { - let test_cases: TestCases = toml::from_str(include_str!("../test_cases.toml")).unwrap(); + let test_cases: TestCases = toml::from_str(include_str!("test_cases.toml")).unwrap(); for test_case in test_cases.list.iter() { #[cfg(feature = "alloc")] let element = diff --git a/test_cases.rs b/tests/test_cases.rs similarity index 100% rename from test_cases.rs rename to tests/test_cases.rs diff --git a/test_cases.toml b/tests/test_cases.toml similarity index 100% rename from test_cases.toml rename to tests/test_cases.toml