Skip to content

Commit 77b47b0

Browse files
authored
MNT: Migrate Travis CI to GitHub Actions (#163)
* MNT: Migrate Travis CI to GitHub Actions Travis has constant backlog and its build sometimes fails to fire. Long live GH Actions! :/ * Copy deploying tags docs into a separate workflow * fix yml: https://github.com/kernc/backtesting.py/actions/runs/332715564 * fix docs build with -e * pip install wheel * it's late * Make test type a parameter, becasuse it's shown in the UI * Remove Py3.9 testing: It's new and weird https://github.com/kernc/backtesting.py/runs/1318477083 * Fetch tags for correct __version__ * test deploy-docs workflow ... * mark .github/deploy-gh-pages.sh executable * give 'fetch tags' step a name * goddamn debug * set github-actions git credentials * undo 'test deploy-docs workflow' * DOC: Update 'Build: Passing' link in README * MNT: Bump minimal Python to 3.6+ in setup.py * DOC: Bump mentions to Python 3.6+ * move lint deps to setup.py [dev] group
1 parent 028f02d commit 77b47b0

File tree

9 files changed

+127
-59
lines changed

9 files changed

+127
-59
lines changed

.github/deploy-gh-pages.sh

100644100755
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sitemap() {
2020

2121
head=$(git rev-parse HEAD)
2222

23-
git clone -b gh-pages "https://kernc:$GH_PASSWORD@github.com/$TRAVIS_REPO_SLUG.git" gh-pages
23+
git clone -b gh-pages "https://kernc:$GH_PASSWORD@github.com/$GITHUB_REPOSITORY.git" gh-pages
2424
mkdir -p gh-pages/doc
2525
cp -R doc/build/* gh-pages/doc/
2626
cd gh-pages
@@ -30,5 +30,11 @@ if git diff --staged --quiet; then
3030
echo "$0: No changes to commit."
3131
exit 0
3232
fi
33-
git commit -a -m "CI: Update docs for $TRAVIS_TAG ($head)"
33+
34+
if ! git config user.name; then
35+
git config user.name 'github-actions'
36+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
37+
fi
38+
39+
git commit -a -m "CI: Update docs for ${GITHUB_REF#refs/tags/} ($head)"
3440
git push

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
on:
3+
push: { branches: [master] }
4+
pull_request: { branches: [master] }
5+
schedule: [ cron: '2 2 * * 6' ] # Every Saturday, 02:02
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-18.04
11+
12+
strategy:
13+
matrix:
14+
python-version: [3.6, 3.7]
15+
include:
16+
- python-version: 3.8
17+
test-type: lint
18+
- python-version: 3.8
19+
test-type: docs
20+
21+
steps:
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- uses: actions/cache@v2
28+
name: Set up caches
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-py${{ matrix.python-version }}
32+
33+
- name: Checkout repo
34+
uses: actions/checkout@v2
35+
with:
36+
fetch-depth: 3
37+
- name: Fetch tags
38+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
39+
40+
- name: Install dependencies
41+
run: |
42+
pip install -U pip setuptools wheel
43+
pip install -U --pre .[test]
44+
45+
- name: Install lint dependencies
46+
if: matrix.test-type == 'lint'
47+
run: pip install -U .[dev]
48+
49+
- name: Install docs dependencies
50+
if: matrix.test-type == 'docs'
51+
run: pip install -e .[doc,test] # -e provides _version.py for pdoc
52+
53+
- name: Test w/ Coverage, Lint
54+
if: matrix.test-type == 'lint'
55+
env: { BOKEH_BROWSER: none }
56+
run: |
57+
flake8
58+
mypy backtesting
59+
time catchsegv coverage run -m backtesting.test
60+
bash <(curl -s https://codecov.io/bash)
61+
62+
- name: Test
63+
if: '! matrix.test-type'
64+
env: { BOKEH_BROWSER: none }
65+
run: time catchsegv python -m backtesting.test
66+
67+
- name: Test docs
68+
if: matrix.test-type == 'docs'
69+
run: time catchsegv doc/build.sh

.github/workflows/deploy-docs.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy docs
2+
on:
3+
push:
4+
tags: ['[0-9]+.[0-9]+.*']
5+
6+
jobs:
7+
deploy:
8+
name: Deploy
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.8
16+
17+
- uses: actions/cache@v2
18+
name: Set up caches
19+
with:
20+
path: ~/.cache/pip
21+
key: ${{ runner.os }}
22+
23+
- name: Checkout repo
24+
uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 3
27+
- name: Fetch tags
28+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
29+
30+
- name: Install dependencies
31+
run: |
32+
pip install -U pip setuptools wheel
33+
pip install -U .[doc,test]
34+
35+
- name: Build docs
36+
run: time catchsegv doc/build.sh
37+
38+
- name: Deploy docs
39+
env:
40+
GH_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
41+
run: .github/deploy-gh-pages.sh

.travis.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Backtesting.py
44
==============
5-
[![Build Status](https://img.shields.io/travis/kernc/backtesting.py.svg?style=for-the-badge)](https://travis-ci.org/kernc/backtesting.py)
5+
[![Build Status](https://img.shields.io/github/workflow/status/kernc/backtesting.py/ci/master?style=for-the-badge)](https://github.com/kernc/backtesting.py/actions)
66
[![Code Coverage](https://img.shields.io/codecov/c/gh/kernc/backtesting.py.svg?style=for-the-badge)](https://codecov.io/gh/kernc/backtesting.py)
77
[![Backtesting on PyPI](https://img.shields.io/pypi/v/backtesting.svg?color=blue&style=for-the-badge)](https://pypi.org/project/backtesting)
88

backtesting/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
try:
4949
from ._version import version as __version__ # noqa: F401
5050
except ImportError:
51-
pass # Package not installed
51+
__version__ = '?.?.?' # Package not installed
5252

5353
from .backtesting import Backtest, Strategy # noqa: F401
5454
from . import lib # noqa: F401

doc/examples/Quick Start User Guide.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"\n",
1010
"This tutorial shows some of the features of *backtesting.py*, a Python framework for [backtesting](https://www.investopedia.com/terms/b/backtesting.asp) trading strategies.\n",
1111
"\n",
12-
"_Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.5+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool.\n",
12+
"_Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.6+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool.\n",
1313
"\n",
1414
"\n",
1515
"## Data\n",

doc/examples/Quick Start User Guide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
# This tutorial shows some of the features of *backtesting.py*, a Python framework for [backtesting](https://www.investopedia.com/terms/b/backtesting.asp) trading strategies.
2020
#
21-
# _Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.5+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool.
21+
# _Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python structures and procedures (Python 3.6+, Pandas, NumPy, Bokeh). It has a very small and simple API that is easy to remember and quickly shape towards meaningful results. The library _doesn't_ really support stock picking or trading strategies that rely on arbitrage or multi-asset portfolio rebalancing; instead, it works with an individual tradeable asset at a time and is best suited for optimizing position entrance and exit signal strategies, decisions upon values of technical indicators, and it's also a versatile interactive trade visualization and statistics tool.
2222
#
2323
#
2424
# ## Data

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22
import sys
33

4-
if sys.version_info < (3, 4):
5-
sys.exit('ERROR: Backtesting.py requires Python 3.4+')
4+
if sys.version_info < (3, 6):
5+
sys.exit('ERROR: Backtesting.py requires Python 3.6+')
66

77

88
if __name__ == '__main__':
@@ -31,7 +31,6 @@
3131
'write_to': os.path.join('backtesting', '_version.py'),
3232
},
3333
install_requires=[
34-
'typing ; python_version < "3.5"',
3534
'numpy',
3635
'pandas >= 0.25.0, != 0.25.0',
3736
'bokeh >= 1.4.0',
@@ -51,10 +50,12 @@
5150
],
5251
'dev': [
5352
'flake8',
53+
'coverage',
54+
'mypy',
5455
],
5556
},
5657
test_suite="backtesting.test",
57-
python_requires='>=3.4',
58+
python_requires='>=3.6',
5859
author='Zach Lûster',
5960
classifiers=[
6061
'Intended Audience :: Financial and Insurance Industry',

0 commit comments

Comments
 (0)