diff --git a/.drone.yml b/.drone.yml index 6283309..d8ac34a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,9 +8,34 @@ trigger: event: - push +environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: newsletter + DATABASE_URL: postgres://postgres:password@postgres:5432/newsletter + steps: - - name: testBuild + - name: postgresDBTest # Test that the service is ready to be acted upon for cargo tests + image: postgres:12-alpine + commands: + - sleep 15 + - psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} + + - name: sqlxMigrate image: rust:1.56 commands: - - cargo build --verbose --all - - cargo test --verbose --all \ No newline at end of file + - 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.56 + commands: + - apt update && apt install -y build-essential pkg-config libssl-dev # Dependancies for tarpaulin + - cargo install cargo-tarpaulin + - cargo tarpaulin -v --all-features --timeout 120 --color always # RUN THOSE TESTS + +services: + - name: postgres + image: postgres:12-alpine \ No newline at end of file diff --git a/scripts/init_db.sh b/scripts/init_db.sh index 312e44e..bb26791 100644 --- a/scripts/init_db.sh +++ b/scripts/init_db.sh @@ -13,7 +13,7 @@ fi if ! [ -x "$(command -v sqlx)" ]; then echo >&2 "Error: `sqlx` is not installed." echo >&2 "Use:" - echo >&2 " sudo apt install build-essential pkg-config openssl libssl-dev" + echo >&2 " sudo apt install build-essential pkg-config libssl-dev" echo >&2 " cargo install --version=0.5.7 sqlx-cli --no-default-features --features postgres" echo >&2 "to install it." exit 1 @@ -43,7 +43,7 @@ until psql -h "localhost" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; sleep 1 done ->&2 echo "Postgres is up anad running on port ${DB_PORT} - running migrations." +>&2 echo "Postgres is up and running on port ${DB_PORT} - running migrations." export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME} sqlx database create