Last active
January 23, 2023 04:14
-
-
Save garcia556/015116fc26e37df25ca0c30dfaae803e to your computer and use it in GitHub Desktop.
python backend ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
readonly PG_IMAGE="postgres:15.1-bullseye" | |
readonly PG_URL="postgres://kd_admin_auth:[email protected]:5432/kd_admin_auth" | |
flake8 | |
mypy | |
mkdir -p db | |
echo " | |
create role kd_admin_auth with login password 'mysecretpassword'; | |
create database kd_admin_auth owner kd_admin_auth; | |
" > db/init.sql | |
docker run \ | |
--name pg_db_test \ | |
--mount type=bind,source="$(pwd)/db,target=/docker-entrypoint-initdb.d,readonly" \ | |
--publish 127.0.0.1:5432:5432 \ | |
-e POSTGRES_PASSWORD=mysecretpassword \ | |
--detach \ | |
"${PG_IMAGE}" | |
docker logs pg_db_test | |
POSTGRES_URL="${PG_URL}" pytest -s -v api/tests/test_heartbeat.py | |
docker stop pg_db_test || true && docker rm pg_db_test || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment