Skip to content

Commit

Permalink
add workflow and update version
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGoldfarb committed Nov 30, 2021
1 parent 3df0ec0 commit ee55567
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
76 changes: 76 additions & 0 deletions .github/workflows/mplfinance_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: mplfinance Checks
on: [ push, pull_request ]
jobs:
Regression_Tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Preliminary Information
run: |
echo "The job was automatically triggered by a ${{ github.event_name }} event."
echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
echo " "
echo "github.ref = ${{ github.ref }}"
echo "github.sha = ${{ github.sha }}"
echo "github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}"
echo "github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}"
echo "github.event.pull_request.base.ref = ${{ github.event.pull_request.base.ref }}"
echo "github.event.pull_request.base.sha = ${{ github.event.pull_request.base.sha }}"
echo " "
- name: Check out repository code
uses: actions/checkout@v2

- run: echo "The ${{ github.repository }} repository has been cloned to the runner."

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install My Package
run: pip install .

- name: Run Pytest
run: python -m pytest

- run: echo "This job's status is ${{ job.status }}."

Pull_Request_Updates_Version:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install packaging
- name: Fetch base and head on PR
if: ${{ github.event.pull_request.base.sha }}
run: |
git fetch origin master ${{ github.event.pull_request.base.sha }}
git fetch origin master ${{ github.event.pull_request.head.sha }}
- name: Check that Pull Request includes updating the Version
run: |
git show ${{ github.event.pull_request.base.sha }}:src/mplfinance/_version.py > scripts/tv0.py
git show ${{ github.sha }}:src/mplfinance/_version.py > scripts/tv1.py
python scripts/version_update_check.py tv0 tv1
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
python_files = tests/*
37 changes: 37 additions & 0 deletions scripts/version_update_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import sys
import importlib
from packaging import version

if len(sys.argv) < 3:
raise RuntimeError('Got less than 2 Version Arguments!')

debug = True if (len(sys.argv) > 3 and sys.argv[3] == 'debug') else False

v0 = importlib.import_module(sys.argv[1])
pv0 = version.parse(v0.__version__)

v1 = importlib.import_module(sys.argv[2])
pv1 = version.parse(v1.__version__)

if debug:
print('sys.argv=',sys.argv)
print('v0=',v0)
print('v1=',v1)
print('pv0=',pv0)
print('pv1=',pv1)
# cmd='cat '+sys.argv[1]+'.py'
# print('os.system("'+cmd+'")')
# os.system(cmd)
# cmd='cat '+sys.argv[2]+'.py'
# print('os.system("'+cmd+'")')
# os.system(cmd)
print('v0.__version__=',v0.__version__)
print('v1.__version__=',v1.__version__)

if not pv1 > pv0:
print('ERROR: Pull Request requires mplfinance version to be updated: (Version '+str(pv1)+' is NOT greater than '+str(pv0)+')')
exit(1)
else:
print('Version was updated OK (from '+str(pv0)+' to '+str(pv1)+')')
exit(0)
2 changes: 1 addition & 1 deletion src/mplfinance/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version_info = (0, 12, 7, 'alpha', 19)
version_info = (0, 12, 8, 'beta', 0)

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

Expand Down

0 comments on commit ee55567

Please sign in to comment.