Debian Codegraph @

.github/workflows/main.yml

raw symbols SCIP
1 ---
2 name: CI
3
4 on:
5 push:
6 branches: [main]
7 tags: [v*]
8 pull_request:
9 branches: [main]
10 merge_group:
11 workflow_dispatch:
12
13 permissions: {}
14
15 env:
16 PYTHON_LATEST: 3.13
17
18 jobs:
19 build:
20 name: Build package
21 runs-on: ubuntu-latest
22 outputs:
23 version: ${{ steps.version.outputs.version }}
24 prerelease: ${{ steps.version.outputs.prerelease }}
25 steps:
26 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
27 with:
28 fetch-depth: 0
29 persist-credentials: false
30 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
31 with:
32 python-version: ${{ env.PYTHON_LATEST }}
33 - name: Install tox
34 run: python -m pip install tox
35 - name: Build package and check distributions
36 run: tox run -e build
37 - name: List result
38 run: ls -l dist
39 - name: Install pytest-asyncio
40 run: pip install .
41 - name: Get version info
42 id: version
43 run: python ./tools/get-version.py >> $GITHUB_OUTPUT
44 - name: Upload artifacts
45 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
46 with:
47 name: dist
48 path: dist
49
50 lint:
51 name: Run linters
52 runs-on: ubuntu-latest
53 steps:
54 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
55 with:
56 fetch-depth: 0
57 persist-credentials: false
58 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
59 with:
60 python-version: ${{ env.PYTHON_LATEST }}
61 - name: Install GitHub matcher for ActionLint checker
62 run: |
63 echo "::add-matcher::.github/actionlint-matcher.json"
64 - name: Install pre-commit
65 run: python -m pip install pre-commit
66 - name: Run pre-commit checks
67 run: pre-commit run --all-files --show-diff-on-failure
68
69 test:
70 name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
71 runs-on: ${{ matrix.os }}-latest
72 continue-on-error: ${{ !matrix.required }}
73 strategy:
74 matrix:
75 os: [ubuntu, windows]
76 python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', 3.14t]
77 required: [true]
78
79 steps:
80 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
81 with:
82 persist-credentials: false
83 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
84 with:
85 python-version: ${{ matrix.python-version }}
86 - name: Install dependencies
87 run: |
88 python -VV
89 python -m site
90 python -m pip install --upgrade pip
91 python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions
92 - name: Run tox targets for ${{ matrix.python-version }}
93 run: python -m tox
94
95 - name: Store coverage data
96 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
97 if: "!endsWith(matrix.os, 'windows')"
98 with:
99 name: coverage-python-${{ matrix.python-version }}
100 path: coverage/coverage.*
101 if-no-files-found: error
102
103 test-pytest-dev:
104 name: ubuntu - Python latest - pytest main
105 runs-on: ubuntu-latest
106 continue-on-error: true
107 steps:
108 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
109 with:
110 persist-credentials: false
111 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
112 with:
113 python-version: ${{ env.PYTHON_LATEST }}
114 - name: Install dependencies
115 run: |
116 python -VV
117 python -m site
118 python -m pip install --upgrade pip
119 python -m pip install --upgrade tox
120 - name: Run tests against pytest main
121 run: python -m tox run -e pytest-dev
122
123 lint-github-actions:
124 name: Lint GitHub Actions
125 permissions:
126 security-events: write
127 uses: zizmorcore/workflow/.github/workflows/reusable-zizmor.yml@3bb5e95068d0f44b6d2f3f7e91379bed1d2f96a8
128
129 check:
130 name: Check
131 if: always()
132 needs: [build, lint, test]
133 runs-on: ubuntu-latest
134 steps:
135 - name: Decide whether the needed jobs succeeded or failed
136 uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
137 with:
138 jobs: ${{ toJSON(needs) }}
139 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
140 with:
141 persist-credentials: false
142 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
143 with:
144 python-version: ${{ env.PYTHON_LATEST }}
145 - name: Install Coverage.py
146 run: |
147 set -xe
148 python -m pip install --upgrade coverage[toml]
149 - name: Download coverage data for all test runs
150 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
151 with:
152 pattern: coverage-*
153 path: coverage
154 merge-multiple: true
155 - name: Combine coverage data and create report
156 run: |
157 coverage combine
158 coverage xml
159 - name: Upload coverage report
160 uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
161 with:
162 files: coverage.xml
163 fail_ci_if_error: true
164 token: ${{ secrets.CODECOV_TOKEN }}
165
166 create-github-release:
167 name: Create GitHub release
168 needs: [check]
169 runs-on: ubuntu-latest
170 permissions:
171 contents: write
172 steps:
173 - name: Checkout
174 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
175 with:
176 fetch-depth: 0
177 persist-credentials: false
178 - name: Install Python
179 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
180 - name: Install towncrier
181 run: pip install towncrier==24.8.0
182 - name: Install pandoc
183 run: |
184 sudo apt-get install -y pandoc
185 - name: Install pytest-asyncio
186 run: pip install .
187 - name: Compile Release Notes Draft
188 if: ${{ !contains(github.ref, 'refs/tags/') }}
189 run: towncrier build --draft --version "${version}" > release-notes.rst
190 env:
191 version: ${{ needs.build.outputs.version }}
192 - name: Extract release notes from Git tag
193 if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
194 run: |
195 set -e
196 git fetch --tags --force # see https://github.com/actions/checkout/issues/290
197 git for-each-ref "${GITHUB_REF}" --format='%(contents)' > release-notes.rst
198 # Strip signature from signed tags
199 sed -i -e "/-----BEGIN PGP SIGNATURE-----/,/-----END PGP SIGNATURE-----\n/d" \
200 -e "/-----BEGIN SSH SIGNATURE-----/,/-----END SSH SIGNATURE-----\n/d" release-notes.rst
201 - name: Convert Release Notes to Markdown
202 run: |
203 pandoc --wrap=preserve -o release-notes.md release-notes.rst
204 - name: Upload artifacts
205 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
206 with:
207 name: release-notes.md
208 path: release-notes.md
209 - name: Download distributions
210 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
211 with:
212 name: dist
213 path: dist
214 - name: Create GitHub Release
215 if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
216 env:
217 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
218 PRERELEASE: ${{ needs.build.outputs.prerelease }}
219 run: |
220 set +e
221 TAG_NAME="${GITHUB_REF#refs/tags/}"
222 gh release view "${TAG_NAME}" >/dev/null && echo "Release already exists. Exiting." && exit 0
223 gh release create "${TAG_NAME}" \
224 --title "pytest-asyncio ${TAG_NAME}" \
225 --notes-file release-notes.md \
226 --draft \
227 $( [ "${PRERELEASE}" = "true" ] && echo "--prerelease" ) \
228 dist/*
229
230 publish-test-pypi:
231 name: Publish packages to test.pypi.org
232 if: github.event_name == 'push' && github.ref == 'refs/heads/main'
233 needs: [create-github-release]
234 runs-on: ubuntu-latest
235 permissions:
236 id-token: write
237 steps:
238 - name: Download distributions
239 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
240 with:
241 name: dist
242 path: dist
243 - name: Upload to test.pypi.org
244 uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
245 with:
246 repository-url: https://test.pypi.org/legacy/
247
248 publish-pypi:
249 name: Publish packages to pypi.org
250 environment: release
251 if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
252 needs: [create-github-release]
253 runs-on: ubuntu-latest
254 permissions:
255 contents: write
256 id-token: write
257 steps:
258 - name: Download distributions
259 uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
260 with:
261 name: dist
262 path: dist
263 - name: PyPI upload
264 uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
265 - name: Publish GitHub Release
266 env:
267 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
268 run: |
269 set +e
270 TAG_NAME="${GITHUB_REF#refs/tags/}"
271 gh release edit "${TAG_NAME}" --draft=false