-
Notifications
You must be signed in to change notification settings - Fork 18
77 lines (66 loc) · 2.04 KB
/
Copy pathcoverage.yml
File metadata and controls
77 lines (66 loc) · 2.04 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
name: Coverage Report
on:
pull_request:
paths:
- "src/**"
jobs:
coverage:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Create virtual environment and install dependencies
run: |
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
- name: Run coverage on PR branch
run: |
source .venv/bin/activate
uv run pytest src/poly/tests/ --cov=poly --cov-report=json:coverage-pr.json -q
- name: Run coverage on base branch
env:
BASE_REF: ${{ github.base_ref }}
run: |
source .venv/bin/activate
PR_SHA=$(git rev-parse HEAD)
if git rev-parse --verify -q HEAD:uv.lock >/dev/null; then
git checkout -- uv.lock
fi
git checkout "origin/$BASE_REF"
uv pip install -e ".[dev]"
uv run pytest src/poly/tests/ --cov=poly --cov-report=json:coverage-base.json -q || true
if git rev-parse --verify -q HEAD:uv.lock >/dev/null; then
git checkout -- uv.lock
fi
git checkout "$PR_SHA"
- name: Generate coverage comment
env:
BASE_REF: ${{ github.base_ref }}
run: |
source .venv/bin/activate
python .github/scripts/coverage_comment.py \
coverage-base.json \
coverage-pr.json \
"$BASE_REF" > coverage_comment.md
- name: Save PR number
run: echo "${{ github.event.number }}" > pr_number.txt
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-comment
path: |
coverage_comment.md
pr_number.txt