From 335dcef3dc81b8a1a1c0aa223a3214af656c72b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Wed, 11 Aug 2021 18:11:27 +0100 Subject: [PATCH 1/6] Switch to Github Actions --- .github/pull_request_template.md | 4 ++++ .github/workflows/test.yml | 41 ++++++++++++++++++++++++++++++++ .travis.yml | 10 -------- bors.toml | 3 +++ 4 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 bors.toml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..906a912 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,4 @@ +- [ ] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). +- [ ] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. +--- + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..57b318b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +on: push +name: Run tests +jobs: + # The `ci-result` job doesn't actually test anything - it just aggregates the + # overall build status for bors, otherwise our bors.toml would need an entry + # for each individual job produced by the job-matrix. + # + # Ref: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149 + # + # ALL THE SUBSEQUENT JOBS NEED THEIR `name` ADDED TO THE `needs` SECTION OF THIS JOB! + ci-result: + name: ci result + runs-on: ubuntu-latest + needs: + - geocoding + steps: + - name: Mark the job as a success + if: success() + run: exit 0 + - name: Mark the job as a failure + if: "!success()" + run: exit 1 + + geocoding: + name: geocoding + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]')" + defaults: + run: + working-directory: . + strategy: + matrix: + container_image: ["georust/geo-ci:rust-1.50", "georust/geo-ci:rust-1.51"] + container: + image: ${{ matrix.container_image }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - run: cargo install cargo-all-features + - run: cargo build-all-features + - run: cargo test-all-features diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f0d1274..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly - -matrix: - fast_finish: true - -cache: cargo diff --git a/bors.toml b/bors.toml new file mode 100644 index 0000000..bfa4661 --- /dev/null +++ b/bors.toml @@ -0,0 +1,3 @@ +status = [ + "ci result", +] From c704fad99545e1eab0bcc6b345104d3f31ec5bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Wed, 11 Aug 2021 18:23:53 +0100 Subject: [PATCH 2/6] Bump http libraries --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 21f5b10..fab6390 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ geo-types = "0.6" num-traits = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -reqwest = { version = "0.10", default-features = false, features = ["blocking", "json"] } -hyper = "0.13.6" +reqwest = { version = "0.11", default-features = false, features = ["blocking", "json"] } +hyper = "0.14.11" chrono = { version = "0.4", features = ["serde"] } [features] From 67c35535a82b56aeae89f6422c5ceff89033b6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 12 Aug 2021 11:14:49 +0100 Subject: [PATCH 3/6] Enable default-tls for reqwest so our https calls work --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fab6390..f4e2a57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ geo-types = "0.6" num-traits = "0.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -reqwest = { version = "0.11", default-features = false, features = ["blocking", "json"] } +reqwest = { version = "0.11", default-features = false, features = ["default-tls", "blocking", "json"] } hyper = "0.14.11" chrono = { version = "0.4", features = ["serde"] } From 38b3e27184f395ffceb08861f5ab8193288e4a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 12 Aug 2021 11:28:41 +0100 Subject: [PATCH 4/6] Fix tests By switching to assert + contains, we're reducing the risk of updates to the results randomly breaking our tests --- src/opencage.rs | 36 +++++++++++++++--------------------- src/openstreetmap.rs | 8 +++----- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/opencage.rs b/src/opencage.rs index b9a5bc7..c391b8e 100644 --- a/src/opencage.rs +++ b/src/opencage.rs @@ -209,7 +209,7 @@ impl<'a> Opencage<'a> { /// let res = oc.forward_full(&address, bbox).unwrap(); /// let first_result = &res.results[0]; /// // the first result is correct - /// assert_eq!(first_result.formatted, "UCL, 188 Tottenham Court Road, London W1T 7PQ, United Kingdom"); + /// assert!(first_result.formatted.contains("UCL, 188 Tottenham Court Road")); ///``` /// /// ``` @@ -237,10 +237,10 @@ impl<'a> Opencage<'a> { /// ); /// let res = oc.forward_full(&address, bbox).unwrap(); /// let first_result = &res.results[0]; - /// assert_eq!( - /// first_result.formatted, - /// "UCL, 188 Tottenham Court Road, London W1T 7PQ, United Kingdom" - /// ); + /// assert!( + /// first_result.formatted.contains( + /// "UCL, 188 Tottenham Court Road" + /// )); /// ``` pub fn forward_full( &self, @@ -680,10 +680,7 @@ mod test { }; let res = oc.forward_full(&address, bbox).unwrap(); let first_result = &res.results[0]; - assert_eq!( - first_result.formatted, - "UCL, 188 Tottenham Court Road, London W1T 7PQ, United Kingdom" - ); + assert!(first_result.formatted.contains("UCL")); } #[test] fn forward_full_test_floats() { @@ -695,10 +692,9 @@ mod test { ); let res = oc.forward_full(&address, bbox).unwrap(); let first_result = &res.results[0]; - assert_eq!( - first_result.formatted, - "UCL, 188 Tottenham Court Road, London W1T 7PQ, United Kingdom" - ); + assert!(first_result + .formatted + .contains("UCL, 188 Tottenham Court Road")); } #[test] fn forward_full_test_pointfrom() { @@ -710,10 +706,9 @@ mod test { ); let res = oc.forward_full(&address, bbox).unwrap(); let first_result = &res.results[0]; - assert_eq!( - first_result.formatted, - "UCL, 188 Tottenham Court Road, London W1T 7PQ, United Kingdom" - ); + assert!(first_result + .formatted + .contains("UCL, 188 Tottenham Court Road")); } #[test] fn forward_full_test_pointinto() { @@ -725,10 +720,9 @@ mod test { ); let res = oc.forward_full(&address, bbox).unwrap(); let first_result = &res.results[0]; - assert_eq!( - first_result.formatted, - "UCL, 188 Tottenham Court Road, London W1T 7PQ, United Kingdom" - ); + assert!(first_result + .formatted + .contains("Tottenham Court Road, London")); } #[test] fn forward_full_test_nobox() { diff --git a/src/openstreetmap.rs b/src/openstreetmap.rs index b223809..d361426 100644 --- a/src/openstreetmap.rs +++ b/src/openstreetmap.rs @@ -131,13 +131,13 @@ impl Openstreetmap { /// (-0.13806939125061035, 51.51989264641164), /// (-0.13427138328552246, 51.52319711775629), /// ); - /// let params = OpenstreetmapParams::new(&"University College London") + /// let params = OpenstreetmapParams::new(&"UCL CASA") /// .with_addressdetails(true) /// .with_viewbox(&viewbox) /// .build(); /// let res: OpenstreetmapResponse = osm.forward_full(¶ms).unwrap(); /// let result = res.features[0].properties.clone(); - /// assert!(result.display_name.contains("London Borough of Camden, London, Greater London")); + /// assert!(result.display_name.contains("Gordon Square")); /// ``` pub fn forward_full( &self, @@ -369,9 +369,7 @@ mod test { .build(); let res: OpenstreetmapResponse = osm.forward_full(¶ms).unwrap(); let result = res.features[0].properties.clone(); - assert!(result - .display_name - .contains("London Borough of Camden, London, Greater London")); + assert!(result.display_name.contains("Gordon Square")); assert_eq!(result.address.unwrap().city.unwrap(), "London"); } From ce08a396824ef8186a495bb1c0f79c6600f153df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 12 Aug 2021 12:49:56 +0100 Subject: [PATCH 5/6] Update changelog --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 23ed174..05fdf54 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ - Switch GeoAdmin API to WGS84 - +- Migrate to Github Actions +- Update tests and dependencies ## 0.3.1 From 45ca913a7d36d9d0a8b5a286258c74351d65f4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Thu, 12 Aug 2021 12:52:22 +0100 Subject: [PATCH 6/6] Update crate authors --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f4e2a57..9e59cb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "geocoding" description = "Geocoding library for Rust" version = "0.3.1" -authors = ["Stephan Hügel ", "Blake Grotewold "] +authors = ["The Georust Developers "] license = "MIT OR Apache-2.0" repository = "https://github.com/georust/geocoding" keywords = ["gecoding", "geo", "gis", "geospatial"]