diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..04ad75a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +sudo: required + +services: + - docker + +before_install: + - docker build -t heroku-load-balancer . -f Dockerfile + - docker run -d -p 7979:7979 -v $PWD:/heroku-load-balancer -e PORT=7979 -e HEROKU_API_KEY=$HEROKU_API_KEY -e PIPELINE_IDENTIFIER='f64cf79b-79ba-4c45-8039-57c9af5d4508' --name heroku-load-balancer heroku-load-balancer + +script: + - docker exec -it heroku-load-balancer bash -c "radon cc src -nb --total-average" + - docker exec -it heroku-load-balancer bash -c "cat requirements.txt requirements-dev.txt | safety check --stdin" + - docker exec -it heroku-load-balancer bash -c "bash <(curl -s https://linters.io/sort-requirements) requirements.txt requirements-dev.txt" + - docker exec -it heroku-load-balancer bash -c "bash <(curl -s https://linters.io/isort-diff) src" + - docker exec -it heroku-load-balancer bash -c "flake8 src" + +env: + global: + secure: I8Rr7rQOfSFkq+VjYFThFfbBE2YIs4d5y3f9kJEAbZ51p61QWu8h4Opu1/fXGPFA5hCOS2sd8hywj+wVAaavd4GUuJurYbUd4rGVhkpQDCSYlUVr2eGHXGC+JgpyZ14LKsPOAFIfdwumU4ZrmAgTmKuduhiXo/erQk2g086ivBjqUvjG/yRH3ZehlMVY1MU4QIOZa1JrWgG/XmXXIxaFbQpwIeNQw3Q5i10PcG+X+6Yoeg+IrJ4mKIExKzrwrBS3I/JEWh37TAB2AkQN8Ez2u8AktM8uAyKALxL4mThhr9sCsIjfrNHJOYENDKvzLM1Y0XDURSclrngsvp3ihOTo23JSXemBPzbxfP2jvhFV0nDePVq88fVIrhxFNw+Kd1Gvew6hFa1PftNq825eDfLv+oWD8o3J9SU8innqxF6TH5d/UfIkI+Z3ovciedL4Jy7/bGTIqKk5Zc04GylCfEGxm1YFotNpE1LYunMcmE6pJQvs35DWryhJw3ryGOI3CWQLXuSq8pbR3czJpPeZlisJ1pU7vh79x8lZmWsxsza5jYMvPAle6JgInnm8oYkvwNc4fi5u9Y4Tb9Q4QSIc3nX9o62mH1fu6F/N5lefe6xoRkTjz2xkOkwEHtiAFKrXimyI6E/wscOk5NgenMqp0cm4Sk5C3vlLnvCc79/zycCeIpw= diff --git a/Dockerfile b/Dockerfile index fb7a18d..2553ce3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,15 @@ ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 RUN apt-get update && apt-get install -y \ - nginx + software-properties-common \ + nginx \ + curl -RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa && \ - apt-get update && apt-get install -y python3.6 python3.6-dev python3-pip python3-setuptools +RUN add-apt-repository ppa:deadsnakes/ppa && apt-get update && apt-get install -y \ + python3.6 \ + python3.6-dev \ + python3-pip \ + python3-setuptools RUN ln -sfn /usr/bin/python3.6 /usr/bin/python3 && ln -sfn /usr/bin/python3 /usr/bin/python @@ -16,6 +21,6 @@ COPY . /heroku-load-balancer ENV PYTHONPATH="$PYTHONPATH:/heroku-load-balancer/src" -RUN pip3 install -r /heroku-load-balancer/requirements.txt +RUN pip3 install -r /heroku-load-balancer/requirements.txt -r /heroku-load-balancer/requirements-dev.txt CMD /bin/bash -c "python3 src/entrypoint.py create-load-balancer --nginx-port=$PORT --heroku-api-key=$HEROKU_API_KEY --pipeline-identifier=$PIPELINE_IDENTIFIER" && mv nginx.conf /etc/nginx/nginx.conf && nginx -g 'daemon off;' diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..8cfd09e --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,11 @@ +add-trailing-comma==1.0.0 +flake8-commas==2.0.0 +flake8-comprehensions==2.1.0 +flake8-docstrings==1.3.0 +flake8-per-file-ignores==0.8.1 +flake8-print==3.1.0 +flake8==3.7.7 +isort==4.3.20 +pep8-naming==0.8.2 +radon==3.0.3 +safety==1.8.5 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..fedce7c --- /dev/null +++ b/setup.cfg @@ -0,0 +1,22 @@ +[isort] +line_length=120 +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=True +combine_as_imports=True + +[flake8] +max-line-length=120 +ignore=D200, D413, D107, D100 +per-file-ignores= + */__init__.py: D104, F401, D100, + */test_*: D205, + src/constants.py: E501 + +[coverage:run] +omit = + */.virtualenvs/*, + */virtualenv/*, + + */__init__.py, + tests/* diff --git a/src/entrypoint.py b/src/entrypoint.py index 181ecc1..c7db432 100644 --- a/src/entrypoint.py +++ b/src/entrypoint.py @@ -12,6 +12,9 @@ @click.group() def cli(): + """ + Command line interface root function. + """ pass @@ -32,7 +35,7 @@ def cli(): '--pipeline-identifier', type=str, required=True, - help='Pipeline identifier to fetch applications for balancing.' + help='Pipeline identifier to fetch applications for balancing.', ) def create_load_balancer(nginx_port, heroku_api_key, pipeline_identifier): """