Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: Test and lint
2
3 on:
4 schedule:
5 - cron: "0 2 * * *" # 2am UTC
6 push:
7 branches:
8 - main
9 pull_request:
10 workflow_dispatch:
11
12 permissions:
13 contents: read
14
15 env:
16 FORCE_COLOR: 1
17 PIP_DISABLE_PIP_VERSION_CHECK: 1
18
19 concurrency:
20 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21 cancel-in-progress: true
22
23 jobs:
24 docs:
25 name: Build docs
26 runs-on: ubuntu-latest
27
28 steps:
29 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
30 with:
31 persist-credentials: false
32
33 - name: Install the latest version of uv
34 uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
35 with:
36 python-version: "3.14"
37
38 - name: Build docs in nitpicky mode
39 run: uvx --from sphinx sphinx-build -n -W -b html doc doc/_build/html
40
41 tests:
42 name: Run tests
43
44 # if 'schedule' was the trigger,
45 # don't run it on contributors' forks
46 if: >-
47 github.repository == 'python/typing_extensions'
48 || github.event_name != 'schedule'
49
50 strategy:
51 fail-fast: false
52 matrix:
53 # We try to test on the earliest available bugfix release of each
54 # Python version, because typing sometimes changed between bugfix releases.
55 # For available versions, see:
56 # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
57 python-version:
58 - "3.9"
59 - "3.9.12"
60 - "3.10"
61 - "3.10.4"
62 - "3.11"
63 - "3.11.0"
64 - "3.12"
65 - "3.12.0"
66 - "3.13"
67 - "3.13.0"
68 - "3.14"
69 - "pypy3.9"
70 - "pypy3.10"
71 - "pypy3.11"
72
73 runs-on: ubuntu-latest
74
75 permissions:
76 contents: read
77 id-token: write # for codecov upload
78
79 steps:
80 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
81 with:
82 persist-credentials: false
83
84 - name: Set up Python
85 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
86 with:
87 python-version: ${{ matrix.python-version }}
88 allow-prereleases: true
89
90 - name: Install coverage
91 run: |
92 # Be wary that this does not install typing_extensions in the future.
93 # 'toml' extra is needed to read settings from pyproject.toml on Python <3.11
94 pip install 'coverage[toml]'
95
96 - name: Test typing_extensions with coverage
97 run: |
98 # Be wary of running `pip install` here, since it becomes easy for us to
99 # accidentally pick up typing_extensions as installed by a dependency
100 cd src
101 python --version # just to make sure we're running the right one
102 # Run tests under coverage
103 python -We -m coverage run -m unittest test_typing_extensions.py
104 # Create xml file for Codecov
105 coverage xml --rcfile=../pyproject.toml --fail-under=0
106
107 - name: Test CPython typing test suite
108 # Test suite fails on PyPy even without typing_extensions
109 if: ${{ !startsWith(matrix.python-version, 'pypy') }}
110 run: |
111 cd src
112 # Run the typing test suite from CPython with typing_extensions installed,
113 # because we monkeypatch typing under some circumstances.
114 python -c 'import typing_extensions; import test.__main__' test_typing -v
115
116 - name: Upload coverage reports to Codecov
117 uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
118 if: >-
119 github.repository == 'python/typing_extensions'
120 && (github.event_name == 'push' || github.event_name == 'pull_request')
121 with:
122 use_oidc: true
123 flags: ${{ matrix.python-version }}
124 directory: src
125 fail_ci_if_error: true
126 verbose: true
127
128 create-issue-on-failure:
129 name: Create an issue if daily tests failed
130 runs-on: ubuntu-latest
131
132 needs: [tests]
133
134 if: >-
135 ${{
136 github.repository == 'python/typing_extensions'
137 && always()
138 && github.event_name == 'schedule'
139 && needs.tests.result == 'failure'
140 }}
141
142 permissions:
143 issues: write
144
145 steps:
146 - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
147 with:
148 github-token: ${{ secrets.GITHUB_TOKEN }}
149 script: |
150 await github.rest.issues.create({
151 owner: "python",
152 repo: "typing_extensions",
153 title: `Daily tests failed on ${new Date().toDateString()}`,
154 body: "Run listed here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
155 })