Skip to content

Commit

Permalink
Changing the way the application is deployed. Introducing pipenv.
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Oct 26, 2019
1 parent 5bde177 commit 58f8c1a
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 26 deletions.
17 changes: 17 additions & 0 deletions .infrastructure/generate-requirements-txt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3

import os
from json import loads as json_loads

assert os.path.isfile('Pipfile.lock')

requirements = ""

with open('./Pipfile.lock', 'rb') as f:
piplock = f.read()

for package_name, details in json_loads(piplock)['default'].items():
requirements += package_name + details['version'] + "\n"

with open('./requirements.txt', 'wb') as f:
f.write(requirements.encode('utf-8'))
25 changes: 17 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,28 @@ before_script:

jobs:
include:
- stage: Test
- stage: Functional tests
before_script:
# install dependencies
- sudo apt-get update -y
- sudo apt-get install -y whois
- sudo apt-get install -y whois openssh-client sshpass
- make install PY_BIN="python" PIP="pip"
script:
- cd infracheck && ./functional-test.sh
- cd ../ && make unit_test coverage
after_success:
- bash ./.infrastructure/notify.sh "${SLACK_URL}" " [OK] Infracheck functional tests were passed"
after_failure:
- bash ./.infrastructure/notify.sh "${SLACK_URL}" " [FAILURE] Infracheck functional tests are failing!"

