Skip to content

Commit 08a99b6

Browse files
Merge pull request #7 from nsat/ff-add-ghas
[gha] add fmt, clippy and bloat actions
2 parents c62fe7c + 7d5b1a4 commit 08a99b6

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

.github/workflows/clippy-fmt.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
pull_request:
3+
types: [opened, synchronize, reopened]
4+
5+
name: Clippy and rustfmt Check
6+
jobs:
7+
clippy_check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- uses: actions-rs/toolchain@v1
13+
with:
14+
toolchain: stable
15+
components: rustfmt
16+
override: true
17+
- name: Check with rustfmt
18+
uses: actions-rs/cargo@v1
19+
with:
20+
command: fmt
21+
args: --all -- --check
22+
23+
- uses: actions-rs/toolchain@v1
24+
with:
25+
toolchain: nightly
26+
components: clippy
27+
override: true
28+
- name: Check with Clippy
29+
uses: actions-rs/clippy-check@v1
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
args: --all-features --all --tests

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ libc = "0.2.71"
2121
thiserror = "1.0"
2222

2323
[build-dependencies]
24-
cc = "1.0"
24+
cc = "1.0"
25+
26+
[dev-dependencies]
27+
float-cmp = "0.8"

src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ mod tests {
163163
use super::*;
164164

165165
use chrono::Duration;
166+
use float_cmp::approx_eq;
167+
168+
fn vecs_eq(l: &[f64; 3], r: &[f64; 3]) -> bool {
169+
approx_eq!(f64, l[0], r[0]) && approx_eq!(f64, l[1], r[1]) && approx_eq!(f64, l[2], r[2])
170+
}
166171

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

178-
assert_ne!(s1.position, s2.position);
179-
assert_ne!(s1.velocity, s2.velocity);
183+
assert!(!vecs_eq(&s1.position, &s2.position));
184+
assert!(!vecs_eq(&s1.velocity, &s2.velocity));
180185

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

195-
assert_ne!(s1.position, s2.position);
196-
assert_ne!(s1.velocity, s2.velocity);
200+
assert!(!vecs_eq(&s1.position, &s2.position));
201+
assert!(!vecs_eq(&s1.velocity, &s2.velocity));
197202

198203
Ok(())
199204
}

0 commit comments

Comments
 (0)