Skip to content

Commit 360edea

Browse files
authored
Merge pull request #81 from AeroRust/ci-improvements
Ci improvements
2 parents 0779bba + e6fd438 commit 360edea

File tree

8 files changed

+96
-100
lines changed

8 files changed

+96
-100
lines changed

.github/workflows/ci.yml

+33-69
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- "v*"
79
pull_request:
810
branches:
911
- main
1012
schedule:
11-
- cron: '00 01 * * *'
13+
- cron: "00 01 * * *"
1214

1315
# Stops the running workflow of previous pushes
1416
concurrency:
@@ -22,33 +24,25 @@ jobs:
2224
name: Rustfmt & Clippy lints
2325

2426
runs-on: ubuntu-latest
25-
strategy:
26-
fail-fast: false
27+
# strategy:
28+
# fail-fast: false
2729
env:
2830
RUSTUP_MAX_RETRIES: 10
2931
CARGO_NET_RETRY: 10
3032
steps:
3133
- uses: actions/checkout@v3
3234

35+
# use nightly for rustfmt & clippy checks
3336
- name: Install Rust nightly toolchain
34-
uses: actions-rs/toolchain@v1
37+
uses: dtolnay/rust-toolchain@nightly
3538
with:
36-
toolchain: nightly
37-
profile: default
38-
override: true
3939
components: rustfmt, clippy
4040

4141
- name: Rust format
42-
uses: actions-rs/cargo@v1
43-
with:
44-
command: fmt
45-
args: --check
42+
run: cargo fmt --check
4643

4744
- name: Clippy lints
48-
uses: actions-rs/cargo@v1
49-
with:
50-
command: clippy
51-
args: --no-deps -- -D warnings
45+
run: cargo clippy --no-deps -- -D warnings
5246
test:
5347
name: Test
5448

@@ -65,50 +59,26 @@ jobs:
6559
steps:
6660
- uses: actions/checkout@v3
6761

68-
# We need to disable the existing toolchain to avoid updating rust-docs
69-
# which takes a long time. The fastest way to do this is to rename the
70-
# existing folder, as deleting it takes about as much time as not doing
71-
# anything and just updating rust-docs.
72-
- name: Rename existing rust toolchain (Windows)
73-
if: matrix.os == 'windows-latest'
74-
run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
75-
7662
- name: Install Rust toolchain
77-
uses: actions-rs/toolchain@v1
63+
uses: dtolnay/rust-toolchain@stable
7864
with:
79-
toolchain: ${{ matrix.rust }}
80-
profile: minimal
81-
override: true
8265
components: rust-src
66+
toolchain: ${{ matrix.rust }}
8367

8468
- name: Build
85-
uses: actions-rs/cargo@v1
86-
with:
87-
command: build
69+
run: cargo build
8870

8971
- name: Test --no-default-features
90-
uses: actions-rs/cargo@v1
91-
with:
92-
command: test
93-
args: --no-default-features
72+
run: cargo test --no-default-features
9473

9574
- name: Test --all-features
96-
uses: actions-rs/cargo@v1
97-
with:
98-
command: test
99-
args: --all-features
75+
run: cargo test --all-features
10076

10177
- name: Test (Release)
102-
uses: actions-rs/cargo@v1
103-
with:
104-
command: test
105-
args: --release --no-default-features
106-
78+
run: cargo test --release --no-default-features
79+
10780
- name: Test (Release) all-features
108-
uses: actions-rs/cargo@v1
109-
with:
110-
command: test
111-
args: --release --all-features
81+
run: cargo test --release --all-features
11282

11383
# Detect cases where documentation links don't resolve and such.
11484
doc:
@@ -118,37 +88,31 @@ jobs:
11888
RUSTDOCFLAGS: "-D warnings"
11989
steps:
12090
- uses: actions/checkout@v3
121-
- uses: actions-rs/toolchain@v1
91+
# Docs.rs uses nightly, which allows for easier syntax for linking to functions.
92+
- uses: dtolnay/rust-toolchain@nightly
12293
with:
123-
profile: minimal
124-
# Docs.rs uses nightly, which allows for easier syntax for linking to functions.
125-
toolchain: nightly
126-
override: true
94+
components: rust-docs
12795

