Skip to content

Commit ee55567

Browse files
add workflow and update version
1 parent 3df0ec0 commit ee55567

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: mplfinance Checks
2+
on: [ push, pull_request ]
3+
jobs:
4+
Regression_Tests:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: [3.6, 3.7, 3.8, 3.9]
9+
steps:
10+
- name: Preliminary Information
11+
run: |
12+
echo "The job was automatically triggered by a ${{ github.event_name }} event."
13+
echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
14+
echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
15+
echo " "
16+
echo "github.ref = ${{ github.ref }}"
17+
echo "github.sha = ${{ github.sha }}"
18+
echo "github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}"
19+
echo "github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}"
20+
echo "github.event.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}"
21+
echo "github.event.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}"
22+
echo " "
23+
24+
- name: Check out repository code
25+
uses: actions/checkout@v2
26+
27+
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install pytest
38+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
39+
40+
- name: Install My Package
41+
run: pip install .
42+
43+
- name: Run Pytest
44+
run: python -m pytest
45+
46+
- run: echo "This job's status is ${{ job.status }}."
47+
48+
Pull_Request_Updates_Version:
49+
runs-on: ubuntu-latest
50+
if: github.event_name == 'pull_request'
51+
steps:
52+
- name: Check out repository code
53+
uses: actions/checkout@v2
54+
55+
- name: Set up Python ${{ matrix.python-version }}
56+
uses: actions/setup-python@v2
57+
with:
58+
python-version: '3.10'
59+
60+
- name: Install dependencies
61+
run: |
62+
python -m pip install --upgrade pip
63+
pip install packaging
64+
65+
- name: Fetch base and head on PR
66+
if: ${{ github.event.pull_request.base.sha }}
67+
run: |
68+
git fetch origin master ${{ github.event.pull_request.base.sha }}
69+
git fetch origin master ${{ github.event.pull_request.head.sha }}
70+
71+
- name: Check that Pull Request includes updating the Version
72+
run: |
73+
git show ${{ github.event.pull_request.base.sha }}:src/mplfinance/_version.py > scripts/tv0.py
74+
git show ${{ github.sha }}:src/mplfinance/_version.py > scripts/tv1.py
75+
python scripts/version_update_check.py tv0 tv1
76+

pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
python_files = tests/*

scripts/version_update_check.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import sys
3+
import importlib
4+
from packaging import version
5+
6+
if len(sys.argv) < 3:
7+
raise RuntimeError('Got less than 2 Version Arguments!')
8+
9+
debug = True if (len(sys.argv) > 3 and sys.argv[3] == 'debug') else False
10+
11+
v0 = importlib.import_module(sys.argv[1])
12+
pv0 = version.parse(v0.__version__)
13+
14+
v1 = importlib.import_module(sys.argv[2])
15+
pv1 = version.parse(v1.__version__)
16+
17+
if debug:
18+
print('sys.argv=',sys.argv)
19+
print('v0=',v0)
20+
print('v1=',v1)
21+
print('pv0=',pv0)
22+
print('pv1=',pv1)
23+
# cmd='cat '+sys.argv[1]+'.py'
24+
# print('os.system("'+cmd+'")')
25+
# os.system(cmd)
26+
# cmd='cat '+sys.argv[2]+'.py'
27+
# print('os.system("'+cmd+'")')
28+
# os.system(cmd)
29+
print('v0.__version__=',v0.__version__)
30+
print('v1.__version__=',v1.__version__)
31+
32+
if not pv1 > pv0:
33+
print('ERROR: Pull Request requires mplfinance version to be updated: (Version '+str(pv1)+' is NOT greater than '+str(pv0)+')')
34+
exit(1)
35+
else:
36+
print('Version was updated OK (from '+str(pv0)+' to '+str(pv1)+')')
37+
exit(0)

src/mplfinance/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
version_info = (0, 12, 7, 'alpha', 19)
2+
version_info = (0, 12, 8, 'beta', 0)
33

44
_specifier_ = {'alpha': 'a','beta': 'b','candidate': 'rc','final': ''}
55

0 commit comments

Comments
 (0)