Skip to content

Commit

Permalink
Merge #50
Browse files Browse the repository at this point in the history
50: Switch to GH Actions, fix tests, update network libraries r=michaelkirk a=urschrei

Fixes #49 

Co-authored-by: Stephan Hügel <shugel@tcd.ie>
  • Loading branch information
bors[bot] and urschrei authored Aug 17, 2021
2 parents 4c9e960 + 45ca913 commit 1736b26
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -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.
---

41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Switch GeoAdmin API to WGS84
- <https://github.com/georust/geocoding/pull/43>
- Migrate to Github Actions
- Update tests and dependencies

## 0.3.1

Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "geocoding"
description = "Geocoding library for Rust"
version = "0.3.1"
authors = ["Stephan Hügel <urschrei@gmail.com>", "Blake Grotewold <hello@grotewold.me>"]
authors = ["The Georust Developers <admins@georust.org>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/georust/geocoding"
keywords = ["gecoding", "geo", "gis", "geospatial"]
Expand All @@ -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 = ["default-tls", "blocking", "json"] }
hyper = "0.14.11"
chrono = { version = "0.4", features = ["serde"] }

[features]
Expand Down
3 changes: 3 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
status = [
"ci result",
]
36 changes: 15 additions & 21 deletions src/opencage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
///```
///
/// ```
Expand Down Expand Up @@ -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<T, U>(
&self,
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down
8 changes: 3 additions & 5 deletions src/openstreetmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64> = osm.forward_full(&params).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<T>(
&self,
Expand Down Expand Up @@ -369,9 +369,7 @@ mod test {
.build();
let res: OpenstreetmapResponse<f64> = osm.forward_full(&params).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");
}

Expand Down

0 comments on commit 1736b26

Please sign in to comment.