Skip to content

Commit

Permalink
Merge pull request #7 from nsat/ff-add-ghas
Browse files Browse the repository at this point in the history
[gha] add fmt, clippy and bloat actions
  • Loading branch information
spire-ffoston authored Oct 21, 2020
2 parents c62fe7c + 7d5b1a4 commit 08a99b6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/clippy-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:
types: [opened, synchronize, reopened]

name: Clippy and rustfmt Check
jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
override: true
- name: Check with rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
override: true
- name: Check with Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all --tests
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ libc = "0.2.71"
thiserror = "1.0"

[build-dependencies]
cc = "1.0"
cc = "1.0"

[dev-dependencies]
float-cmp = "0.8"
13 changes: 9 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ mod tests {
use super::*;

use chrono::Duration;
use float_cmp::approx_eq;

fn vecs_eq(l: &[f64; 3], r: &[f64; 3]) -> bool {
approx_eq!(f64, l[0], r[0]) && approx_eq!(f64, l[1], r[1]) && approx_eq!(f64, l[2], r[2])
}

#[test]
fn test_simple_propagation() -> Result<()> {
Expand All @@ -175,8 +180,8 @@ mod tests {
let s1 = tle.propagate_to(epoch)?;
let s2 = tle.propagate_to(epoch + Duration::hours(1))?;

assert_ne!(s1.position, s2.position);
assert_ne!(s1.velocity, s2.velocity);
assert!(!vecs_eq(&s1.position, &s2.position));
assert!(!vecs_eq(&s1.velocity, &s2.velocity));

Ok(())
}
Expand All @@ -192,8 +197,8 @@ mod tests {
let s1 = tle.propagate_to(epoch)?;
let s2 = tle.propagate_to(epoch - Duration::days(30))?;

assert_ne!(s1.position, s2.position);
assert_ne!(s1.velocity, s2.velocity);
assert!(!vecs_eq(&s1.position, &s2.position));
assert!(!vecs_eq(&s1.velocity, &s2.velocity));

Ok(())
}
Expand Down

0 comments on commit 08a99b6

Please sign in to comment.