- stage: Unit tests
before_script:
# install dependencies
- sudo apt-get update -y
- sudo apt-get install -y whois openssh-client sshpass
script:
- cd ../ && make coverage
after_success:
- bash <(curl -s https://codecov.io/bash) -cF python
- bash ./.infrastructure/notify.sh "${SLACK_URL}" " [OK] Infracheck tests were passed"
- bash ./.infrastructure/notify.sh "${SLACK_URL}" " [OK] Infracheck unit tests were passed"
after_failure:
- bash ./.infrastructure/notify.sh "${SLACK_URL}" " [FAILURE] Infracheck tests are failing!"
deploy:
Expand All @@ -36,9 +46,8 @@ jobs:
password:
secure: jVQvdHqtkrL1smrJl/QC3YjP7vXSQ0XGuXe6nKeO0y3hDqGF8uP1FWNE4N+qSd1hJa23bN26gJa0FwrbP/n0XH82638QWw/Lu7gO5ITsoFrD3eERHqlRJ+xjsLo5NCP5/oo1fgMxWJ2Dp9xQvVRoYOc+xyyfoyllyMQY7vrpV9BZexJh9hZC2feX6B6PxmDYOV6EPnM2Nxi37kvUva7vAxJPZXrK29gJuB9VR1ToST6/ivA8LZXrjt1K/W1O8ewENr+PkDfmo8+ULHQtMEZO4/I4IvFRiLVYfCDFsJfUTkxeeMu468ZHnYyEUWcK//18UAz7bQXTOCeZbSla+g/LtBLXOo8w+V1Ws541ulJkKrekbvJB1GPwzOcVDHb9UEXtGyr8MvTkKqJUBsZFXGW3F7ClNyMvlbdf/8RDbI2xhwS402TD4e4g9cvZCy4QOGDHaAH0NldoLHdxfNQALIXrjI9HNm1bG5LQtvJ9bEsVsxcm1Zu9nSKqUfDxG12OIpAcdAwa0AoKOwds8BfIskyvbR+n37ftv6Hyv9H3ErpZh6L04y/LJeSE87+nQYwfFhZPx4KD+/D4lqCm1a98mDUwSIhkfrhF2Gvt0B0aOKP1pxGQMW8QVicOplCfdk4SHQL8J/Gy6xZbOFH7rWdDnnO/CWmlZ3UnCJDWiGssBJwstyA=


- stage: Build recent x86_64 image
- stage: "[Docker] Build recent x86_64 image"
script: make build_image ARCH=x86_64 GIT_TAG=${TRAVIS_TAG} PUSH=true

- stage: Build recent ARM image
- stage: "[Docker] Build recent ARM image"
script: make build_image ARCH=arm GIT_TAG=${TRAVIS_TAG} PUSH=true
73 changes: 73 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,13 +1,82 @@
CHANGES
=======

* Enabled docker in travis builds as it is required for testing
* Covered "ssh-command" with tests and fixed all spotted bugs
* Preparation for the Pipenv support
* Updated documentation for requirements
* Added documentation for "reminder" check
* Added ssh-command
* Added "reminder" check that should remind about upcoming dates
* Docker: Fixed typo in entrypoint

v1.6.1
------

* Cleared username from cron entry
* Restored /etc/crontabs/root as it was previously working
* Unified docker images to base on same OS - Alpine 3.9: Do not have to support two cron types
* Unified docker images to base on same OS - Alpine 3.9
* Correct crontab support to be compatible with multiple cron systems
* Corrected ARM dockerfile by adding supervisord config file

v1.6
----

* Makefile: Switched shell to bash
* CI: Fixed typo
* Moving to Travis
* Fixed documentation styling for new check
* Added retry support
* Added ovh-expiration check
* Refactored - moved infrastructural things to separate directory, added Slack notifications

v1.5.2
------

* Bugfix: The CHECK\_INTERVAL expression was evaluated, but it should not

v1.5.1
------

* Fixed possibly not executing crontab due to syntax error (double quote remained from docker environment variables)

v1.5.0
------

* Simplified docs
* Docker: Cleaned up the container, now we can be sure that the installed version of infracheck is used, the database have it's constant place at "/database/db.sqlite3", the crontab endpoint have explict arguments same as server
* domain-expiration: Shell whois checking method got exception handling

v1.4.3
------

* domain-expiration: Properly handling not registered domains

v1.4.2
------

* Domain Expiration is now properly handling ".info" domains
* Runner: Now contains the stderr

v1.4.1
------

* Fixed: --force flag was not considered, --lazy needed to be also specified
* Fixed types casting in arguments passing from CLI
* Fixed types casting in arguments passing from CLI
* Hotfix: Fixed 503 on HTTP caused by missing new params
* Updated suggestion in reference in docs

1.4.0
-----

* Added --lazy flag
* Added --wait / WAIT\_TIME, secured \`domain-expiration\` check against CPU overload

v1.3.0
------

* Added docs, clean up
* Resolved unit tests
* Resolved "rate limit exceeded" in domain-expiration check, by adding waits
Expand All @@ -29,6 +98,10 @@ CHANGES
* Renamed check to fit the convention
* Added domain-expiration check
* Corrected package name

v1.1.2
------

* Fixed invalid types casting - when the value in checks parameters was an integer, then there was an exception
* Update LICENSE
* Create LICENSE
Expand Down
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ build_package: ## Build
build_docs: ## Build documentation
cd ./docs && make html

install: build_package ## Install
${PIP} install -r ./requirements.txt
install: build_package ## Install as a package
${PIP} install pipenv
test -f ./requirements.txt || ./.infrastructure/generate-requirements-txt.py
${SUDO} ${PY_BIN} ./setup.py install
which infracheck
make clean

clean: ## Clean up the local build directory
${SUDO} rm -rf ./build ./infracheck.egg-info

unit_test: ## Run unit tests
${PY_BIN} -m unittest discover -s tests
setup_venv: ## Setup virtual environment
${SUDO} pipenv sync

coverage: ## Generate code coverage
coverage run --rcfile=.coveragerc --source . -m unittest discover -s ./tests
unit_test: setup_venv ## Run unit tests
${SUDO} pipenv run ${PY_BIN} -m unittest discover -s .

coverage: setup_venv ## Generate code coverage
${SUDO} pipenv run coverage run --rcfile=.coveragerc --source . -m unittest discover -s .
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ verify_ssl = true
coverage = "*"
unittest-data-provider = "*"
mock = "*"
docker = "*"

[packages]
tornado = "*"
pytz = "*"
whois = "*"
ovh = "*"
dateutil = "*"
python-dateutil = "*"

[requires]
python_version = "3.7"
71 changes: 68 additions & 3 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
tornado>=5<7
setuptools
unittest-data-provider
coverage
mock
whois>=0.7<2
pytz>=2019.1
ovh>=0.5.0
ovh==0.5.0
python-dateutil==2.8.0
pytz==2019.3
six==1.12.0
tornado==6.0.3
whois==0.9.4

0 comments on commit 58f8c1a

Please sign in to comment.