diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d59fa35..9aa04ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,8 @@ -on: push +on: + push: + pull_request: + workflow_dispatch: + name: Run tests jobs: # The `ci-result` job doesn't actually test anything - it just aggregates the @@ -30,20 +34,44 @@ jobs: working-directory: . strategy: matrix: - container_image: + toolchain: # We aim to support rust-stable plus (at least) the prior 3 releases, # giving us about 6 months of coverage. # # Minimum supported rust version (MSRV) - - "georust/geo-ci:rust-1.67" - # Two most recent releases - we omit older ones for expedient CI - - "georust/geo-ci:rust-1.69" - - "georust/geo-ci:rust-1.70" - container: - image: ${{ matrix.container_image }} + - "1.67" + # Two recent releases - we omit older ones for expedient CI + - "1.80" + - "stable" steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Install stable + run: | + rustup toolchain install ${{ matrix.toolchain }} --no-self-update --profile minimal --component rust-src rustfmt clippy + + - name: Check with Rustfmt + run: cargo fmt --all --check + + - name: Build (--no-default-features) + run: cargo build --no-default-features + - name: Build (--all-features) + run: cargo build --all-features + - name: Run tests (--all-features) + run: cargo test --all-features + - name: Build + run: cargo build + - name: Run tests + run: cargo test + + - name: Check with Clippy (--no-default-features) + run: cargo clippy --tests --no-default-features -- -D warnings + - name: Check with Clippy (--all-features) + run: cargo clippy --tests --all-features -- -D warnings + - name: Check with Clippy + run: cargo clippy --tests -- -D warnings + - run: cargo build --no-default-features - run: cargo test --no-default-features - run: cargo build --all-features diff --git a/Cargo.toml b/Cargo.toml index 7b99786..2526b95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,4 +24,4 @@ serde = { version = "1.0", features = ["derive"], optional = true } [dev-dependencies] assert_approx_eq = "1" -geo = "0.27" +geo = "0.28" diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 1d4286a..cac3b09 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -13,16 +13,16 @@ macro_rules! consume { )) }}; ($xml:expr, $version:expr, $tagname:expr) => {{ - use crate::parser::create_context; use std::io::BufReader; + use $crate::parser::create_context; consume( &mut create_context(BufReader::new($xml.as_bytes()), $version), $tagname, ) }}; ($xml:expr, $version:expr, $tagname:expr, $allow_empty:expr) => {{ - use crate::parser::create_context; use std::io::BufReader; + use $crate::parser::create_context; consume( &mut create_context(BufReader::new($xml.as_bytes()), $version), $tagname, diff --git a/src/writer.rs b/src/writer.rs index 8fef2a5..8d31ec7 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -293,7 +293,11 @@ fn write_fix_if_exists(fix: &Option, writer: &mut EventWriter) Ok(()) } -fn write_track(version: GpxVersion, track: &Track, writer: &mut EventWriter) -> GpxResult<()> { +fn write_track( + version: GpxVersion, + track: &Track, + writer: &mut EventWriter, +) -> GpxResult<()> { write_xml_event(XmlEvent::start_element("trk"), writer)?; write_string_if_exists("name", &track.name, writer)?; write_string_if_exists("cmt", &track.comment, writer)?; @@ -310,7 +314,11 @@ fn write_track(version: GpxVersion, track: &Track, writer: &mut EventW Ok(()) } -fn write_route(version: GpxVersion, route: &Route, writer: &mut EventWriter) -> GpxResult<()> { +fn write_route( + version: GpxVersion, + route: &Route, + writer: &mut EventWriter, +) -> GpxResult<()> { write_xml_event(XmlEvent::start_element("rte"), writer)?; write_string_if_exists("name", &route.name, writer)?; write_string_if_exists("cmt", &route.comment, writer)?; @@ -354,11 +362,8 @@ fn write_waypoint( writer, )?; write_value_if_exists("ele", &waypoint.elevation, writer)?; - match version { - GpxVersion::Gpx10 => { - write_value_if_exists("speed", &waypoint.speed, writer)?; - } - _ => {} + if version == GpxVersion::Gpx10 { + write_value_if_exists("speed", &waypoint.speed, writer)?; } write_time_if_exists(&waypoint.time, writer)?; write_value_if_exists("geoidheight", &waypoint.geoidheight, writer)?; diff --git a/tests/gpx_write.rs b/tests/gpx_write.rs index 8ecdd7d..d035cfb 100644 --- a/tests/gpx_write.rs +++ b/tests/gpx_write.rs @@ -78,7 +78,7 @@ fn check_metadata_equal(reference_gpx: &Gpx, written_gpx: &Gpx) { check_links_equal(&reference.links, &written.links); } -fn check_links_equal(reference: &Vec, written: &Vec) { +fn check_links_equal(reference: &[Link], written: &[Link]) { assert_eq!(reference.len(), written.len()); for (r, w) in reference.iter().zip(written) { assert_eq!(r.href, w.href); @@ -98,7 +98,7 @@ fn check_points_equal(reference: &Gpx, written: &Gpx) { } } -fn check_waypoints_equal(reference: &Vec, written: &Vec) { +fn check_waypoints_equal(reference: &[Waypoint], written: &[Waypoint]) { assert_eq!(reference.len(), written.len()); for (r_wp, w_wp) in reference.iter().zip(written) { assert_eq!(r_wp.point(), w_wp.point());