Skip to content

Commit e7084a6

Browse files
committed
update ci/cd 1
1 parent 86b08c3 commit e7084a6

4 files changed

Lines changed: 175 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master, main, develop ]
5+
branches: [ master, main, develop, '**' ]
6+
paths-ignore:
7+
- '**.md'
8+
- 'docs/**'
9+
- '.gitignore'
10+
- 'LICENSE'
611
pull_request:
712
branches: [ master, main, develop ]
13+
paths-ignore:
14+
- '**.md'
15+
- 'docs/**'
16+
- '.gitignore'
17+
- 'LICENSE'
818
schedule:
919
# Run tests once a week to catch dependency issues
1020
- cron: '0 0 * * 0'
@@ -24,6 +34,8 @@ jobs:
2434
python-version: '3.13'
2535
- os: macos-latest
2636
python-version: '3.13'
37+
# Set timeout for the entire job
38+
timeout-minutes: 30
2739

2840
steps:
2941
- uses: actions/checkout@v4
@@ -37,6 +49,18 @@ jobs:
3749
- name: Display Python version
3850
run: python -c "import sys; print(sys.version)"
3951

52+
- name: Cache pip packages
53+
uses: actions/cache@v3
54+
with:
55+
path: |
56+
~/.cache/pip
57+
~/Library/Caches/pip
58+
~\AppData\Local\pip\Cache
59+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }}
60+
restore-keys: |
61+
${{ runner.os }}-pip-${{ matrix.python-version }}-
62+
${{ runner.os }}-pip-
63+
4064
- name: Upgrade pip
4165
run: |
4266
python -m pip install --upgrade pip
@@ -156,15 +180,15 @@ jobs:
156180
- name: Test basic functionality
157181
run: |
158182
python -c "
159-
import pyfolio
160-
import pandas as pd
161-
import numpy as np
162-
# Create sample returns
163-
dates = pd.date_range('2020-01-01', periods=252, freq='D')
164-
returns = pd.Series(np.random.randn(252) * 0.01, index=dates)
165-
# Test basic stats computation
166-
print('Testing pyfolio basic functionality...')
167-
print(f'Annual return: {pyfolio.timeseries.annual_return(returns):.2%}')
168-
print(f'Sharpe ratio: {pyfolio.timeseries.sharpe_ratio(returns):.2f}')
169-
print('Basic functionality test passed!')
170-
"
183+
import pyfolio
184+
import pandas as pd
185+
import numpy as np
186+
# Create sample returns
187+
dates = pd.date_range('2020-01-01', periods=252, freq='D')
188+
returns = pd.Series(np.random.randn(252) * 0.01, index=dates)
189+
# Test basic stats computation
190+
print('Testing pyfolio basic functionality...')
191+
print(f'Annual return: {pyfolio.timeseries.annual_return(returns):.2%}')
192+
print(f'Sharpe ratio: {pyfolio.timeseries.sharpe_ratio(returns):.2f}')
193+
print('Basic functionality test passed!')
194+
"

.github/workflows/quick-test.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Quick Test
2+
3+
# Trigger on any push to any branch
4+
on:
5+
push:
6+
# Run on all branches
7+
branches: '**'
8+
# Skip if only documentation files are changed
9+
paths-ignore:
10+
- '**.md'
11+
- 'docs/**'
12+
- '.gitignore'
13+
- 'LICENSE'
14+
- '.github/workflows/manual-test.yml'
15+
16+
jobs:
17+
quick-test:
18+
name: Quick Test - Python 3.11 on Ubuntu
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Python 3.11
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.11'
28+
29+
- name: Cache pip packages
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
37+
- name: Install dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install pytest pytest-cov pytest-xdist
41+
# Install empyrical
42+
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
43+
pip install -e .
44+
45+
- name: Run tests
46+
run: |
47+
pytest tests/ -v -x --tb=short -n auto
48+
49+
- name: Test import
50+
run: |
51+
python -c "import pyfolio; print(f'Successfully imported pyfolio {pyfolio.__version__}')"
52+
53+
# Run full matrix test only on main branches
54+
full-test:
55+
name: Full Test - ${{ matrix.python-version }} on ${{ matrix.os }}
56+
needs: quick-test
57+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
58+
runs-on: ${{ matrix.os }}
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
os: [ubuntu-latest, windows-latest, macos-latest]
63+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Set up Python ${{ matrix.python-version }}
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
73+
- name: Install dependencies
74+
run: |
75+
python -m pip install --upgrade pip
76+
pip install pytest pytest-cov pytest-xdist
77+
pip install git+https://github.com/cloudQuant/empyrical.git || pip install git+https://gitee.com/yunjinqi/empyrical.git
78+
pip install -e .
79+
80+
- name: Run tests
81+
run: |
82+
pytest tests/ -v --cov=pyfolio --cov-report=term

.github/workflows/status.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build Status
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
status:
11+
name: Update Status Badge
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Update README with test status
17+
run: echo "Tests are configured and running automatically"

test_ci_locally.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# Local CI test script
3+
4+
echo "Testing CI configuration locally..."
5+
6+
# Colors for output
7+
GREEN='\033[0;32m'
8+
RED='\033[0;31m'
9+
NC='\033[0m' # No Color
10+
11+
# Test Python version
12+
echo -e "\n${GREEN}Testing with Python:${NC}"
13+
python --version
14+
15+
# Install empyrical
16+
echo -e "\n${GREEN}Installing empyrical...${NC}"
17+
pip install git+https://github.com/cloudQuant/empyrical.git || {
18+
echo -e "${RED}Failed to install from GitHub, trying Gitee...${NC}"
19+
pip install git+https://gitee.com/yunjinqi/empyrical.git
20+
}
21+
22+
# Install dependencies
23+
echo -e "\n${GREEN}Installing dependencies...${NC}"
24+
pip install -r requirements.txt
25+
pip install -r requirements-dev.txt
26+
27+
# Install pyfolio
28+
echo -e "\n${GREEN}Installing pyfolio...${NC}"
29+
pip install -e .
30+
31+
# Run tests
32+
echo -e "\n${GREEN}Running tests...${NC}"
33+
pytest tests/ -v -x --tb=short
34+
35+
# Run linting
36+
echo -e "\n${GREEN}Running linting...${NC}"
37+
flake8 pyfolio --count --select=E9,F63,F7,F82 --show-source --statistics || echo "Linting issues found"
38+
39+
echo -e "\n${GREEN}Local CI test completed!${NC}"

0 commit comments

Comments
 (0)