-
Notifications
You must be signed in to change notification settings - Fork 3
80 lines (72 loc) · 2.83 KB
/
upload_coverage.yml
File metadata and controls
80 lines (72 loc) · 2.83 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
name: Upload coverage
on:
workflow_call:
inputs:
fail-on-coverage-error:
required: false
type: boolean
default: true
description: Fail if codecov action fails.
artifact-pattern:
required: false
type: string
default: covreport-*
description: >
glob pattern to the artifacts that should be downloaded for coverage reports.
This should match the `name` you used for the `upload-artifact` step in the
job that generates the coverage reports.
(*This default matches the name in test-pyrepo.yml*)
secrets:
codecov_token:
required: false
description: Token for codecov-action.
jobs:
upload_coverage:
name: Upload coverage
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v6
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
python-version: '3.12'
activate-environment: true
- name: Install coverage
run: uv pip install coverage
- name: Download coverage data
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: ${{ inputs.artifact-pattern }}
path: covreports
merge-multiple: true
- name: Combine coverage data
run: |
REPO_NAME="${GITHUB_REPOSITORY##*/}"
echo "[paths]" > ci_coveragerc
echo "source =" >> ci_coveragerc
# if src exists, add it to the pathmap
if [ -d "src" ]; then
echo " src/" >> ci_coveragerc
echo " D:\\a\\$REPO_NAME\\$REPO_NAME\\src" >> ci_coveragerc
echo " /home/runner/work/$REPO_NAME/$REPO_NAME/src" >> ci_coveragerc
echo " /Users/runner/work/$REPO_NAME/$REPO_NAME/src" >> ci_coveragerc
else
echo " ${GITHUB_WORKSPACE}" >> ci_coveragerc
echo " D:\\a\\$REPO_NAME\\$REPO_NAME" >> ci_coveragerc
echo " /home/runner/work/$REPO_NAME/$REPO_NAME" >> ci_coveragerc
echo " /Users/runner/work/$REPO_NAME/$REPO_NAME" >> ci_coveragerc
fi
echo " */site-packages/" >> ci_coveragerc
cat ci_coveragerc
python -Im coverage combine --rcfile=ci_coveragerc covreports
python -Im coverage xml -o coverage.xml
python -Im coverage report
python -Im coverage report --format=markdown --skip-empty --skip-covered >> $GITHUB_STEP_SUMMARY
- name: Upload to codecov
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
with:
fail_ci_if_error: ${{ inputs.fail-on-coverage-error }}
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}