forked from usra-riacs/stochastic-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 2
183 lines (157 loc) · 5.87 KB
/
Copy pathci.yml
File metadata and controls
183 lines (157 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-xdist
pip install pandas numpy scipy matplotlib seaborn
pip install networkx tqdm multiprocess
# Install optional dependencies for extended functionality
pip install hyperopt || echo "hyperopt installation failed, continuing..."
pip install cloudpickle dill || echo "pickle dependencies failed, continuing..."
# Install package in development mode
pip install -e .
- name: Lint with flake8 (optional)
run: |
pip install flake8
# Stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings. Increase line-length for compatibility
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
continue-on-error: true
- name: Run tests with pytest
run: |
# Set PYTHONPATH to include src directory
export PYTHONPATH="${PYTHONPATH}:${PWD}/src"
# Run tests with coverage
pytest tests/ -v --cov=src --cov-report=xml --cov-report=html --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Generate coverage summary
run: |
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Coverage report generated for commit ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
coverage report >> $GITHUB_STEP_SUMMARY || echo "Coverage report generation failed" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
- name: Archive coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-reports-${{ matrix.python-version }}
path: |
coverage.xml
htmlcov/
retention-days: 30
integration-tests:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas numpy scipy matplotlib seaborn
pip install networkx tqdm multiprocess
pip install pytest
pip install -e .
- name: Run integration tests
run: |
export PYTHONPATH="${PYTHONPATH}:${PWD}/src"
# Run any integration tests (if they exist)
if [ -d "tests/integration" ]; then
pytest tests/integration/ -v
else
echo "No integration tests found"
fi
coverage-summary:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install pandas numpy scipy matplotlib seaborn
pip install networkx tqdm multiprocess
pip install -e .
- name: Generate final coverage report
run: |
export PYTHONPATH="${PYTHONPATH}:${PWD}/src"
pytest tests/ -v --cov=src --cov-report=term --cov-report=html
echo "## 📊 Final Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Overall Coverage Statistics" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
coverage report --skip-covered >> $GITHUB_STEP_SUMMARY 2>&1 || echo "Coverage report failed" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Coverage by Module" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
coverage report --include="src/*" >> $GITHUB_STEP_SUMMARY 2>&1 || echo "Module coverage report failed" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📈 **Detailed HTML coverage report is available in the artifacts**" >> $GITHUB_STEP_SUMMARY
- name: Upload final coverage artifacts
uses: actions/upload-artifact@v4
with:
name: final-coverage-report
path: |
htmlcov/
retention-days: 30
- name: Test examples (smoke tests)
run: |
export PYTHONPATH="${PYTHONPATH}:${PWD}/src"
# Basic smoke tests to ensure examples don't crash
python -c "
import sys
sys.path.insert(0, 'src')
try:
import stochastic_benchmark
import bootstrap
import plotting
import stats
import names
print('All main modules import successfully')
except ImportError as e:
print(f'Import error: {e}')
sys.exit(1)
"