Add Gitlab CI and tests
This commit is contained in:
parent
68bd36e7e8
commit
1866aedd9e
2
.coveragerc
Normal file
2
.coveragerc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[run]
|
||||||
|
source = period
|
20
.gitlab-ci.yml
Normal file
20
.gitlab-ci.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
buiild job:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- export PYTHONPATH=.
|
||||||
|
- export FLASK_APP=period
|
||||||
|
- apt-get udate -qy
|
||||||
|
- apt-get install -y python3-dev python3-pip
|
||||||
|
- pip3 install Flask gunicorn pytest pytest-cov
|
||||||
|
- pytest tests --cov --cov-report term --cov-report html
|
||||||
|
|
||||||
|
deploy job:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- apt-get update -qy
|
||||||
|
- apt-get install curl -y
|
||||||
|
- curl period.ahosking.com/reload?password=BananaHammocks
|
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
FROM debian:jessie-slim
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
python3 \
|
||||||
|
python3-pip
|
||||||
|
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
ENV LC_ALL C.UTF-8
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . /app
|
2
deploy.sh
Normal file
2
deploy.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
gunicorn --bind=0.0.0.0:9060 --daemon reload:app
|
||||||
|
gunicorn --bind 0.0.0.0:9061 --reload --chdir period app:app
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
version: '2.3'
|
||||||
|
services:
|
||||||
|
flask-reload:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
command: bash deploy.sh
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: .
|
||||||
|
ports:
|
||||||
|
- '9060:9060'
|
||||||
|
- '9061:9061'
|
15
reload.py
Normal file
15
reload.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import os
|
||||||
|
from flask import request, Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/reload')
|
||||||
|
def reload():
|
||||||
|
if request.args.get('password') == 'BananaHammocks':
|
||||||
|
try:
|
||||||
|
os.system('git pull origin master')
|
||||||
|
return 'success'
|
||||||
|
except:
|
||||||
|
return 'fail'
|
||||||
|
else:
|
||||||
|
return 'wrong password'
|
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
# for pytest
|
16
tests/conftest.py
Normal file
16
tests/conftest.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import pytest
|
||||||
|
from period import create_app
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def app():
|
||||||
|
app = create_app({
|
||||||
|
'TESTING': True
|
||||||
|
})
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client(app):
|
||||||
|
return app.test_client()
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def runner(app):
|
||||||
|
return app.test_cli_runner()
|
Loading…
Reference in New Issue
Block a user