Skip to content

Commit

Permalink
trying explicit cache image
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Mar 27, 2023
1 parent 69a31fc commit f869b49
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 19 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/push-dev-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions .github/workflows/push-latest-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

9 changes: 7 additions & 2 deletions git-hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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)
36 changes: 24 additions & 12 deletions services/gtfs/gtfs_bbox/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use geom::{Rect, Point};
use geom::{Point, Rect};

use std::path::PathBuf;

Expand All @@ -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<PathBuf> = 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(())
Expand All @@ -35,7 +35,7 @@ fn compute_bbox(gtfs_dirs: Vec<PathBuf>) -> Result<Rect> {
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(())
Expand All @@ -52,11 +52,11 @@ fn compute_bbox(gtfs_dirs: Vec<PathBuf>) -> Result<Rect> {
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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit f869b49

Please sign in to comment.