diff --git a/.woodpecker.yml b/.woodpecker.yml index c97d007..2b47644 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,4 +1,24 @@ -pipeline: +steps: + librepages-conductor: + image: realaravinth/librepages-conductor + detach: true + environment: + - LPCONDUCTOR__SOURCE_CODE=https://git.batsense.net/LibrePages/conductor + - LPCONDUCTOR_SERVER__PROXY_HAS_TLS=false + - LPCONDUCTOR_DEBUG=false + - LPCONDUCTOR_CONDUCTOR=dummy + - LPCONDUCTOR_SERVER_DOMAIN=librepages.test + - LPCONDUCTOR_SERVER_IP=0.0.0.0 + - LPCONDUCTOR_SERVER_PROXY_HAS_TLS=false + - LPCONDUCTOR_SERVER_PORT=7000 + - LPCONDUCTOR_SOURCE_CODE=https://example.org + - LPCONDUCTOR_CREDS_USERNAME=librepages_api + - LPCONDUCTOR_CREDS_TOKEN=longrandomlygeneratedpassword + - PORT=5000 + - LPCONDUCTOR_CREDS_PASSWORD=longrandomlygeneratedpassword + commands: + - conductor serve + backend: image: rust environment: @@ -29,12 +49,14 @@ pipeline: image: plugins/docker when: event: [push, tag, deployment] + branch: master settings: username: realaravinth password: from_secret: DOCKER_TOKEN repo: realaravinth/librepages - tags: latest + tags: + latest # build_publisher_docker_img: # image: plugins/docker @@ -51,6 +73,7 @@ pipeline: image: rust when: event: [push, tag, deployment] + branch: master commands: - apt update - apt-get -y --no-install-recommends install gpg tar curl wget @@ -63,20 +86,3 @@ services: image: postgres environment: - POSTGRES_PASSWORD=password - - librepages-conductor: - image: realaravinth/librepages-conductor - command: conductor serve - environment: - - LPCONDUCTOR_SERVER__PROXY_HAS_TLS=false - - LPCONDUCTOR_DEBUG=false - - LPCONDUCTOR_CONDUCTOR=dummy - - LPCONDUCTOR_SERVER_URL_PREFIX="" - - LPCONDUCTOR_SERVER_DOMAIN="librepages.test" - - LPCONDUCTOR_SERVER_IP=0.0.0.0 - - LPCONDUCTOR_SERVER_PROXY_HAS_TLS=false - - LPCONDUCTOR_SERVER_PORT=7000 - - LPCONDUCTOR_SOURCE_CODE=https://example.org - - LPCONDUCTOR_CREDS_USERNAME="librepages_api" - - LPCONDUCTOR_CREDS_PASSWORD="longrandomlygeneratedpassword" - - PORT=5000 diff --git a/src/tests.rs b/src/tests.rs index fb36ad3..805826b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -24,6 +24,7 @@ use actix_web::{ }; use mktemp::Temp; use serde::Serialize; +use url::Url; use crate::ctx::api::v1::auth::{Login, Register}; use crate::ctx::api::v1::pages::AddSite; @@ -40,6 +41,15 @@ pub async fn get_ctx() -> (Temp, Arc<Ctx>) { // mktemp::Temp is returned because the temp directory created // is removed once the variable goes out of scope let mut settings = Settings::new().unwrap(); + let mut db_url = Url::parse(&settings.database.url).unwrap(); + db_url.set_path(&crate::utils::get_random(8)); + settings.database.url = db_url.to_string(); + + use sqlx::migrate::MigrateDatabase; + // sqlx::Postgres::create_database(&settings.database.url).await.unwrap(); + sqlx::postgres::Postgres::create_database(&settings.database.url) + .await + .unwrap(); let tmp_dir = Temp::new_dir().unwrap(); println!("[log] Test temp directory: {}", tmp_dir.to_str().unwrap()); @@ -48,8 +58,10 @@ pub async fn get_ctx() -> (Temp, Arc<Ctx>) { settings.init(); println!("[log] Initialzing settings again with test config"); settings.init(); + let ctx = Ctx::new(settings).await; + ctx.db.migrate().await.unwrap(); - (tmp_dir, Ctx::new(settings).await) + (tmp_dir, ctx) } #[allow(dead_code, clippy::upper_case_acronyms)]