Skip to content

Commit 5ffba3b

Browse files
committed
update ci/cd 2
1 parent e7084a6 commit 5ffba3b

7 files changed

Lines changed: 143 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
os: [ubuntu-latest, windows-latest, macos-latest]
30-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
31-
exclude:
32-
# Python 3.13 might not be available on all OS yet
33-
- os: windows-latest
34-
python-version: '3.13'
35-
- os: macos-latest
36-
python-version: '3.13'
30+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
31+
include:
32+
# Add Python 3.13 only for Ubuntu where it's more stable
33+
- os: ubuntu-latest
34+
python-version: '3.13-dev'
3735
# Set timeout for the entire job
3836
timeout-minutes: 30
3937

@@ -50,12 +48,12 @@ jobs:
5048
run: python -c "import sys; print(sys.version)"
5149

5250
- name: Cache pip packages
53-
uses: actions/cache@v3
51+
uses: actions/cache@v4
5452
with:
5553
path: |
5654
~/.cache/pip
5755
~/Library/Caches/pip
58-
~\AppData\Local\pip\Cache
56+
~/AppData/Local/pip/Cache
5957
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}
6058
restore-keys: |
6159
${{ runner.os }}-pip-${{ matrix.python-version }}-
@@ -69,13 +67,54 @@ jobs:
6967
- name: Install dependencies
7068
run: |
7169
pip install pytest pytest-cov pytest-xdist pytest-timeout
72-
# Install empyrical from GitHub (primary) or Gitee (fallback)
70+
pip install ipython>=7.0.0
71+
72+
- name: Install empyrical (Unix)
73+
if: runner.os != 'Windows'
74+
run: |
75+
# Try installing empyrical with retries
76+
for i in 1 2 3; do
77+
echo "Attempt $i to install empyrical..."
78+
if pip install git+https://github.com/cloudQuant/empyrical.git; then
79+
echo "Successfully installed empyrical from GitHub"
80+
break
81+
elif [ $i -eq 3 ]; then
82+
echo "GitHub failed, trying Gitee..."
83+
pip install git+https://gitee.com/yunjinqi/empyrical.git || exit 1
84+
else
85+
echo "Attempt $i failed, retrying..."
86+
sleep 5
87+
fi
88+
done
89+
90+
- name: Install empyrical (Windows)
91+
if: runner.os == 'Windows'
92+
shell: cmd
93+
run: |
7394
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
95+
96+
- name: Install pyfolio
97+
run: |
7498
pip install -e .
7599
76100
- name: Run tests with pytest
77101
run: |
78-
pytest tests/ -v --cov=pyfolio --cov-report=xml --cov-report=term -n auto
102+
pytest tests/ -v --cov=pyfolio --cov-report=xml --cov-report=term -n auto --tb=short
103+
continue-on-error: true
104+
id: pytest
105+
106+
- name: Upload test results
107+
if: always()
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: test-results-${{ matrix.os }}-${{ matrix.python-version }}
111+
path: |
112+
coverage.xml
113+
.coverage
114+
115+
- name: Check test results
116+
if: steps.pytest.outcome == 'failure'
117+
run: exit 1
79118

80119
- name: Upload coverage to Codecov
81120
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
@@ -101,8 +140,10 @@ jobs:
101140
run: |
102141
python -m pip install --upgrade pip
103142
pip install flake8 black isort mypy
143+
pip install ipython>=7.0.0
104144
# Install empyrical for linting
105145
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
146+
pip install -e .
106147
107148
- name: Lint with flake8
108149
run: |
@@ -172,8 +213,11 @@ jobs:
172213

