Merge pull request 'ci-init-conductor' (#37) from ci-init-conductor into master
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

Reviewed-on: #37
This commit is contained in:
Aravinth Manivannan 2024-06-10 15:44:20 +05:30
commit 09d2deeb71
2 changed files with 38 additions and 20 deletions

View file

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

View file

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