Compare commits

...

21 Commits

Author SHA1 Message Date
Jef Roosens 03020fe798 Merge pull request 'CICD Upgrade' (#72) from 45-cicd into develop
continuous-integration/drone the build was successful Details
Reviewed-on: https://git.roosens.me/Chewing_Bever/fej/pulls/72
2021-05-13 10:44:15 +02:00
Jef Roosens 4cf9152fc4
[#45] Hopefully made Cargo home available across steps
continuous-integration/drone the build was successful Details
2021-05-12 14:44:10 +02:00
Jef Roosens 8baeda4cae
[#45] Fixed clippy errors
continuous-integration/drone the build failed Details
2021-05-12 14:29:39 +02:00
Jef Roosens 2547434d95
[#45] Added cargo caching; made clippy more strict 2021-05-12 14:28:59 +02:00
Jef Roosens b9d0bb7aa5
[#45] Removed leftover comments 2021-05-12 14:12:29 +02:00
Jef Roosens faa4f713c8
[#45] Fixed clippy errors
continuous-integration/drone the build was successful Details
2021-05-11 22:11:35 +02:00
Jef Roosens c8bfc16af8
[#45] Moved tests to before linting 2021-05-11 22:03:44 +02:00
Jef Roosens 9dbb4c8804
[#45] Moved clippy call to lint phase
continuous-integration/drone the build failed Details
2021-05-11 21:58:49 +02:00
Jef Roosens 728e72e47c
[#45] Removed unnecessary clippy flag (and let's test the cache)
continuous-integration/drone the build failed Details
2021-05-11 21:51:54 +02:00
Jef Roosens 01aa4bae80
[#45] Re-ordered tasks to make them logical
continuous-integration/drone the build failed Details
2021-05-11 21:41:54 +02:00
Jef Roosens 2a14703097
[#45] Let's try some other env vars
continuous-integration/drone the build failed Details
2021-05-11 21:38:19 +02:00
Jef Roosens 81c0d5e00b
[#45] Changed root style
continuous-integration/drone the build failed Details
2021-05-11 21:19:18 +02:00
Jef Roosens 63316314aa
[#45] Another try at fixing the ci
continuous-integration/drone the build failed Details
2021-05-11 20:43:51 +02:00
Jef Roosens 0ec5e33860
[#45] Enabled debug logs for debugging
continuous-integration/drone the build failed Details
2021-05-10 22:22:51 +02:00
Jef Roosens 9d065c229e
[#45] Added path_style option
continuous-integration/drone the build failed Details
2021-05-10 22:21:56 +02:00
Jef Roosens b8f31aa337
[#45] Renamed root 2021-05-10 22:19:49 +02:00
Jef Roosens bd51b6ce14
[#45] More updates to cicd file
continuous-integration/drone the build failed Details
2021-05-10 22:15:05 +02:00
Jef Roosens 4666790784
[#45] Edited broken env vars
continuous-integration/drone the build failed Details
2021-05-10 21:57:15 +02:00
Jef Roosens 92c6e2c5cc
[#45] It's plugins/s3-cache dude
continuous-integration/drone the build failed Details
2021-05-10 21:54:56 +02:00
Jef Roosens ff1631b525
[#45] Fixed first of probably many errors
continuous-integration/drone the build failed Details
2021-05-10 21:54:03 +02:00
Jef Roosens cd4075d294
[#45] First attempt at using S3 cache 2021-05-10 21:52:24 +02:00
5 changed files with 79 additions and 33 deletions

View File

@ -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 ]

View File

@ -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 }
}
}

View File

@ -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 }
}
}

View File

@ -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.");
}
}
}

View File

@ -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