12896
- name: Docs --all-features
129-
uses: actions-rs/cargo@v1
130-
with:
131-
command: doc
132-
args: --all-features --no-deps
97+
run: cargo doc --all-features --no-deps
13398

13499
- name: Docs --no-default-features
135-
uses: actions-rs/cargo@v1
136-
with:
137-
command: doc
138-
args: --no-default-features --no-deps
139-
100+
run: cargo doc --no-default-features --no-deps
140101
codecov:
141102
name: Generate code coverage
142103
runs-on: ubuntu-latest
104+
container:
105+
image: xd009642/tarpaulin:develop-nightly
106+
options: --security-opt seccomp=unconfined
143107
steps:
144-
- uses: actions/checkout@v3
145-
- uses: actions-rs/toolchain@v1
146-
with:
147-
toolchain: stable
148-
override: true
108+
- name: Checkout repository
109+
uses: actions/checkout@v3
149110

150-
- name: Run cargo-tarpaulin
151-
uses: actions-rs/tarpaulin@v0.1
111+
- name: Generate code coverage
112+
run: |
113+
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
152114
153115
- name: Upload to codecov.io
154-
uses: codecov/codecov-action@v1
116+
uses: codecov/codecov-action@v2
117+
with:
118+
fail_ci_if_error: true

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ approx = "0.5.1"
4040
doc-comment = "0.3"
4141
pretty_assertions = "1"
4242
quickcheck = { version = "1.0.3", default-features = false }
43+
# Criterion 0.4 will force us to use MSRV of 1.57!
4344
criterion = "0.3"
4445

4546
[features]

README.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,30 @@ Supported sentences:
1313
NMEA Standard Sentences
1414
- AAM
1515
- ALM
16-
- BOD (not supported by `Nmea::parse()`)
17-
- BWC (not supported by `Nmea::parse()`)
18-
- GBS (not supported by `Nmea::parse()`)
19-
- GGA
20-
- GLL
21-
- GNS
22-
- GSA
23-
- GSV
16+
- BOD
17+
- BWC
18+
- GBS
19+
- GGA *
20+
- GLL *
21+
- GNS *
22+
- GSA *
23+
- GSV *
2424
- MDA
2525
- MTW
2626
- MWV
27-
- RMC
28-
- VTG
27+
- RMC *
28+
- VTG *
2929

3030
Other Sentences
31-
- TXT
31+
- TXT *
3232

3333
Vendor Extensions
3434
- PGRMZ
3535

36+
**\* [`Nmea::parse()`] supported sentences**
37+
38+
[`Nmea::parse()`]: https://docs.rs/nmea/latest/nmea/struct.Nmea.html#method.parse
39+
3640
## How to contribute
3741

3842
We have an ongoing effort to support as many sentences from `NMEA 0183` as possible,
@@ -60,7 +64,7 @@ Add the `nmea` dependency in your `Cargo.toml`:
6064

6165
```toml
6266
[dependencies]
63-
nmea = "0.3"
67+
nmea = "0.4"
6468
```
6569

6670
### For `no_std`
@@ -70,7 +74,7 @@ just add the `nmea` crate without the default features:
7074

7175
```toml
7276
[dependencies]
73-
nmea = {version = "0.3", default-features = false}
77+
nmea = {version = "0.4", default-features = false}
7478
```
7579

7680
### For Rust edition 2015

src/lib.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,35 @@
44
//! to preserve state between receiving new NMEA sentence,
55
//! and [`parse_str()`] or [`parse_bytes()`] to parse sentences without state.
66
//!
7-
//! Units used: **degrees**, **knots**, **meters** for altitude
7+
//! Units used: **celsius**, **degrees**, **knots**, **meters** for altitude
88
//!
99
//! # Supported sentences:
1010
//!
1111
//! NMEA Standard Sentences
1212
//! - AAM
1313
//! - ALM
14-
//! - BOD (not supported by [`Nmea::parse()`])
15-
//! - BWC (not supported by `Nmea::parse()`)
16-
//! - GBS (not supported by [`Nmea::parse()`])
17-
//! - GGA
18-
//! - GLL
19-
//! - GNS
20-
//! - GSA
21-
//! - GSV
14+
//! - BOD
15+
//! - BWC
16+
//! - GBS
17+
//! - GGA *
18+
//! - GLL *
19+
//! - GNS *
20+
//! - GSA *
21+
//! - GSV *
2222
//! - MDA
2323
//! - MWV
24-
//! - RMC
25-
//! - VTG
24+
//! - RMC *
25+
//! - VTG *
2626
//!
2727
//! Other Sentences
28-
//! - TXT
28+
//! - TXT *
2929
//!
3030
//! Vendor Extension
3131
//! - PGRMZ
3232
//!
33+
//! **\* [`Nmea::parse()`] supported sentences**
34+
//!
35+
//!
3336
//! # Crate features
3437
//!
3538
//! - `default` features - `std`

src/parse.rs

+25
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,31 @@ pub enum ParseResult {
118118
Unsupported(SentenceType),
119119
}
120120

121+
impl From<&ParseResult> for SentenceType {
122+
fn from(parse_result: &ParseResult) -> Self {
123+
match parse_result {
124+
ParseResult::AAM(_) => SentenceType::AAM,
125+
ParseResult::ALM(_) => SentenceType::ALM,
126+
ParseResult::BOD(_) => SentenceType::BOD,
127+
ParseResult::BWC(_) => SentenceType::BWC,
128+
ParseResult::GBS(_) => SentenceType::GBS,
129+
ParseResult::GGA(_) => SentenceType::GGA,
130+
ParseResult::GLL(_) => SentenceType::GLL,
131+
ParseResult::GNS(_) => SentenceType::GNS,
132+
ParseResult::GSA(_) => SentenceType::GSA,
133+
ParseResult::GSV(_) => SentenceType::GSV,
134+
ParseResult::MDA(_) => SentenceType::MDA,
135+
ParseResult::MTW(_) => SentenceType::MTW,
136+
ParseResult::MWV(_) => SentenceType::MWV,
137+
ParseResult::RMC(_) => SentenceType::RMC,
138+
ParseResult::TXT(_) => SentenceType::TXT,
139+
ParseResult::VTG(_) => SentenceType::VTG,
140+
ParseResult::PGRMZ(_) => SentenceType::RMZ,
141+
ParseResult::Unsupported(sentence_type) => *sentence_type,
142+
}
143+
}
144+
}
145+
121146
/// Parse a NMEA 0183 sentence from bytes and extract data from it.
122147
///
123148
/// # Errors

src/parser.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,10 @@ impl<'a> Nmea {
262262
self.merge_txt_data(txt);
263263
Ok(SentenceType::TXT)
264264
}
265-
// ParseResult::BWC(_) | ParseResult::BOD(_) | ParseResult::GBS(_) => {
266-
// Err(Error::Unsupported(SentenceType::BWC))
267-
// }
268265
ParseResult::Unsupported(sentence_type) => Err(Error::Unsupported(sentence_type)),
269-
_ => Err(Error::Unsupported(SentenceType::BWC)),
266+
// any other implemented sentence which is not part of the `Nmea` parsing is unsupported
267+
// at this time being
268+
ref parse_result => Err(Error::Unsupported(parse_result.into())),
270269
}
271270
}
272271

src/sentences/alm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use super::utils::number;
4444
/// 16. Checksum
4545
///
4646
/// Fields 5 through 15 are dumped as raw hex.
47-
#[derive(Debug, Clone, Copy, PartialEq)]
47+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4848
pub struct AlmData {
4949
pub total_number_of_messages: Option<u16>,
5050
pub sentence_number: Option<u16>,

src/sentences/rmz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum PgrmzFixType {
2929
/// 4. Checksum
3030
///
3131
/// Example: `$PGRMZ,2282,f,3*21`
32-
#[derive(Debug, Clone, Copy, PartialEq)]
32+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3333
pub struct PgrmzData {
3434
/// Current altitude in feet
3535
pub altitude: u32,

0 commit comments

Comments
 (0)