CICD Upgrade #72
			
				
			
		
		
		
	|  | @ -1,43 +1,91 @@ | |||
| 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 | ||||
|         pull: true | ||||
|         group: lint | ||||
|         environment: | ||||
|             - CARGO_HOME=.cargo | ||||
|         commands: | ||||
|             - cargo fmt -- --check | ||||
|             # This is run here because it requires compilation | ||||
|             - cargo clippy --all-targets -- -D warnings | ||||
|      | ||||
| 
 | ||||
|     # 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 | ||||
|     # =====REBUILD & FLUSH CACHE===== | ||||
|     rebuild-cache: | ||||
|         image: plugins/s3-cache | ||||
| 
 | ||||
|     # 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 | ||||
|         endpoint: https://s3.roosens.me | ||||
|         root: build-cache/ | ||||
|         rebuild: true | ||||
|         mount: | ||||
|             - target | ||||
|             - .cargo | ||||
|             - web/node_modules | ||||
| 
 | ||||
|     # TODO build dev & rel image, deploy these images | ||||
|         secrets: [ cache_s3_access_key, cache_s3_secret_key ] | ||||
|         # Push the cache, even on failure | ||||
|         when: | ||||
|             status: [ success, failure ] | ||||
| 
 | ||||
| # branches: [ master, develop ] | ||||
|     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 ] | ||||
|  |  | |||
|  | @ -16,10 +16,7 @@ impl PickupTime { | |||
|     /// * `date` - Date of pickup time
 | ||||
|     /// * `label` - Type of trash
 | ||||
|     pub fn new(date: BasicDate, label: String) -> PickupTime { | ||||
|         PickupTime { | ||||
|             date: date, | ||||
|             label: label, | ||||
|         } | ||||
|         PickupTime { date, label } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,10 +18,7 @@ impl Street { | |||
|     // This constructor just makes my life a bit easier during testing
 | ||||
|     #[cfg(test)] | ||||
|     fn new(name: String, city: String) -> Street { | ||||
|         Street { | ||||
|             name: name, | ||||
|             city: city, | ||||
|         } | ||||
|         Street { name, city } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,12 +8,15 @@ fn main() { | |||
|     let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); | ||||
| 
 | ||||
|     let db_conn = PgConnection::establish(&database_url) | ||||
|         .expect(&format!("Error connecting to {}", database_url)); | ||||
|         .unwrap_or_else(|_| panic!("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); | ||||
|             insert_into(ivago_streets) | ||||
|                 .values(streets) | ||||
|                 .execute(&db_conn) | ||||
|                 .expect("Failed to insert rows."); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -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,8 +63,9 @@ fn run_db_migrations(rocket: Rocket) -> Result<Rocket, Rocket> { | |||
| 
 | ||||
| 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
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue