-
Notifications
You must be signed in to change notification settings - Fork 18
106 lines (87 loc) · 2.54 KB
/
python-ci.yml
File metadata and controls
106 lines (87 loc) · 2.54 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
# Building and testing Python
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
lint:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Lint commit messages
uses: wagoid/commitlint-github-action@v6.2.1
- name: Set up uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v6.2.0
with:
python-version-file: ".python-version"
- name: Install lint dependencies
run: |
uv venv
uv pip install --group lint
- name: Lint with Flake8
run: |
uv run flake8 .
- name: Check code formatting with Black
run: |
uv run black --check .
test:
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Set up uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v6.2.0
with:
python-version-file: ".python-version"
- name: Install test dependencies
run: |
uv venv
uv pip install --group dev
- name: Run tests with pytest
run: |
uv run pytest -v
- name: Generate coverage report
run: |
uv run pytest --cov=./ --cov-report=xml --cov-report=term
- name: Upload coverage report artifact
uses: actions/upload-artifact@v7.0.0
with:
name: coverage.xml
path: ./coverage.xml
coverage:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
# Only run coverage for PRs from the same repository (not forks)
# This ensures secrets are available for Codecov
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Download coverage report artifact
uses: actions/download-artifact@v8.0.0
with:
name: coverage.xml
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml