Skip to content

Commit

Permalink
Merge branch 'feature/travis'
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMax committed Jun 20, 2018
2 parents 469d33b + 4eae6bd commit a78e7b9
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 104 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo_token: gseS35w5Pk1BHJmfMgncdMSeL862hAifa
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ build/
dist/
temp/

# sphinx doc
docs/

# pytest
.cache
.pytest_cache

# coveralls
.coverage

# python gifts
*.egg-info/
*.egg
.eggs
*.py[cod]
__pycache__/
*.so
Expand Down
64 changes: 64 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
language: python
sudo: required
dist: trusty
os: linux

python:
- 3.5
- 3.6

matrix:
include:
- os: osx
language: generic
env: PYTHON=3.5.5
- os: osx
language: generic
env: PYTHON=3.6.3

addons:
apt:
update: true
packages:
- hdf5-tools

# https://pythonhosted.org/CodeChat/.travis.yml.html
before_install:
- linux() { if test "$TRAVIS_OS_NAME" == "linux"; then $@; fi; }
- osx() { if test "$TRAVIS_OS_NAME" == "osx"; then $@; fi; }
- osx brew update
- osx rm -vf /usr/local/include/c++
- osx brew install gcc
- osx brew install hdf5
- osx brew install lzo
- osx brew outdated pyenv || brew upgrade pyenv
- osx brew install pyenv-virtualenv
- osx pyenv install $PYTHON
- osx export PYENV_VERSION=$PYTHON
- osx export PATH="/Users/travis/.pyenv/shims:${PATH}"
- osx pyenv virtualenv venv
- osx . /Users/travis/.pyenv/versions/$PYTHON/envs/venv/bin/activate
- python --version
- python -m pip install -U pip
- python -m easy_install -U setuptools
- pip install --upgrade pip
- pip install --upgrade setuptools

install:
- make
- make install_test
- linux make install_graph

script:
- babao
- make flake
- make lint
- make test
- make coverage

