Update drone pipeline

enable postgres DB on drone pipeline for further tests
This commit is contained in:
Nick Bland 2021-11-08 12:43:28 +10:00
parent 6db0a7bc86
commit 7d7e7dc2d5
No known key found for this signature in database
GPG Key ID: B46CF88E4DAB4A2C
2 changed files with 30 additions and 5 deletions

View File

@ -8,9 +8,34 @@ trigger:
event: event:
- push - push
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: newsletter
DATABASE_URL: postgres://postgres:password@postgres:5432/newsletter
steps: 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 image: rust:1.56
commands: commands:
- cargo build --verbose --all - apt update && apt install -y build-essential pkg-config libssl-dev # Dependancies for sqlx
- cargo test --verbose --all - 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

View File

@ -13,7 +13,7 @@ fi
if ! [ -x "$(command -v sqlx)" ]; then if ! [ -x "$(command -v sqlx)" ]; then
echo >&2 "Error: `sqlx` is not installed." echo >&2 "Error: `sqlx` is not installed."
echo >&2 "Use:" 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 " cargo install --version=0.5.7 sqlx-cli --no-default-features --features postgres"
echo >&2 "to install it." echo >&2 "to install it."
exit 1 exit 1
@ -43,7 +43,7 @@ until psql -h "localhost" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q';
sleep 1 sleep 1
done 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} export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
sqlx database create sqlx database create