Skip to content

Commit

Permalink
Various CI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarcireau committed May 25, 2024
1 parent 0371840 commit 82ec9fb
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 139 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
@@ -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 }}
49 changes: 0 additions & 49 deletions .github/workflows/ci_no_std.yml

This file was deleted.

65 changes: 0 additions & 65 deletions .github/workflows/ci_std.yml

This file was deleted.

22 changes: 10 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions benches/propagate.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
12 changes: 3 additions & 9 deletions src/tle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,11 +991,11 @@ pub fn parse_3les(tles: &str) -> core::result::Result<alloc::vec::Vec<Elements>,
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);
Expand All @@ -1004,7 +1004,6 @@ mod tests {
}
}

#[cfg(feature = "serde")]
#[test]
fn test_from_celestrak_omm() -> anyhow::Result<()> {
let elements: Elements = serde_json::from_str(
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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#"[{
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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(),
)?;
Expand All @@ -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\
Expand All @@ -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\
Expand Down
4 changes: 2 additions & 2 deletions tests/propagate.rs
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 82ec9fb

Please sign in to comment.