Debian Codegraph @

.github/workflows/ci.yaml

raw
1 name: CI
2
3 on:
4 push:
5 branches:
6 - main
7 - maintenance/**
8 pull_request:
9 workflow_dispatch:
10
11 env:
12 CACHE_VERSION: 3
13 KEY_PREFIX: venv
14 DEFAULT_PYTHON: "3.13"
15 PRE_COMMIT_CACHE: ~/.cache/pre-commit
16
17 concurrency:
18 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19 cancel-in-progress: true
20
21 jobs:
22 base-checks:
23 name: Checks
24 runs-on: ubuntu-latest
25 timeout-minutes: 20
26 steps:
27 - &checkout
28 name: Check out code from GitHub
29 uses: actions/[email protected]
30 - &setup-python-default
31 name: Set up Python ${{ env.DEFAULT_PYTHON }}
32 id: python
33 uses: actions/[email protected]
34 with:
35 python-version: ${{ env.DEFAULT_PYTHON }}
36 check-latest: true
37 - name: Generate partial Python venv restore key
38 id: generate-python-key
39 run: >-
40 echo "key=base-venv-${{ env.CACHE_VERSION }}-${{
41 hashFiles('pyproject.toml', 'requirements_dev.txt',
42 'requirements_full.txt', 'requirements_minimal.txt') }}" >> $GITHUB_OUTPUT
43 - &cache-python
44 name: Restore Python virtual environment
45 id: cache-venv
46 uses: actions/[email protected]
47 with:
48 path: venv
49 key: >-
50 ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
51 steps.generate-python-key.outputs.key }}
52 - name: Create Python virtual environment
53 if: steps.cache-venv.outputs.cache-hit != 'true'
54 run: |
55 python -m venv venv
56 . venv/bin/activate
57 python -m pip install -U pip
58 pip install -U -r requirements_full.txt
59 - name: Generate pre-commit restore key
60 id: generate-pre-commit-key
61 run: >-
62 echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{
63 hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
64 - name: Restore pre-commit environment
65 id: cache-precommit
66 uses: actions/[email protected]
67 with:
68 path: ${{ env.PRE_COMMIT_CACHE }}
69 key: >-
70 ${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }}
71 - name: Install pre-commit dependencies
72 if: steps.cache-precommit.outputs.cache-hit != 'true'
73 run: |
74 . venv/bin/activate
75 pre-commit install --install-hooks
76 - name: Run pre-commit checks
77 run: |
78 . venv/bin/activate
79 pre-commit run --hook-stage manual pylint-ci --all-files
80
81 tests-linux:
82 name: tests / run / ${{ matrix.python-version }} / Linux
83 runs-on: ubuntu-latest
84 timeout-minutes: 20
85 strategy:
86 fail-fast: false
87 matrix:
88 python-version:
89 &matrix-python-version ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15-dev"]
90 outputs:
91 python-key: ${{ steps.generate-python-key.outputs.key }}
92 steps:
93 - *checkout
94 - name: Set up Python ${{ matrix.python-version }}
95 id: python
96 uses: actions/[email protected]
97 with:
98 python-version: ${{ matrix.python-version }}
99 allow-prereleases: true
100 check-latest: true
101 - name: Install Qt
102 if: ${{ matrix.python-version == '3.10' }}
103 run: |
104 sudo apt-get update
105 sudo apt-get install build-essential libgl1-mesa-dev
106 - name: Generate partial Python venv restore key
107 id: generate-python-key
108 run: >-
109 echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
110 hashFiles('pyproject.toml', 'requirements_dev.txt',
111 'requirements_full.txt', 'requirements_minimal.txt') }}" >> $GITHUB_OUTPUT
112 - *cache-python
113 - name: Create Python virtual environment
114 if: steps.cache-venv.outputs.cache-hit != 'true'
115 run: |
116 python -m venv venv
117 . venv/bin/activate
118 python -m pip install -U pip wheel
119 pip install -U -r requirements_full.txt
120 pip install -e .
121 - name: Run pytest
122 run: |
123 . venv/bin/activate
124 pytest --cov
125 - name: Upload coverage artifact
126 uses: &actions-upload-artifact actions/[email protected]
127 with:
128 name: coverage-linux-${{ matrix.python-version }}
129 path: .coverage
130 include-hidden-files: true
131
132 tests-windows:
133 name: tests / run / ${{ matrix.python-version }} / Windows
134 runs-on: windows-latest
135 timeout-minutes: 20
136 needs: [tests-linux]
137 strategy:
138 fail-fast: false
139 matrix:
140 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15-dev"]
141 steps:
142 - name: Set temp directory
143 run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
144 # Workaround to set correct temp directory on Windows
145 # https://github.com/actions/virtual-environments/issues/712
146 - *checkout
147 - &setup-python-matrix
148 name: Set up Python ${{ matrix.python-version }}
149 id: python
150 uses: actions/[email protected]
151 with:
152 python-version: ${{ matrix.python-version }}
153 allow-prereleases: true
154 check-latest: true
155 - name: Generate partial Python venv restore key
156 id: generate-python-key
157 run: >-
158 echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
159 hashFiles('pyproject.toml', 'requirements_dev.txt',
160 'requirements_full.txt', 'requirements_minimal.txt') }}" >> $env:GITHUB_OUTPUT
161 - *cache-python
162 - name: Create Python virtual environment
163 if: steps.cache-venv.outputs.cache-hit != 'true'
164 run: |
165 python -m venv venv
166 . venv\\Scripts\\activate
167 python -m pip install -U pip
168 pip install -U -r requirements_full.txt
169 pip install -e .
170 - name: Run pytest
171 run: |
172 . venv\\Scripts\\activate
173 pytest --cov
174 - name: Upload coverage artifact
175 uses: *actions-upload-artifact
176 with:
177 name: coverage-windows-${{ matrix.python-version }}
178 path: .coverage
179 include-hidden-files: true
180
181 tests-pypy:
182 name: tests / run / ${{ matrix.python-version }} / Linux
183 runs-on: ubuntu-latest
184 timeout-minutes: 20
185 strategy:
186 fail-fast: false
187 matrix:
188 # We only test on the lowest and highest supported PyPy versions
189 python-version: ["pypy3.10"]
190 steps:
191 - *checkout
192 - *setup-python-matrix
193 - name: Generate partial Python venv restore key
194 id: generate-python-key
195 run: >-
196 echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
197 hashFiles('pyproject.toml', 'requirements_minimal.txt')
198 }}" >> $GITHUB_OUTPUT
199 - *cache-python
200 - name: Create Python virtual environment
201 if: steps.cache-venv.outputs.cache-hit != 'true'
202 run: |
203 python -m venv venv
204 . venv/bin/activate
205 python -m pip install -U pip
206 pip install -U -r requirements_minimal.txt
207 pip install -e .
208 - name: Run pytest
209 run: |
210 . venv/bin/activate
211 pytest --cov
212 - name: Upload coverage artifact
213 uses: *actions-upload-artifact
214 with:
215 name: coverage-pypy-${{ matrix.python-version }}
216 path: .coverage
217 include-hidden-files: true
218
219 coverage:
220 name: tests / process / coverage
221 runs-on: ubuntu-latest
222 timeout-minutes: 10
223 needs: ["tests-linux", "tests-windows", "tests-pypy"]
224 steps:
225 - *checkout
226 - *setup-python-default
227 - name: Install dependencies
228 run: pip install -U -r requirements_minimal.txt
229 - name: Download all coverage artifacts
230 uses: actions/[email protected]
231 - name: Combine Linux coverage results
232 run: |
233 coverage combine coverage-linux*/.coverage
234 coverage xml -o coverage-linux.xml
235 - uses: &actions-codecov codecov/codecov-action@v7
236 with:
237 token: ${{ secrets.CODECOV_TOKEN }}
238 fail_ci_if_error: true
239 verbose: true
240 flags: linux
241 files: coverage-linux.xml
242 - name: Combine Windows coverage results
243 run: |
244 coverage combine coverage-windows*/.coverage
245 coverage xml -o coverage-windows.xml
246 - uses: *actions-codecov
247 with:
248 token: ${{ secrets.CODECOV_TOKEN }}
249 fail_ci_if_error: true
250 verbose: true
251 flags: windows
252 files: coverage-windows.xml
253 - name: Combine PyPy coverage results
254 run: |
255 coverage combine coverage-pypy*/.coverage
256 coverage xml -o coverage-pypy.xml
257 - uses: *actions-codecov
258 with:
259 token: ${{ secrets.CODECOV_TOKEN }}
260 fail_ci_if_error: true
261 verbose: true
262 flags: pypy
263 files: coverage-pypy.xml