Skip to content

Commit

Permalink
Merge pull request vnpy#2097 from vnpy/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vnpy authored Sep 18, 2019
2 parents 32639a1 + 8ec0f43 commit 1257f9a
Show file tree
Hide file tree
Showing 431 changed files with 163,297 additions and 12,833 deletions.
132 changes: 132 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
version: 2
jobs:
flake8:
docker:
- image: circleci/python:3.7
steps:
- checkout
- restore_cache:
keys:
- flake8-dependencies
- run:
name: "create venv for caching"
command: |
python3 -m venv venv
- run:
name: "install flake8"
command: |
. venv/bin/activate
pip install flake8
- save_cache:
paths:
- ./venv
key: flake8-dependencies
- run:
name: "run flake8"
command: |
. venv/bin/activate
flake8
build_ctp_gcc8:
<<: &build_spec
docker:
- image: registry.cn-shanghai.aliyuncs.com/vnpy-ci/gcc-8-python-3.7:1.0
- image: circleci/postgres:latest
environment:
POSTGRES_DB: &db_name "vnpy"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: &db_password "1234"
- image: circleci/mysql:latest
environment:
MYSQL_DATABASE: *db_name
MYSQL_ROOT_PASSWORD: *db_password
- image: circleci/mongo:latest
environment:
<<: &build_environment
VNPY_TEST_POSTGRESQL_PASSWORD: *db_password
VNPY_TEST_MYSQL_PASSWORD: *db_password
VNPY_BUILD_CTP: "1"
VNPY_BUILD_OES: "0"
# best suit for circle-ci
VNPY_BUILD_PARALLEL: "2"
steps:
- checkout
- run:
name: "create venv for caching"
command: |
python3 -m venv venv
- restore_cache:
keys:
- v2-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v2-dependencies-

- run:
name: "showing environments"
command: |
. venv/bin/activate
source ci/env.sh
echo $PWD
python -V
pip list
gcc --version
free
cat /proc/cpuinfo|grep -P "(processor|cpu MHz|model name)"
set
- run:
name: "install some special pip packages"
command: |
. venv/bin/activate
source ci/env.sh
python -m pip --version
python -m pip install --upgrade pip wheel setuptools
python -m pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
bash ci/gitlab_pre_install.sh
- run:
name: "install vnpy and its dependents"
command: |
. venv/bin/activate
source ci/env.sh
bash ./install.sh
- save_cache:
paths:
- ./venv
key: v2-dependencies-{{ checksum "requirements.txt" }}

- run:
name: "test"
command: |
. venv/bin/activate
source ci/env.sh
set
cd tests
python test_all.py
build_oes_gcc8:
<<: *build_spec
environment:
<<: *build_environment
VNPY_BUILD_CTP: "0"
VNPY_BUILD_OES: "1"
python_only:
<<: *build_spec
environment:
<<: *build_environment
VNPY_BUILD_CTP: "0"
VNPY_BUILD_OES: "0"

workflows:
version: 2
build_ctp_gcc8:
jobs:
- build_ctp_gcc8
build_oes_gcc8:
jobs:
- build_oes_gcc8
flake8:
jobs:
- flake8
python_only:
jobs:
- python_only
4 changes: 1 addition & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[flake8]
exclude = __pycache__,__init__.py,ib,talib,uic
exclude = venv,build,__pycache__,__init__.py,ib,talib,uic
ignore =
E501 line too long, fixed by black
W503 line break before binary operator
W293 blank line contains whitespace
W291 trailing whitespace
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## 环境

* 操作系统: 如Windows 10或者Ubuntu 18.04
* Anaconda版本: 如Anaconda 18.12 Python 3.7 64位
* vn.py版本: 如v2.0发行版或者dev branch 20190101(下载日期)
* Python版本: 如VNStudio-2.0.6
* vn.py版本: 如v2.0.5发行版或者dev branch 20190101(下载日期)

## Issue类型
三选一:Bug/Enhancement/Question
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Python
*.pyc
*.egg-info/

# Jupyter
.ipynb_checkpoints
Expand Down
142 changes: 142 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: registry.cn-shanghai.aliyuncs.com/vnpy-ci/gcc-7-python-3.7:latest

.services:
services: &services
- postgres:latest
- mysql:latest
- mongo:latest

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables: &variables
GIT_DEPTH: "1"
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
POSTGRES_DB: &db_name "vnpy"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: &db_password "1234"
VNPY_TEST_POSTGRESQL_PASSWORD: *db_password
MYSQL_DATABASE: *db_name
MYSQL_ROOT_PASSWORD: *db_password
VNPY_TEST_MYSQL_PASSWORD: *db_password
VNPY_BUILD_PARALLEL: "auto"

# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
.default_cache:
cache:
<<: &cache
key: "pip_and_venv"
untracked: false
policy: pull
paths:
- .cache/pip
- venv/



before_script:
- echo $PWD
- python -V
- gcc --version
- free
- date

# venv
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate

# some envs
- source ci/env.sh

.scripts:
script:
- &install_scripts |
date
python -m pip --version
python -m pip install --upgrade pip wheel setuptools
python -m pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
bash ci/gitlab_pre_install.sh

date
bash ./install.sh
date

- &test_scripts |
date
cd tests
python test_all.py
date
##################################
# stages

stages: # I use anchors for IDE hints only
- &single_module single_module
- &build_all build_all


###########################################
## jobs:
flake8:
stage: *single_module
image: python:3.7
cache:
key: 'flake8'
paths:
- .cache/pip
- venv/
script:
- pip install flake8
- flake8

ctp:
<<: &test_single_module
stage: *single_module
image: registry.cn-shanghai.aliyuncs.com/vnpy-ci/gcc-8-python-3.7:latest
services: *services
cache:
<<: *cache
script:
- *install_scripts
- *test_scripts
variables:
<<: *variables
VNPY_BUILD_CTP: 1

oes:
<<: *test_single_module
variables:
<<: *variables
VNPY_BUILD_OES: 1

no_building:
<<: *test_single_module
cache:
<<: *cache
policy: pull-push
variables:
<<: *variables
VNPY_BUILD_OES: 0
VNPY_BUILD_CTP: 0

build-all-gcc8:
stage: *build_all
variables:
<<: *variables
image: registry.cn-shanghai.aliyuncs.com/vnpy-ci/gcc-8-python-3.7:latest
services: *services
cache:
key: "build-all"
paths: []
script:
- unset VNPY_BUILD_CTP
- unset VNPY_BUILD_OES
- *install_scripts
- *test_scripts

15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)

cache: pip

env:
- VNPY_BUILD_OES=0

git:
depth: 1

env:
- >
VNPY_BUILD_PARALLEL=1
VNPY_BUILD_CTP=1
VNPY_BUILD_OES=1
python:
- "3.7"

Expand All @@ -21,9 +24,10 @@ services:
before_script:
- psql -d postgresql:https://postgres:${VNPY_TEST_POSTGRESQL_PASSWORD}@localhost -c "create database vnpy;"
- mysql -u root --password=${VNPY_TEST_MYSQL_PASSWORD} -e 'CREATE DATABASE vnpy;'
- source ci/env.sh;

script:
- cd tests; source travis_env.sh;
- cd tests;
- python test_all.py

matrix:
Expand Down Expand Up @@ -92,5 +96,6 @@ matrix:
- bash ./install_osx.sh
before_script: []
script:
- cd tests; source travis_env.sh;
- source ci/env.sh;
- cd tests;
- VNPY_TEST_ONLY_SQLITE=1 python3 test_all.py
Loading

0 comments on commit 1257f9a

Please sign in to comment.