after_script:
- make develop
- make install
- make reinstall
- make doc
- make uninstall
8 changes: 5 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ make install_test
```


if you're not planning to develop:
if planning to develop:
```shell
make install
make develop
```


### ...or using pip:
```shell
mkdir -pv ~/.babao.d/{data,log}
cp -nv config/babao.conf config/kraken.key ~/.babao.d
pip install .
```

Expand All @@ -44,7 +46,7 @@ pip install .[test]

## Requirements:

* python3
* python >= 3.5
* pip
* hdf5

Expand Down
96 changes: 52 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,71 @@

NAME = babao


ROOT_DIR = $(HOME)/.$(NAME).d
SRC_DIR = src
INSTALL_DIR= $(HOME)/.local
INSTALL_NAME = $(INSTALL_DIR)/bin/$(NAME)
DOC_DIR = docs
DOC_BUILD_DIR = docs/_build

CONFIG_DIR = config
CONFIG_FILE = $(CONFIG_DIR)/$(NAME).conf
KRAKEN_KEY_FILE = $(CONFIG_DIR)/kraken.key

export PATH := $(INSTALL_DIR)/bin:$(PATH)

INSTALL_FILES_LOG = .install_files.list
TMP_FILES = build dist temp __pycache__ $(NAME).egg-info\
$(SRC_DIR)/$(NAME)/**/*/__pycache__ $(SRC_DIR)/$(NAME).egg-info
TMP_FILES = build dist temp $(shell find . -name __pycache__) \
$(NAME).egg-info $(SRC_DIR)/$(NAME).egg-info $(DOC_DIR)

RM = rm -rfv
MKDIR = mkdir -pv
CP = cp -nv
ECHO = echo -e
PY = python3 -u
PY = python -u

EUID = $(shell id -u)

DEBUGER = ipython --no-confirm-exit --no-banner -i --pdb
TESTER = pytest --pdb --fulltrace
FLAKE = flake8
LINTER = pylint --rcfile=setup.cfg $(shell test $(TERM) == dumb && echo "-fparseable")
SETUP = python3 setup.py
INSTALL_FLAGS = install -O2 --user
DEVELOP_FLAGS = develop -O2 --user
RECORD_FLAGS = $(INSTALL_FLAGS) --record $(INSTALL_FILES_LOG) # --dry-run is bugged?

ifdef QUIET
SETUP += --quiet
.SILENT:
TESTER = pytest --fulltrace
ifndef TRAVIS
TESTER += $(shell if [ "$(TERM)" != dumb ]; then echo "--pdb"; fi)
endif
FLAKE = flake8
LINTER = pylint --rcfile=setup.cfg $(shell if [ "$(TERM)" = dumb ]; then echo "-fparseable"; fi)
PIP_INSTALL = pip install $(shell if [ "$(EUID)" != 0 ] && [ "$(READTHEDOCS)$(TRAVIS)$(PYENV_VERSION)" = "" ]; then echo "--user"; fi)
PIP_UNINSTALL = pip uninstall -y

ifdef DEBUG
BUILD_FLAGS += -g
EXEC = $(DEBUGER) -m $(NAME) --
else
EXEC = $(PY) -m $(NAME)
endif


.PHONY: conf install install_test install_graph clean fclean uninstall reinstall flake lint test check commit
.PHONY: conf install install_test install_graph clean fclean uninstall reinstall flake lint test check commit coverage doc html man


$(NAME): | $(ROOT_DIR)
$(SETUP) $(DEVELOP_FLAGS)
sed -i 's|^\(#!/.*python\w*\)$$|\1 -u|' $(INSTALL_DIR)/bin/$(NAME)
$(ECHO) '#!/bin/bash\n\n$(EXEC) "$$@"' > $(NAME)
$(NAME): install
printf '#!/bin/bash\n\n$(EXEC) "$$@"\n' > $(NAME)
chmod 755 $(NAME)

$(ROOT_DIR):
$(ROOT_DIR): # TODO: do that in setup.py / babao
$(MKDIR) $(ROOT_DIR)/{data,log}
$(CP) $(CONFIG_FILE) $(KRAKEN_KEY_FILE) $(ROOT_DIR)

$(INSTALL_NAME):
$(SETUP) $(INSTALL_FLAGS)


conf: | $(ROOT_DIR)

install: $(NAME) $(INSTALL_NAME) # TODO: won't install if develop already there
install: conf
$(PIP_INSTALL) .
ifndef TRAVIS
# unbufferd I/O: TODO: move to forever-babao.sh
sed -i 's|^\(#!/.*python\w*\)$$|\1 -u|' $(shell which $(NAME))
endif

develop: install
$(PIP_INSTALL) --editable .

install_test: install
pip install --user .[test] # TODO
install_test: conf
$(PIP_INSTALL) .[test] # TODO

install_graph: install
pip install --user .[graph] # TODO
install_graph: conf
$(PIP_INSTALL) .[graph] # TODO


clean:
Expand All @@ -79,16 +76,11 @@ fclean: clean
$(RM) $(NAME)

uninstall: fclean
$(SETUP) $(RECORD_FLAGS)
xargs $(RM) < $(INSTALL_FILES_LOG)
$(RM) $(INSTALL_FILES_LOG)
find $(INSTALL_DIR)/lib -name $(NAME)\* | xargs $(RM)
find $(INSTALL_DIR)/lib -name easy-install.pth | xargs sed -i 's!\./$(NAME)-.*\.egg!!'
make fclean #ouch
$(PIP_UNINSTALL) $(NAME)
# $(RM) $(ROOT_DIR)

reinstall: uninstall install

reinstall: uninstall
$(MAKE) $(NAME)

flake:
$(FLAKE)
Expand All @@ -99,8 +91,24 @@ lint:
test:
$(TESTER)

coverage:
coverage run --source=$(NAME) setup.py test
coveralls

check: flake lint test

$(DOC_BUILD_DIR):
sphinx-apidoc --ext-coverage -H $(NAME) -A JeanMax -V 0.1 -F -o $(DOC_DIR) $(SRC_DIR)/$(NAME)

html: $(DOC_BUILD_DIR)
sphinx-build -M html $(DOC_DIR) $(DOC_BUILD_DIR)

man: $(DOC_BUILD_DIR)
sphinx-build -M man $(DOC_DIR) $(DOC_BUILD_DIR)

doc: html man
sphinx-build -M coverage $(DOC_DIR) $(DOC_BUILD_DIR)

commit: reinstall check fclean
git add -A .
git diff --cached --minimal
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
Just a little [insert crypto-currency] trade bot, using [insert strategy] over [insert market-place] api.

| Branch | Build | Coverage | Doc | Package |
|-|-|-|-|-|
| `master` | [![Build Status](https://travis-ci.org/JeanMax/babao.svg?branch=master)](https://travis-ci.org/JeanMax/babao) | [![Coverage Status](https://coveralls.io/repos/github/JeanMax/babao/badge.svg?branch=master)](https://coveralls.io/github/JeanMax/babao?branch=master) | [![Documentation Status](https://readthedocs.org/projects/babao/badge/?version=master)](http://babao.readthedocs.io/en/latest/?badge=master) | [![PyPI version](https://badge.fury.io/py/babao.svg)](https://badge.fury.io/py/babao) |
| `dev` | [![Build Status](https://travis-ci.org/JeanMax/babao.svg?branch=dev)](https://travis-ci.org/JeanMax/babao) | [![Coverage Status](https://coveralls.io/repos/github/JeanMax/babao/badge.svg?branch=dev)](https://coveralls.io/github/JeanMax/babao?branch=dev) | [![Documentation Status](https://readthedocs.org/projects/babao/badge/?version=dev)](http://babao.readthedocs.io/en/dev/?badge=dev) |-|

## Usage:

Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[aliases]
test=pytest

[metadata]
description-file = README.md

[easy_install]
optimize = 2

Expand Down

0 comments on commit a78e7b9

Please sign in to comment.