diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7a29640aa..624bb44af 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -14,7 +14,7 @@ jobs: - uses: earthly/actions-setup@v1 - uses: actions/checkout@v2 - run: earthly --version - - run: earthly -P +build --area=Bogota + - run: earthly -P --ci --remote-cache=headwaymaps:earthly-cache +build --area=Bogota www_checks: defaults: run: @@ -55,3 +55,26 @@ jobs: - run: cargo clippy --all-features - run: cargo test --all-features - run: cargo build --release + gtfs_bbox: + defaults: + run: + working-directory: services/gtfs/gtfs_bbox + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + services/transitmux/target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - run: cargo fmt --all --check + - run: cargo clippy --all-features + - run: cargo test --all-features + - run: cargo build --release diff --git a/.github/workflows/push-dev-containers.yml b/.github/workflows/push-dev-containers.yml index 6fd6ec1b3..c83600a15 100644 --- a/.github/workflows/push-dev-containers.yml +++ b/.github/workflows/push-dev-containers.yml @@ -18,6 +18,6 @@ jobs: - name: Earthly version check run: earthly --version - name: Push dev images - run: earthly --push +images --tags=dev + run: earthly --ci --remote-cache=headwaymaps/ci:earthly-cache --push +images --tags=dev - name: Push dev branded images - run: earthly --push +images --branding=maps.earth --tags "maps-earth-dev" + run: earthly --ci --remote-cache=headwaymaps/ci:earthly-cache --push +images --branding=maps.earth --tags "maps-earth-dev" diff --git a/.github/workflows/push-latest-containers.yml b/.github/workflows/push-latest-containers.yml index 57a674758..0da64bf1a 100644 --- a/.github/workflows/push-latest-containers.yml +++ b/.github/workflows/push-latest-containers.yml @@ -20,7 +20,7 @@ jobs: - name: Earthly version check run: earthly --version - name: Push latest images - run: earthly --push +images --tags "latest ${{ github.ref_name }}" + run: earthly --ci --remote-cache=headwaymaps/ci:earthly-cache --push +images --tags "latest ${{ github.ref_name }}" - name: Push latest branded images - run: earthly --push +images --branding=maps.earth --tags "maps-earth-latest maps-earth-${{ github.ref_name }}" + run: earthly --ci --remote-cache=headwaymaps/ci:earthly-cache --push +images --branding=maps.earth --tags "maps-earth-latest maps-earth-${{ github.ref_name }}" diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit index 1f3e719be..39efc9753 100755 --- a/git-hooks/pre-commit +++ b/git-hooks/pre-commit @@ -17,5 +17,10 @@ set -e (cd services/transitmux && cargo fmt && - cargo clippy -- -D warnings && - cargo test) + cargo clippy --all-features -- -D warnings && + cargo test --all-features) + +(cd services/gtfs/gtfs_bbox && + cargo fmt && + cargo clippy --all-features -- -D warnings && + cargo test --all-features) diff --git a/services/gtfs/gtfs_bbox/src/main.rs b/services/gtfs/gtfs_bbox/src/main.rs index 4e6c06a33..3fc698979 100644 --- a/services/gtfs/gtfs_bbox/src/main.rs +++ b/services/gtfs/gtfs_bbox/src/main.rs @@ -1,4 +1,4 @@ -use geom::{Rect, Point}; +use geom::{Point, Rect}; use std::path::PathBuf; @@ -9,13 +9,13 @@ use serde::Deserialize; #[derive(Debug, Deserialize)] struct GTFSPoint { shape_pt_lon: f64, - shape_pt_lat: f64 + shape_pt_lat: f64, } fn main() -> Result<()> { let args = std::env::args().skip(1); let gtfs_dirs: Vec = args.map(PathBuf::from).collect(); - assert!(gtfs_dirs.len() > 0, "must specify gtfs dirs"); + assert!(!gtfs_dirs.is_empty(), "must specify gtfs dirs"); let bbox = compute_bbox(gtfs_dirs)?; println!("{}", bbox.bbox_fmt()); Ok(()) @@ -35,7 +35,7 @@ fn compute_bbox(gtfs_dirs: Vec) -> Result { match (&mut bbox, &mut first_point) { (Some(bbox), _) => bbox.expand(point), (None, None) => first_point = Some(point), - (None, Some(first_point)) => bbox = Some(Rect::new(point, *first_point)) + (None, Some(first_point)) => bbox = Some(Rect::new(point, *first_point)), } } Ok(()) @@ -52,11 +52,11 @@ fn compute_bbox(gtfs_dirs: Vec) -> Result { Ok(bbox.expect("bbox must be computed")) } - mod geom { #[derive(Debug, Clone, Copy, PartialEq)] pub struct Point { - x: f64, y: f64 + x: f64, + y: f64, } impl Point { @@ -74,7 +74,10 @@ mod geom { } #[derive(Debug, Clone, PartialEq)] - pub struct Rect { min: Point, max: Point } + pub struct Rect { + min: Point, + max: Point, + } impl Rect { pub fn new(a: Point, b: Point) -> Self { @@ -121,22 +124,31 @@ mod tests { #[test] fn test_1() { let actual = compute_bbox(vec!["data/mock_gtfs_1".into()]).unwrap(); - let expected = Rect::new(Point::new(-122.366249, 47.599201), Point::new(-122.281769, 47.64312)); + let expected = Rect::new( + Point::new(-122.366249, 47.599201), + Point::new(-122.281769, 47.64312), + ); assert_eq!(actual, expected); } #[test] fn test_2() { let actual = compute_bbox(vec!["data/mock_gtfs_2".into()]).unwrap(); - let expected = Rect::new(Point::new(-118.4467287702, 34.0636633497), Point::new(-118.4371927733, 34.0764316858)); + let expected = Rect::new( + Point::new(-118.4467287702, 34.0636633497), + Point::new(-118.4371927733, 34.0764316858), + ); assert_eq!(actual, expected); } #[test] fn test_1_and_2() { - let actual = compute_bbox(vec!["data/mock_gtfs_1".into(), "data/mock_gtfs_2".into()]).unwrap(); - let expected = Rect::new(Point::new(-122.366249, 34.0636633497), Point::new(-118.4371927733, 47.64312)); + let actual = + compute_bbox(vec!["data/mock_gtfs_1".into(), "data/mock_gtfs_2".into()]).unwrap(); + let expected = Rect::new( + Point::new(-122.366249, 34.0636633497), + Point::new(-118.4371927733, 47.64312), + ); assert_eq!(actual, expected); } } -