Debian Codegraph @

.github/workflows/ci.yml

raw
1 ---
2 name: CI
3
4 on:
5 push:
6 branches: [master]
7 pull_request:
8 branches: [master]
9 release:
10 types: [published]
11
12 jobs:
13 lint-python:
14 name: Lint Python
15 runs-on: ubuntu-latest
16 permissions:
17 contents: read
18 steps:
19 - uses: actions/checkout@v4
20 - name: Set up Python 3.x
21 uses: actions/setup-python@v5
22 with:
23 python-version: "3.x"
24 cache: "pip"
25 - name: Install Hatch
26 run: |
27 pip3 --quiet install --upgrade hatch uv
28 hatch --version
29 uv --version
30 - name: Run formatter
31 run: hatch run lint:format-check || true
32 - name: Run linter
33 run: hatch run lint:check || true
34 # TODO: Remove '|| true' when linting issues are resolved in future PR
35
36 lint-docs:
37 name: Lint Documentation
38 runs-on: ubuntu-latest
39 permissions:
40 contents: read
41 steps:
42 - uses: actions/checkout@v4
43 with:
44 fetch-depth: 0
45 - uses: actions/setup-python@v5
46 with:
47 python-version: 3.x
48 cache: pip
49 - name: Install dependencies
50 run: pip install --upgrade hatch uv
51 # FIXME: Link checking disabled due to github.com link HTTP rate limit issues.
52 # - name: Check documentation links
53 # run: hatch run docs:linkcheck
54 - name: Check docs build
55 run: hatch run docs:build
56 - name: Validate changelog format
57 run: hatch run scripts/validate_changelog.py
58
59 test-python:
60 name: Python ${{ matrix.python-version }} (${{ matrix.os }})
61 runs-on: ${{ matrix.os }}
62 needs:
63 - lint-python
64 strategy:
65 fail-fast: false
66 matrix:
67 os: [ubuntu-latest, windows-latest]
68 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
69 steps:
70 - uses: actions/checkout@v4
71 - uses: actions/setup-python@v5
72 with:
73 python-version: ${{ matrix.python-version }}
74 allow-prereleases: true
75 cache: pip
76 - name: Install dependencies
77 run: python -m pip install --upgrade pip hatch uv
78 - name: Show environment
79 run: hatch test --show --python ${{ matrix.python-version }}
80 - name: Run tests
81 run: |
82 hatch test --cover --python ${{ matrix.python-version }}
83 mv .coverage ".coverage.${{ matrix.os }}.py${{ matrix.python-version }}"
84 - name: Upload coverage data
85 uses: actions/upload-artifact@v4
86 with:
87 name: "coverage-data-${{ matrix.os }}-py${{ matrix.python-version }}"
88 path: ".coverage.${{ matrix.os }}.py${{ matrix.python-version }}"
89 if-no-files-found: error
90 include-hidden-files: true
91 retention-days: 7
92
93 test-functional:
94 name: Functional Tests (${{ matrix.os }})
95 runs-on: ${{ matrix.os }}
96 needs:
97 - lint-python
98 strategy:
99 fail-fast: false
100 matrix:
101 os: [ubuntu-latest, windows-latest]
102 steps:
103 - uses: actions/checkout@v4
104 - uses: actions/setup-python@v5
105 with:
106 python-version: "3.12"
107 cache: pip
108 - name: Install dependencies
109 run: python -m pip install --upgrade pip hatch uv
110 - name: Setup postgres
111 uses: ikalnytskyi/action-setup-postgres@v7
112 - run: psql postgresql://postgres:postgres@localhost:5432/postgres -c "SELECT 1"
113 - run: psql service=postgres -c "SELECT 1"
114 - run: psql -c "SELECT 1"
115 env:
116 PGSERVICE: postgres
117 - name: Run functional tests
118 run: hatch run functional:all -v
119
120 build-python:
121 name: Build Python
122 runs-on: ubuntu-latest
123 permissions:
124 contents: read
125 needs:
126 - lint-python
127 steps:
128 - uses: actions/checkout@v4
129 - name: Set up Python 3.x
130 uses: actions/setup-python@v5
131 with:
132 python-version: "3.x"
133 cache: "pip"
134 - name: Install Hatch
135 run: |
136 pip3 --quiet install --upgrade hatch uv
137 hatch --version
138 uv --version
139 - name: Build release files
140 run: hatch build --clean
141 - uses: actions/upload-artifact@v4
142 with:
143 name: artifacts
144 path: dist/*
145 if-no-files-found: error
146 retention-days: 7
147
148 coverage-python:
149 name: Check Python Coverage
150 runs-on: ubuntu-latest
151 needs:
152 - test-python
153 steps:
154 - uses: actions/checkout@v4
155
156 - uses: actions/setup-python@v5
157 with:
158 python-version: "3.x"
159 cache: pip
160
161 - name: Install dependencies
162 run: python -m pip install --upgrade coverage[toml]
163
164 - name: Download data
165 uses: actions/download-artifact@v4
166 with:
167 merge-multiple: true
168
169 - name: Combine coverage and fail if it's <95%
170 run: |
171 python -m coverage combine
172 python -m coverage html --skip-covered --skip-empty
173 python -m coverage report --fail-under=95
174
175 - name: Upload HTML report
176 uses: actions/upload-artifact@v4
177 with:
178 name: coverage-report
179 path: htmlcov
180
181 publish-docs:
182 name: Publish Documentation
183 runs-on: ubuntu-latest
184 if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/')
185 needs:
186 - lint-docs
187 permissions:
188 contents: write
189 concurrency:
190 group: publish-docs
191 steps:
192 - uses: actions/checkout@v4
193 with:
194 fetch-depth: 0
195 - uses: actions/setup-python@v5
196 with:
197 python-version: 3.x
198 cache: pip
199 - name: Install dependencies
200 run: pip install --upgrade hatch uv
201 - name: Configure Git
202 run: |
203 git config user.name github-actions
204 git config user.email [email protected]
205 - name: Publish Develop Docs
206 if: github.ref_name == 'master'
207 run: hatch run docs:deploy_develop
208 - name: Publish Latest Docs
209 if: startsWith(github.ref, 'refs/tags/')
210 run: hatch run docs:deploy_latest ${{ github.ref_name }}
211
212 # This workflow relies on the user manually creating a "stub release" on GitHub with the correct version number in the tag.
213 publish-github:
214 name: Publish GitHub Release
215 runs-on: ubuntu-latest
216 if: startsWith(github.ref, 'refs/tags/')
217 permissions:
218 contents: write
219 concurrency:
220 group: publish-github
221 needs:
222 - build-python
223 - coverage-python
224 - test-functional
225 steps:
226 - uses: actions/checkout@v4
227 with:
228 fetch-depth: 0
229 - uses: actions/download-artifact@v4
230 with:
231 name: artifacts
232 path: dist
233 - name: Get latest release info
234 id: query-release-info
235 uses: release-flow/keep-a-changelog-action@v3
236 with:
237 command: query
238 version: ${{ github.ref_name }}
239 - name: Display release info
240 run: |
241 echo "Version: ${{ steps.query-release-info.outputs.version }}"
242 echo "Date: ${{ steps.query-release-info.outputs.release-date }}"
243 - uses: ncipollo/release-action@v1
244 with:
245 artifacts: "dist/*.tar.gz,dist/*.whl"
246 body: ${{ steps.query-release-info.outputs.release-notes }}
247 allowUpdates: true
248
249 publish-pypi:
250 name: Publish PyPi Package
251 runs-on: ubuntu-latest
252 if: startsWith(github.ref, 'refs/tags/')
253 permissions:
254 id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
255 concurrency:
256 group: publish-pypi
257 needs:
258 - publish-github
259 steps:
260 - uses: actions/download-artifact@v4
261 with:
262 name: artifacts
263 path: dist
264 - name: Publish build to PyPI
265 uses: pypa/gh-action-pypi-publish@release/v1