diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d59fa35..ab80675 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,45 @@ 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 clippy + rustup component add 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/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)?;