Created
October 19, 2020 04:14
-
-
Save hasandiwan/e5bcb955a642c62f7c32c9ff2beb5246 to your computer and use it in GitHub Desktop.
Simple CI tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from hashlib import sha256 | |
import logging | |
import pytest | |
logging.basicConfig(level=logging.DEBUG) | |
old = '' | |
with open('app.py') as op: | |
hash_bytes = op.read() | |
old = sha256(hash_bytes.encode('utf-8')).hexdigest() | |
logging.debug(f'{old} is the sha256 hash as of {datetime.datetime.now()}') | |
while True: | |
latest = '' | |
with open('app.py') as op: | |
hash_bytes = op.read() | |
latest = sha256(hash_bytes.encode('utf-8')).hexdigest() | |
if latest != old: | |
logging.debug(f'change detected between {old} and {latest} on {datetime.datetime.now()}') | |
pytest.main(['app.py']) | |
old = latest | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment