Skip to content

Commit

Permalink
deploy test
Browse files Browse the repository at this point in the history
  • Loading branch information
evertlammerts committed Feb 15, 2018
1 parent 09559aa commit fe70668
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*

# except a few
!alembic
!src
!tests
!setup.py
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ node {
stage("Test") {
tryStep "test", {
sh "docker-compose -p dcatd -f ./docker-compose.yml build --no-cache --pull test && " +
"docker-compose -p dcatd -f ./docker-compose.yml run --rm test bash -c 'make test'"
"docker-compose -p dcatd -f ./docker-compose.yml run --rm test make test"
}, {
sh "docker-compose -p dcatd -f ./docker-compose.yml down"
}
Expand Down
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,37 @@ PYTEST = $(PYTHON) setup.py test
PYTEST_COV_OPTS ?= --cov=src --cov-report=term --no-cov-on-fail


test: schema
test: cleanpy schema
$(PYTEST)


cov: schema
cov: cleanpy schema
$(PYTEST) $(PYTEST_COV_OPTS)


testdep:
pip3 install --quiet --upgrade --upgrade-strategy eager -e .[test] && echo 'OK' || echo 'FAILED'


testclean:
testclean: cleanpy
@$(RM) .cache .coverage


# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Installing, building, running ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

install:
install: cleanpy
@echo -n 'Installing... '
@pip3 install --quiet --upgrade --upgrade-strategy eager -e . && echo 'OK' || echo 'FAILED'

dist:
dist: cleanpy
$(PYTHON) setup.py sdist

upload:
upload: cleanpy
$(PYTHON) setup.py sdist upload

example:
example: cleanpy
@echo Starting example server:
@docker-compose up api

Expand All @@ -59,6 +59,10 @@ example:
# ┃ Cleaning up ┃
# ┗━━━━━━━━━━━━━┛

cleanpy:
@echo Removing pyc and pyo files
@find . -type f -name '*.py[co]' -exec rm {} \;

clean:
@# From running pytest:
$(RM) .coverage .cache
Expand Down
19 changes: 13 additions & 6 deletions alembic/datacatalog/env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import with_statement
import os
from alembic import context
from sqlalchemy import engine_from_config, pool
from sqlalchemy import engine_from_config, pool, create_engine
from logging.config import fileConfig

# this is the Alembic Config object, which provides
Expand All @@ -23,6 +24,15 @@
# ... etc.


def get_url():
"""This allows users to override alembic stuff with env vars."""
envvars = 'DB_USER', 'DB_PASSWORD', 'DB_HOST', 'DB_PORT', 'DB_DATABASE'
confvals = [os.getenv(key, False) for key in envvars]
if all(confvals):
return "postgresql+psycopg2://{}:{}@{}:{}/{}".format(*confvals)
return config.get_main_option("sqlalchemy.url")


def run_migrations_offline():
"""Run migrations in 'offline' mode.
Expand All @@ -35,7 +45,7 @@ def run_migrations_offline():
script output.
"""
url = config.get_main_option("sqlalchemy.url")
url = get_url()
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True)

Expand All @@ -50,10 +60,7 @@ def run_migrations_online():
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connectable = create_engine(get_url())

with connectable.connect() as connection:
context.configure(
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
POSTGRES_USER: datacatalog
POSTGRES_PASSWORD: datacatalog

api:
example:
build:
context: .
depends_on:
Expand Down
2 changes: 2 additions & 0 deletions tests/datacatalog/plugins/test_postgres_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ storage_postgres:

plugins: []

primarySchema: ""

logging:
formatters:
default:
Expand Down

0 comments on commit fe70668

Please sign in to comment.