Skip to content

Commit c871e77

Browse files
CI: only run coverage once
1 parent 9d6175e commit c871e77

1 file changed

Lines changed: 77 additions & 59 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 77 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -32,75 +32,93 @@ jobs:
3232
strategy:
3333
matrix:
3434
python-version:
35-
- '3.10'
36-
- '3.11'
37-
- '3.12'
38-
- '3.13'
39-
- '3.14'
35+
- "3.10"
36+
- "3.11"
37+
- "3.12"
38+
- "3.13"
39+
- "3.14"
4040
os:
41-
- 'ubuntu-latest'
42-
- 'windows-latest'
43-
- 'macos-latest'
41+
- "ubuntu-latest"
42+
- "windows-latest"
43+
- "macos-latest"
4444
runs-on: ${{ matrix.os }}
4545
steps:
46-
- uses: actions/checkout@v6
47-
- name: Set up Python
48-
uses: actions/setup-python@v6
49-
with:
50-
python-version: ${{ matrix.python-version }}
51-
- name: Install uv
52-
uses: astral-sh/setup-uv@v7
53-
with:
54-
enable-cache: true
55-
- name: Test with pytest
56-
run: |
57-
uv run coverage run -m pytest
58-
- name: Print coverage output
59-
run: |
60-
uv run coverage report
61-
- name: Generate code coverage report
62-
if: ${{ github.event_name == 'pull_request' }}
63-
run: |
64-
uv run coverage xml
65-
- name: Create code coverage comment
66-
if: ${{ github.event_name == 'pull_request' }}
67-
uses: orgoro/coverage@v3
68-
with:
69-
coverageFile: coverage.xml
70-
token: ${{ secrets.GITHUB_TOKEN }}
46+
- uses: actions/checkout@v6
47+
- name: Set up Python
48+
uses: actions/setup-python@v6
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v7
53+
with:
54+
enable-cache: true
55+
- name: Test with pytest
56+
run: |
57+
uv run pytest
58+
59+
# Only run coverage once
60+
Coverage:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v6
64+
- name: Set up Python
65+
uses: actions/setup-python@v6
66+
with:
67+
# Pinned Python version
68+
python-version-file: ".python-version"
69+
- name: Install uv
70+
uses: astral-sh/setup-uv@v7
71+
with:
72+
enable-cache: true
73+
- name: Pytest with coverage
74+
run: |
75+
uv run coverage run -m pytest
76+
- name: Print coverage output
77+
run: |
78+
uv run coverage report
79+
- name: Generate code coverage report
80+
if: ${{ github.event_name == 'pull_request' }}
81+
run: |
82+
uv run coverage xml
83+
- name: Create code coverage comment
84+
if: ${{ github.event_name == 'pull_request' }}
85+
uses: orgoro/coverage@v3
86+
with:
87+
coverageFile: coverage.xml
88+
token: ${{ secrets.GITHUB_TOKEN }}
7189

7290
# Run linting
7391
Lint:
7492
runs-on: ubuntu-latest
7593
steps:
76-
- uses: actions/checkout@v6
77-
- name: Set up Python
78-
uses: actions/setup-python@v6
79-
with:
80-
# Pinned Python version
81-
python-version-file: ".python-version"
82-
- name: Install uv
83-
uses: astral-sh/setup-uv@v7
84-
with:
85-
enable-cache: true
86-
- name: Lint with ruff
87-
run: |
88-
uv run ruff check
94+
- uses: actions/checkout@v6
95+
- name: Set up Python
96+
uses: actions/setup-python@v6
97+
with:
98+
# Pinned Python version
99+
python-version-file: ".python-version"
100+
- name: Install uv
101+
uses: astral-sh/setup-uv@v7
102+
with:
103+
enable-cache: true
104+
- name: Lint with ruff
105+
run: |
106+
uv run ruff check
89107
90108
# Run type-checking with mypy
91109
Type-check:
92110
runs-on: ubuntu-latest
93111
steps:
94-
- uses: actions/checkout@v6
95-
- name: Set up Python
96-
uses: actions/setup-python@v6
97-
with:
98-
# Pinned Python version
99-
python-version-file: ".python-version"
100-
- name: Install uv
101-
uses: astral-sh/setup-uv@v7
102-
with:
103-
enable-cache: true
104-
- name: Type-check with mypy
105-
run: |
106-
uv run mypy
112+
- uses: actions/checkout@v6
113+
- name: Set up Python
114+
uses: actions/setup-python@v6
115+
with:
116+
# Pinned Python version
117+
python-version-file: ".python-version"
118+
- name: Install uv
119+
uses: astral-sh/setup-uv@v7
120+
with:
121+
enable-cache: true
122+
- name: Type-check with mypy
123+
run: |
124+
uv run mypy

0 commit comments

Comments
 (0)