-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (60 loc) · 2.61 KB
/
Copy pathcoverage.yml
File metadata and controls
66 lines (60 loc) · 2.61 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
# Based on
# python-package.yml
# and
# https://medium.com/@wkrzywiec/how-to-write-good-quality-python-code-with-github-actions-2f635a2ab09a
name: Coverage
on:
push:
branches: [ master ]
workflow_dispatch:
permissions:
contents: read
jobs:
codecov:
runs-on: ubuntu-latest
strategy:
matrix:
# The newest Python the project supports, i.e. the top of the CI matrix —
# that is where new-syntax code paths actually run. Bump this whenever the
# matrix grows; nothing else will remind you.
python-version: ["3.15"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
# 3.15 is at rc1, which the setup-python manifest marks unstable, so a bare
# "3.15" resolves to nothing without this. Becomes a no-op once 3.15 final ships.
allow-prereleases: true
- name: Install tools in CI virtualenv
run: |
python -m pip install --upgrade pip
pip install pdm
- name: Create in-project virtualenv and install dependencies
run: |
# Point PDM at the interpreter `setup-python` already installed, rather than
# letting it fetch a second one — its index has no prerelease build, so asking
# for a version like "3.15" fails while that very interpreter is on PATH.
# Ask Python for its own path: under Git Bash on Windows, `which python` gives
# an MSYS path that PDM, a native Windows program, cannot resolve.
pdm use -f "$(python -c 'import sys; print(sys.executable)')"
# "When you run pdm install the first time on a new PDM-managed project, whose Python interpreter is not decided yet,
# PDM will create a virtualenv in <project_root>/.venv, and install dependencies into it."
# https://pdm-project.org/en/latest/usage/venv/
pdm install
- name: Install coverage tool in in-project virtualenv
run: |
pdm run python -m ensurepip
# coverage must run in the same venv as the code being tested.
pdm run python -m pip install coverage
- name: Generate coverage report
run: |
pdm run python -m coverage run -m runtests
pdm run python -m coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests