diff --git a/.woodpecker.yml b/.woodpecker.yml index f670957..45bb910 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,91 +1,43 @@ pipeline: - # Download the cache from S3 - restore-cache: - image: plugins/s3-cache - pull: true - - endpoint: https://s3.roosens.me - root: build-cache/ - restore: true - - secrets: [ cache_s3_access_key, cache_s3_secret_key ] - - - # =====BUILDING===== build-frontend: image: node:15-alpine3.13 pull: true - group: build commands: - cd web - yarn install - yarn run build - build-backend: - image: chewingbever/fej-builder:latest - pull: true - group: build - environment: - - CARGO_HOME=.cargo - commands: - - cargo build - - - # =====TESTING===== - test-backend: - image: chewingbever/fej-builder:latest - environment: - - CARGO_HOME=.cargo - commands: - - cargo test - - - # =====LINTING===== lint-frontend: image: node:15-alpine3.13 - group: lint commands: - cd web - yarn run lint + # This doesn't require compiling anything lint-backend: image: chewingbever/fej-builder:latest - group: lint - environment: - - CARGO_HOME=.cargo + pull: true commands: - cargo fmt -- --check - # This is run here because it requires compilation - - cargo clippy --all-targets -- -D warnings - - # =====REBUILD & FLUSH CACHE===== - rebuild-cache: - image: plugins/s3-cache + # publish-builder: + # image: plugins/docker + # repo: chewingbever/fej-builder + # dockerfile: docker/Dockerfile.builder + # tag: [ latest ] + # secrets: [ docker_username, docker_password ] + # when: + # branch: develop + # event: push - endpoint: https://s3.roosens.me - root: build-cache/ - rebuild: true - mount: - - target - - .cargo - - web/node_modules + # Backend cicd jobs are disabled until we can figure out a way to cache stuff + # test-backend: + # image: chewingbever/fej-builder:latest + # # Always update the builder image + # pull: true + # commands: + # - cargo test - secrets: [ cache_s3_access_key, cache_s3_secret_key ] - # Push the cache, even on failure - when: - status: [ success, failure ] + # TODO build dev & rel image, deploy these images - flush-cache: - image: plugins/s3-cache - - endpoint: https://s3.roosens.me - root: build-cache/ - flush: true - # Delete cache older than 30 days (might lower this) - flush_age: 30 - - secrets: [ cache_s3_access_key, cache_s3_secret_key ] - # Push the cache, even on failure - when: - status: [ success, failure ] +# branches: [ master, develop ] diff --git a/src/fej/ivago/pickup_time.rs b/src/fej/ivago/pickup_time.rs index 19031fb..f70cbcf 100644 --- a/src/fej/ivago/pickup_time.rs +++ b/src/fej/ivago/pickup_time.rs @@ -16,7 +16,10 @@ impl PickupTime { /// * `date` - Date of pickup time /// * `label` - Type of trash pub fn new(date: BasicDate, label: String) -> PickupTime { - PickupTime { date, label } + PickupTime { + date: date, + label: label, + } } } diff --git a/src/fej/ivago/street.rs b/src/fej/ivago/street.rs index 4ba45cb..2f30f06 100644 --- a/src/fej/ivago/street.rs +++ b/src/fej/ivago/street.rs @@ -18,7 +18,10 @@ impl Street { // This constructor just makes my life a bit easier during testing #[cfg(test)] fn new(name: String, city: String) -> Street { - Street { name, city } + Street { + name: name, + city: city, + } } } diff --git a/src/populate_ivago.rs b/src/populate_ivago.rs index 0886551..9dfc876 100644 --- a/src/populate_ivago.rs +++ b/src/populate_ivago.rs @@ -8,15 +8,12 @@ fn main() { let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); let db_conn = PgConnection::establish(&database_url) - .unwrap_or_else(|_| panic!("Error connecting to {}", database_url)); + .expect(&format!("Error connecting to {}", database_url)); // Doing this linearly is good enough I'd say for c in ABC.chars() { if let Ok(streets) = search_streets(&c.to_string()) { - insert_into(ivago_streets) - .values(streets) - .execute(&db_conn) - .expect("Failed to insert rows."); + insert_into(ivago_streets).values(streets).execute(&db_conn); } } } diff --git a/src/server/main.rs b/src/server/main.rs index bfe4fef..2a5bd2f 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -23,9 +23,9 @@ use rocket_contrib::databases::diesel; #[cfg(feature = "frontend")] use rocket_contrib::serve::StaticFiles; -pub struct Cors; +pub struct CORS; -impl Fairing for Cors { +impl Fairing for CORS { fn info(&self) -> Info { Info { name: "Add CORS headers to responses", @@ -63,9 +63,8 @@ fn run_db_migrations(rocket: Rocket) -> Result { fn rocket() -> rocket::Rocket { // This needs to be muted for the frontend feature - #[allow(unused_mut)] let mut rocket = rocket::ignite() - .attach(Cors) + .attach(CORS) .attach(FejDbConn::fairing()) .attach(AdHoc::on_attach("Database Migrations", run_db_migrations)) .mount("/api/ivago", routes::ivago()) // /api being hardcoded is temporary