173214
- name: Install from wheel
174215
run: |
175-
# Install empyrical first
216+
# Install dependencies first
217+
pip install ipython>=7.0.0
218+
# Install empyrical
176219
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
220+
# Install pyfolio wheel
177221
pip install dist/*.whl
178222
python -c "import pyfolio; print(f'Successfully imported pyfolio {pyfolio.__version__}')"
179223

.github/workflows/debug.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Debug CI Issues
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ debug-ci ]
7+
8+
jobs:
9+
debug:
10+
name: Debug Environment
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
python-version: ['3.11']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: System Information
26+
run: |
27+
echo "=== System Information ==="
28+
echo "OS: ${{ runner.os }}"
29+
echo "Python Version: ${{ matrix.python-version }}"
30+
python --version
31+
pip --version
32+
33+
- name: Test Git Access
34+
run: |
35+
echo "=== Testing Git Access ==="
36+
git --version
37+
git ls-remote https://github.com/cloudQuant/empyrical.git HEAD || echo "GitHub access failed"
38+
39+
- name: Test Pip Install
40+
run: |
41+
echo "=== Testing Pip Install ==="
42+
pip install --upgrade pip
43+
pip install numpy pandas matplotlib ipython
44+
45+
- name: Test Empyrical Install
46+
run: |
47+
echo "=== Testing Empyrical Install ==="
48+
pip install git+https://github.com/cloudQuant/empyrical.git --verbose || echo "Empyrical install failed"
49+
50+
- name: List Installed Packages
51+
if: always()
52+
run: |
53+
echo "=== Installed Packages ==="
54+
pip list
55+
56+
- name: Check Import
57+
if: always()
58+
run: |
59+
echo "=== Testing Imports ==="
60+
python -c "import numpy; print(f'NumPy: {numpy.__version__}')"
61+
python -c "import pandas; print(f'Pandas: {pandas.__version__}')"
62+
python -c "import empyrical; print(f'Empyrical: {empyrical.__version__}')" || echo "Empyrical import failed"

.github/workflows/quick-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
python-version: '3.11'
2828

2929
- name: Cache pip packages
30-
uses: actions/cache@v3
30+
uses: actions/cache@v4
3131
with:
3232
path: ~/.cache/pip
3333
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
@@ -38,6 +38,7 @@ jobs:
3838
run: |
3939
python -m pip install --upgrade pip
4040
pip install pytest pytest-cov pytest-xdist
41+
pip install ipython>=7.0.0
4142
# Install empyrical
4243
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
4344
pip install -e .
@@ -74,6 +75,7 @@ jobs:
7475
run: |
7576
python -m pip install --upgrade pip
7677
pip install pytest pytest-cov pytest-xdist
78+
pip install ipython>=7.0.0
7779
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
7880
pip install -e .
7981

pyfolio/tears.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@
2020
import shutil
2121
import pyfolio as pf
2222
import empyrical as ep
23-
from IPython.display import display, Markdown
23+
try:
24+
from IPython.display import display, Markdown
25+
HAS_IPYTHON = True
26+
except ImportError:
27+
HAS_IPYTHON = False
28+
# Define dummy functions for non-IPython environments
29+
def display(obj):
30+
print(obj)
31+
def Markdown(string):
32+
return string
2433
import matplotlib.gridspec as gridspec
2534
import matplotlib.pyplot as plt
2635
import numpy as np

pyfolio/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@
2121
from matplotlib.pyplot import cm
2222
import numpy as np
2323
import pandas as pd
24-
from IPython.display import display, HTML
24+
try:
25+
from IPython.display import display, HTML
26+
HAS_IPYTHON = True
27+
except ImportError:
28+
HAS_IPYTHON = False
29+
# Define dummy functions for non-IPython environments
30+
def display(obj):
31+
print(obj)
32+
def HTML(string):
33+
return string
2534
from pathlib import Path
2635
import os
2736
import pyfolio as pf

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# or
44
# pip install git+https://gitee.com/yunjinqi/empyrical.git
55
flask>=2.0.0
6+
ipython>=7.0.0
67
matplotlib>=3.0.0
78
numpy>=1.20.0
89
pandas>=1.3.0

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
install_requires=[
1818
'flask>=2.0.0',
19+
'ipython>=7.0.0',
1920
'matplotlib>=3.0.0',
2021
'numpy>=1.20.0',
2122
'pandas>=1.3.0',

0 commit comments

Comments
 (0)