diff --git a/.drone.yml b/.drone.yml index e0b8c29..281ad51 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ trigger: steps: - name: postgresDBTest # Test that the service is ready to be acted upon for cargo tests - image: postgres:12-alpine + image: postgres:12 environment: PGPASSWORD: password DATABASE_URL: postgres://postgres:password@postgres:5432/newsletter @@ -20,13 +20,20 @@ steps: - name: sqlxMigrate image: rust:1.57 + environment: + DATABASE_URL: postgres://postgres:password@postgres:5432/newsletter + SKIP_DOCKER: + from_secret: SKIP_DOCKER commands: - apt update && apt install -y build-essential pkg-config libssl-dev # Dependancies for sqlx - cargo install --version=0.5.7 sqlx-cli --no-default-features --features postgres # Install sqlx + - sqlx database create - sqlx migrate run - name: test image: rust:1.57 + environment: + APP_ENVIRONMENT: drone commands: - apt update && apt install -y build-essential pkg-config libssl-dev # Dependancies for tarpaulin - cargo install cargo-tarpaulin @@ -34,7 +41,7 @@ steps: services: - name: postgres - image: postgres:12-alpine + image: postgres:12 environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: password diff --git a/configuration/drone.yaml b/configuration/drone.yaml new file mode 100644 index 0000000..69e366a --- /dev/null +++ b/configuration/drone.yaml @@ -0,0 +1,5 @@ +application: + host: 127.0.0.1 +database: + host: postgres + require_ssl: false \ No newline at end of file diff --git a/src/configuration.rs b/src/configuration.rs index b489161..ccc888a 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -77,6 +77,7 @@ pub fn get_configuration() -> Result { pub enum Environment { Local, Production, + Drone } impl Environment { @@ -84,6 +85,7 @@ impl Environment { match self { Environment::Local => "local", Environment::Production => "production", + Environment::Drone => "drone", } } } @@ -95,8 +97,9 @@ impl TryFrom for Environment { match s.to_lowercase().as_str() { "local" => Ok(Self::Local), "production" => Ok(Self::Production), + "drone" => Ok(Self::Drone), other => Err(format!( - "{} is nto a supported environment. Use either `local` or `production`.", other + "{} is nto a supported environment. Use either `local`, `production` or `drone`.", other )), } }