Skip to content

Commit

Permalink
use docker for lint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Azulinho committed Apr 19, 2023
1 parent 9f6fe37 commit 18a3b74
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 94 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ secrets/*
state/*
.tags
tags
tests/*
.venv
.venv/*
.git
5 changes: 5 additions & 0 deletions .github/workflows/pr_docker_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ jobs:
run: |
set -ex
./run github_actions_ci_pr_docker_tests TAG=pr
- name: ./run tests
run: |
set -ex
./run tests
82 changes: 0 additions & 82 deletions .github/workflows/pr_lint.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM local:tests
RuN mkdir log cache tmp
ADD requirements-dev.txt /cryptobot/requirements-dev.txt
RUN /cryptobot/.venv/bin/pip install -r requirements-dev.txt
ADD .mypy.ini /cryptobot/
ADD pyproject.toml /cryptobot/
ADD tests/ /cryptobot/tests/
ADD strategies/Buy* /cryptobot/strategies/

RUN /cryptobot/.venv/bin/black --check \
app.py \
klines_caching_service.py \
price_log_service.py \
strategies/ \
lib/ \
tests/ \
utils/

RUN ls strategies/*.py \
|grep -v Local \
| xargs /cryptobot/.venv/bin/pylint \
app.py \
klines_caching_service.py \
price_log_service.py \
lib/*.py \
utils/*.py

RUN ls strategies/*.py \
|grep -v Local \
| xargs /cryptobot/.venv/bin/mypy \
app.py \
klines_caching_service.py \
price_log_service.py \
lib/*.py \
utils/*.py

RUN /cryptobot/.venv/bin/pytest \
--quiet -W ignore --disable-pytest-warnings tests/
14 changes: 3 additions & 11 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,9 @@ function setup() { # local setup for development
function tests() { # CI and pre-commit tests
set -e
set -o pipefail
export PATH=~/.pyenv/bin:$PATH
source .venv/bin/activate
echo "running black..."
black --check app.py klines_caching_service.py price_log_service.py strategies/ lib/ tests/ utils/
echo "running pylint..."
ls strategies/*.py |grep -v Local | xargs pylint app.py klines_caching_service.py price_log_service.py lib/*.py utils/*.py
echo "running mypy..."
ls strategies/*.py |grep -v Local | xargs mypy app.py klines_caching_service.py price_log_service.py lib/*.py utils/*.py
echo "running pytest..."
pytest --quiet -W ignore --disable-pytest-warnings tests/
deactivate

IMAGE=local TAG=tests build
docker build -f Dockerfile.tests .
}

function github_actions_ci_pr_docker_tests() {
Expand Down
3 changes: 3 additions & 0 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ def test_extract_order_data(self, bot, coin):
"selfTradePreventionMode": "NONE",
}

bot.calculate_volume_size = mock.MagicMock()
bot.calculate_volume_size.return_value = (True, 0.5)

ok, data = bot.extract_order_data(order_details, coin)
assert ok is True
assert data["avgPrice"] == 332.53376623376624
Expand Down

0 comments on commit 18a3b74

Please sign in to comment.