-
Notifications
You must be signed in to change notification settings - Fork 6
90 lines (75 loc) · 2.52 KB
/
test.yml
File metadata and controls
90 lines (75 loc) · 2.52 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
name: Test
on:
push:
paths:
- 'src/**'
- 'tests/**'
- '*.py'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/test.yml'
pull_request:
workflow_dispatch:
env:
# enable colored output
PY_COLORS: 1
permissions:
contents: read
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
enable-cache: true
python-version: ${{ matrix.python-version }}
cache-dependency-glob: |
uv.lock
pyproject.toml
- name: Lock dependencies for current matrix
run: uv lock
- name: Install dependencies
run: uv sync --locked
- name: Run unit tests
run: uv run pytest -m "not integration" -v --cov=src --cov-append --cov-report=term-missing
env:
MODELSCOPE_API_TOKEN: ${{ secrets.MODELSCOPE_API_TOKEN }}
- name: Run integration tests (fast)
run: uv run pytest -m "integration and not slow" -v --cov=src --cov-append --cov-report=term-missing
env:
MODELSCOPE_API_TOKEN: ${{ secrets.MODELSCOPE_API_TOKEN }}
- name: Run integration tests (slow)
run: uv run pytest -m "integration and slow" -v -s --cov=src --cov-append --cov-report=term-missing
if: matrix.python-version == '3.12' # Only run once to reduce costs
env:
MODELSCOPE_API_TOKEN: ${{ secrets.MODELSCOPE_API_TOKEN }}
- name: Generate coverage report
run: |
echo "📊 Generating final coverage report..."
uv run coverage html
echo "📋 Coverage Summary:"
uv run coverage report
- name: Upload coverage reports
uses: actions/upload-artifact@v6
if: matrix.python-version == '3.12' # Only upload once to avoid duplicates
with:
name: coverage-report-${{ matrix.python-version }}
path: htmlcov/
retention-days: 30
- name: Display coverage summary
if: matrix.python-version == '3.12' # Only show summary once
run: |
echo "## 📊 Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
uv run coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📁 **Download detailed HTML report from Artifacts section below**" >> $GITHUB_STEP_SUMMARY
- name: Optimize uv cache for CI
run: uv cache prune --ci