Skip to content

Commit

Permalink
Merge pull request #44 from corriporai/develop
Browse files Browse the repository at this point in the history
BLD: Change from Travis CI to Github CI and ENH: Support to Heart Training Zones metrics  #38 #12
  • Loading branch information
marcelcaraciolo authored May 24, 2021
2 parents 811b2d7 + 65b9928 commit 47c77bd
Show file tree
Hide file tree
Showing 10 changed files with 470 additions and 84 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# .coveragerc to control coverage.py
[run]
source = runpandas
relative_files = True
branch = True
include = */runpandas/*
omit =
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Build

on:
push:
branches:
- master
- develop
pull_request:
branches: [master]

jobs:
Linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]

Test:
needs: Linting
name: ${{ matrix.os }}, ${{ matrix.env }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- env: "PANDAS=0.24 NUMPY=1.16 PYTHON=3.6"
os: ubuntu-latest
PANDAS: '0.24'
NUMPY: '1.16'
python-version: '3.6'
- env: "PANDAS=0.25 NUMPY=1.17 PYTHON=3.7 DOCBUILD=true"
os: ubuntu-latest
PANDAS: '0.25'
NUMPY: '1.17'
python-version: '3.7'
- env: "PANDAS=0.25 NUMPY=1.18 PYTHON=3.7"
os: ubuntu-latest
PANDAS: '0.25'
NUMPY: '1.18'
python-version: '3.7'
- env: "PANDAS=1 NUMPY=1.18 PYTHON=3.8"
os: ubuntu-latest
PANDAS: '1'
NUMPY: '1.18'
python-version: '3.8'
- env: "PANDAS=1 NUMPY=1.19 PYTHON=3.8"
os: ubuntu-latest
PANDAS: '1'
NUMPY: '1.19'
python-version: '3.8'
- env: "PANDAS=MASTER NUMPY=1.18 PYTHON=3.7"
os: ubuntu-latest
PANDAS: 'MASTER'
NUMPY: '1.18'
python-version: '3.7'
- env: "PANDAS=1 NUMPY=1.18 PYTHON=3.8"
os: macos-latest
PANDAS: '1'
NUMPY: '1.18'
python-version: '3.8'
- env: "PANDAS=1 NUMPY=1.18 PYTHON=3.8"
os: windows-latest
PANDAS: '1'
NUMPY: '1.18'
python-version: '3.8'
- env: "PANDAS=1 NUMPY=1.18 PYTHON=3.7"
os: macos-latest
PANDAS: '1'
NUMPY: '1.18'
python-version: '3.7'
- env: "PANDAS=1 NUMPY=1.18 PYTHON=3.7"
os: windows-latest
PANDAS: '1'
NUMPY: '1.18'
python-version: '3.7'

steps:
- uses: actions/checkout@v2

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

- name: Setup Environment
shell: bash
run: |
source ci/pypi-installer.sh;
pip install -e .
pip install -r requirements-dev.txt
python -V
pip list
python -c "import runpandas; runpandas.__version__;"
env:
PANDAS: ${{ matrix.PANDAS }}
NUMPY: ${{ matrix.NUMPY }}

- name: Test with Pytest
shell: bash
run: |
source ci/pypi-installer.sh;
pytest -v -s -r xX -m stable --cov-config .coveragerc --cov=runpandas --cov-report xml:/tmp/cov-runpandas.xml --junitxml=/tmp/runpandas.xml
env:
PANDAS: ${{ matrix.PANDAS }}
NUMPY: ${{ matrix.NUMPY }}

- uses: codecov/codecov-action@v1
if: startsWith(matrix.os, 'ubuntu')

- name: Coveralls
if: startsWith(matrix.os, 'ubuntu')
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: Unit Test

coveralls_finish:
needs: Test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
78 changes: 78 additions & 0 deletions .github/workflows/readthedocs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""
Trigger ReadTheDocs documentation build and check response for confirmation
"""

import os
import time
import requests

URL = 'https://readthedocs.org/api/v3/projects/runpandas'
TOKEN = os.getenv('READTHEDOCS_TOKEN')
HEADERS = {
'Authorization': f'Token {TOKEN}',
'Content-Length': '0',
}


def build_status(build_id: str) -> str:
"""
Use ReadTheDocs API to check build status until either failed or succeeds. The function checks the status in 30s
intervals. Stop process after max. 3min.
Response field state - code can have the following values: triggered, cloning, installing, building, finished and
failed (check TBD)
"""

max_min = 3
status = 'triggered'

i = 0
while True:
i += 1
time.sleep(30)

response = requests.get(f'{URL}/builds/{build_id}/', headers=HEADERS)
response = response.json()

if response['success'] is True:
status = 'finished'
break
elif response['success'] is False:
status = 'failed'
break

if i == 2*max_min:
break

return status


def main():
response = requests.post(f'{URL}/versions/latest/builds/', headers=HEADERS)
response = response.json()

if response['triggered']:
print('ReadTheDocs build successfully triggered.')
print(f"Build id: {response['build']['id']}")
print(f"Branch: {response['version']['identifier']}")
print(f"Version: {response['build']['version']}")

build_id = response['build']['id']
status = build_status(build_id)

if status == 'finished':
print('ReadTheDocs build successfully finished.')
return 0
if status == 'triggered':
print('ReadTheDocs build still ongoing... Please check manually.')
return 0
if status == 'failed':
print('ReadTheDocs build failed.')
return 1
else:
print('ReadTheDocs build triggering failed.')
return 1


if __name__ == '__main__':
main()
52 changes: 52 additions & 0 deletions .github/workflows/readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Build documentation of ReadTheDocs

name: Document on ReadTheDocs
# TODO: Check running criteria for script
on:
push:
branches:
- master
- develop

jobs:
document:
name: Documentation build on ReadTheDocs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: Setup Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
PANDAS: "0.25"
NUMPY: "1.17"

- name: Install required packages
run: |
source ci/pypi-installer.sh;
pip install -e .
pip install -r requirements-dev.txt
pip install -r docs/requirements.txt
pip install requests
pip list
python -c "import runpandas; runpandas.__version__;"
env:
PANDAS: "0.25"
NUMPY: "1.17"

- name: setup pandoc
uses: r-lib/actions/setup-pandoc@v1
with:
pandoc-version: '2.7.3' # The pandoc version to download (if necessary) and use.

- name: Trigger documentation build
run: |
set -e
cd docs
make html
cd ..
python .github/workflows/readthedocs.py
env:
READTHEDOCS_TOKEN: ${{ secrets.readthedocs_token }}
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

files: 'runpandas\/'
repos:
- repo: https://github.com/python/black
rev: stable
hooks:
- id: black
language_version: python3.7
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
rev: 3.8.3
hooks:
- id: flake8
language: python_venv
language: python_venv



66 changes: 0 additions & 66 deletions .travis.yml

This file was deleted.

9 changes: 2 additions & 7 deletions ci/pypi-installer.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#!/usr/bin/env bash

pip install pip --upgrade
pip install pip --upgrade --user
pip install numpy=="$NUMPY" lxml
pip install -r requirements-dev.txt

if [[ "$PANDAS" == "MASTER" ]]; then
PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com"
pip install --pre --upgrade --timeout=60 -f "$PRE_WHEELS" pandas
pip install --pre --upgrade --timeout=60 -f "$PRE_WHEELS" pandas --user
else
pip install pandas=="$PANDAS"
fi

if [[ "$DOCBUILD" ]]; then
pip install doctr
pip install -r docs/requirements.txt
fi
Loading

0 comments on commit 47c77bd

Please sign in to comment.