Check Travis-CI env

This commit is contained in:
nothink 2018-07-26 00:05:10 +09:00
parent 92ae4a9f9c
commit a753bf68dc
2 changed files with 35 additions and 1 deletions

View file

@ -10,6 +10,7 @@ matrix:
- language: python - language: python
python: python:
- "3.5" - "3.5"
- "3.6"
before_install: before_install:
- sudo apt-get -y install software-properties-common - sudo apt-get -y install software-properties-common
- sudo add-apt-repository -y ppa:mc3man/trusty-media - sudo add-apt-repository -y ppa:mc3man/trusty-media
@ -32,7 +33,9 @@ matrix:
- pip install -r requirements.txt - pip install -r requirements.txt
- pip install -r dev-requirements.txt - pip install -r dev-requirements.txt
script: script:
# - pycodestyle szurubooru/ - pycodestyle wait-for-es
- pycodestyle generate-thumb
- pycodestyle szurubooru/
- ./wait-for-es - ./wait-for-es
- alembic upgrade head - alembic upgrade head
- py.test - py.test

View file

@ -16,12 +16,43 @@ def merge(left: Dict, right: Dict) -> Dict:
return left return left
def docker_config() -> Dict:
for key in [
'POSTGRES_USER',
'POSTGRES_PASSWORD',
'POSTGRES_HOST',
'ESEARCH_HOST'
]:
if not os.getenv(key, False):
raise errors.ConfigError(f'Environment variable "{key}" not set')
return {
'debug': True,
'show_sql': int(os.getenv('LOG_SQL', 0)),
'data_url': os.getenv('DATA_URL', '/data/'),
'data_dir': '/data/',
'database': 'postgres://%(user)s:%(pass)s@%(host)s:%(port)d/%(db)s' % {
'user': os.getenv('POSTGRES_USER'),
'pass': os.getenv('POSTGRES_PASSWORD'),
'host': os.getenv('POSTGRES_HOST'),
'port': int(os.getenv('POSTGRES_PORT', 5432)),
'db': os.getenv('POSTGRES_DB', os.getenv('POSTGRES_USER'))
},
'elasticsearch': {
'host': os.getenv('ESEARCH_HOST'),
'port': int(os.getenv('ESEARCH_PORT', 9200)),
'index': os.getenv('ESEARCH_INDEX', 'szurubooru')
}
}
def read_config() -> Dict: def read_config() -> Dict:
with open('../config.yaml.dist') as handle: with open('../config.yaml.dist') as handle:
ret = yaml.load(handle.read()) ret = yaml.load(handle.read())
if os.path.exists('../config.yaml'): if os.path.exists('../config.yaml'):
with open('../config.yaml') as handle: with open('../config.yaml') as handle:
ret = merge(ret, yaml.load(handle.read())) ret = merge(ret, yaml.load(handle.read()))
if os.path.exists('/.dockerenv') and not os.getenv(CI, False):
ret = merge(ret, docker_config())
return ret return ret