Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify CI, add Clippy, and bump geo #109

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ serde = { version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
assert_approx_eq = "1"
geo = "0.27"
geo = "0.28"
4 changes: 2 additions & 2 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 12 additions & 7 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ fn write_fix_if_exists<W: Write>(fix: &Option<Fix>, writer: &mut EventWriter<W>)
Ok(())
}

fn write_track<W: Write>(version: GpxVersion, track: &Track, writer: &mut EventWriter<W>) -> GpxResult<()> {
fn write_track<W: Write>(
version: GpxVersion,
track: &Track,
writer: &mut EventWriter<W>,
) -> 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)?;
Expand All @@ -310,7 +314,11 @@ fn write_track<W: Write>(version: GpxVersion, track: &Track, writer: &mut EventW
Ok(())
}

fn write_route<W: Write>(version: GpxVersion, route: &Route, writer: &mut EventWriter<W>) -> GpxResult<()> {
fn write_route<W: Write>(
version: GpxVersion,
route: &Route,
writer: &mut EventWriter<W>,
) -> 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)?;
Expand Down Expand Up @@ -354,11 +362,8 @@ fn write_waypoint<W: Write>(
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)?;
Expand Down
4 changes: 2 additions & 2 deletions tests/gpx_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Link>, written: &Vec<Link>) {
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);
Expand All @@ -98,7 +98,7 @@ fn check_points_equal(reference: &Gpx, written: &Gpx) {
}
}

fn check_waypoints_equal(reference: &Vec<Waypoint>, written: &Vec<Waypoint>) {
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());
Expand Down