Skip to content

Commit

Permalink
Add a tox github action and fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
flyck committed Feb 8, 2021
1 parent 0e34b8a commit 3cba3dd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Tests

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Tox and any other packages
run: pip install tox
- name: Run Tox
# Run tox using the version of Python in `PATH`
run: tox -e py
4 changes: 3 additions & 1 deletion cost-reporter/src/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def get_daily_cost(days):


def trigger_notification(graph_data):
""" Determines whether or not to send the notification
"""
should_send = True

total_cost_today = 0
Expand All @@ -66,7 +68,7 @@ def trigger_notification(graph_data):
logging.info(f"Total cost yesterday: {total_cost_yesterday}")

only_notify_on_increase = os.environ["ONLY_NOTIFY_ON_INCREASE"]
if only_notify_on_increase == "true":
if only_notify_on_increase.lower() == "true":
if total_cost_today < total_cost_yesterday:
logging.info("Not sending, since cost did not increase and I should only notify on increase.")
should_send = False
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
envlist = py38
# allows us to run tox without setup.py
skipsdist = True

[testenv]
deps = -r{toxinidir}/cost-reporter/requirements-dev.txt
commands = pytest
setenv =
PYTHONPATH={toxinidir}/cost-reporter/src

0 comments on commit 3cba3dd

Please sign in to comment.