-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (170 loc) · 6.1 KB
/
Copy pathci.yml
File metadata and controls
195 lines (170 loc) · 6.1 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
184
185
186
187
188
189
190
191
192
193
194
195
name: CI
on:
push:
branches: [ master, main, develop ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
jobs:
lint:
name: Lint (Python 3.12)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Cache pip packages
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "numpy>=2.0.0,<3.0"
pip install meson-python>=0.15.0
pip install meson>=1.2.0
pip install ninja
pip install cython>=3.0
pip install tempita>=0.5.2
pip install pylint
pip install -e . --no-build-isolation
- name: Run pylint
run: |
mkdir -p _testing_output
pylint redblackgraph --rcfile=.pylintrc -d C,R | tee _testing_output/pylint_output.txt
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('**/pyproject.toml', '**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-py${{ matrix.python-version }}-pip-
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install "numpy>=2.0.0,<3.0"
pip install meson-python>=0.15.0
pip install meson>=1.2.0
pip install ninja
pip install cython>=3.0
pip install tempita>=0.5.2 # Required for template processing
- name: Install project with test dependencies
run: |
pip install -e ".[test]" --no-build-isolation
- name: Create output directory
run: mkdir -p _testing_output
- name: Run tests with coverage
run: |
export GIT_HASH=$(git log --pretty=format:'%h' -n 1)
echo "GIT_HASH: $GIT_HASH" > _testing_output/pytest_output.txt
pytest --color=yes \
--cov-config coverage.cfg \
--cov=redblackgraph \
--cov-fail-under=65 \
--cov-report term-missing \
--cov-report xml:coverage.xml \
--cov-report html:_testing_output/coverage_html \
--durations=10 \
tests | tee -a _testing_output/pytest_output.txt
- name: Generate coverage summary
if: always()
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: true
format: markdown
output: both
fail_below_min: true
thresholds: '65 80'
- name: Add coverage to job summary
if: always()
run: |
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Coverage Report for Python ${{ matrix.python-version }}" >> $GITHUB_STEP_SUMMARY
echo "Full HTML coverage report is available in artifacts." >> $GITHUB_STEP_SUMMARY
- name: Add coverage PR comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: code-coverage-results.md
- name: Upload coverage report artifact
if: always()
uses: actions/upload-artifact@v5
with:
name: coverage-report-py${{ matrix.python-version }}
path: |
coverage.xml
_testing_output/coverage_html/
retention-days: 30
- name: Upload test results
if: always()
uses: actions/upload-artifact@v5
with:
name: test-results-py${{ matrix.python-version }}
path: _testing_output/
retention-days: 30
coverage-badge:
name: Update Coverage Badge
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Download coverage report
uses: actions/download-artifact@v5
with:
name: coverage-report-py3.12
- name: Extract coverage percentage
id: coverage
run: |
# Extract coverage from XML
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(f\"{float(root.attrib['line-rate']) * 100:.1f}\")")
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
echo "Coverage: $COVERAGE%"
- name: Create coverage badge
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.COVERAGE_GIST_ID }}
filename: redblackgraph-coverage.json
label: coverage
message: ${{ steps.coverage.outputs.percentage }}%
valColorRange: ${{ steps.coverage.outputs.percentage }}
maxColorRange: 100
minColorRange: 0
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [lint, test]
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test.result }}" == "failure" ] || [ "${{ needs.lint.result }}" == "failure" ]; then
echo "❌ Tests or linting failed"
exit 1
else
echo "✅ All tests and linting passed"
fi