Skip to content

Commit 46ef7c1

Browse files
committed
try integrating common in toxgen
1 parent 11462f2 commit 46ef7c1

File tree

5 files changed

+95
-52
lines changed

5 files changed

+95
-52
lines changed

scripts/populate_tox/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ integration_name: {
4646
},
4747
"python": python_version_specifier,
4848
"include": package_version_specifier,
49+
"prereleases": bool,
50+
"test_on_all_python_versions": bool,
4951
}
5052
```
5153

@@ -153,6 +155,34 @@ be expressed like so:
153155
}
154156
```
155157

158+
### `prereleases`
159+
160+
By default, we ignore all prereleases but the newest one. Some packages only have prereleases though. When `prereleases` is set to `True`, we will consider prereleases just like we do normal releases and they will not be filtered out.
161+
162+
```python
163+
"common": {
164+
# opentelemetry-distro is only available in beta
165+
"package": "opentelemetry-distro",
166+
"prereleases": True,
167+
...
168+
}
169+
```
170+
171+
172+
### `test_on_all_python_versions`
173+
174+
By default, the script will cherry-pick a few Python versions to test each integration on.
175+
If you want a test suite to run on all supported Python versions instead, set
176+
`test_on_all_python_versions=True`.
177+
178+
```python
179+
"common": {
180+
# The common test suite should run on all Python versions.
181+
"test_on_all_python_versions": True,
182+
...
183+
}
184+
```
185+
156186

157187
## How-Tos
158188

scripts/populate_tox/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929
"clickhouse_driver": {
3030
"package": "clickhouse-driver",
3131
},
32+
"common": {
33+
"package": "opentelemetry-distro",
34+
"prereleases": True,
35+
"test_on_all_python_versions": True,
36+
"deps": {
37+
"*": ["pytest", "pytest-asyncio"],
38+
# See https://github.com/pytest-dev/pytest/issues/9621
39+
# and https://github.com/pytest-dev/pytest-forked/issues/67
40+
# for justification of the upper bound on pytest
41+
"py3.7": ["pytest<7.0.0"],
42+
"py3.8": ["hypothesis"],
43+
},
44+
},
3245
"django": {
3346
"package": "django",
3447
"deps": {

scripts/populate_tox/populate_tox.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"asgi",
6262
"aws_lambda",
6363
"cloud_resource_context",
64-
"common",
6564
"gevent",
6665
"opentelemetry",
6766
"potel",
@@ -151,6 +150,8 @@ def _prefilter_releases(
151150
TEST_SUITE_CONFIG[integration]["include"], prereleases=True
152151
)
153152

153+
accept_prereleases = TEST_SUITE_CONFIG[integration].get("prereleases") or False
154+
154155
filtered_releases = []
155156
last_prerelease = None
156157

@@ -182,7 +183,7 @@ def _prefilter_releases(
182183
if include_versions is not None and version not in include_versions:
183184
continue
184185

185-
if version.is_prerelease:
186+
if not accept_prereleases and version.is_prerelease:
186187
if last_prerelease is None or version > last_prerelease:
187188
last_prerelease = version
188189
continue
@@ -235,13 +236,6 @@ def get_supported_releases(
235236
integration, pypi_data["releases"], older_than
236237
)
237238

238-
# Determine Python support
239-
expected_python_versions = TEST_SUITE_CONFIG[integration].get("python")
240-
if expected_python_versions:
241-
expected_python_versions = SpecifierSet(expected_python_versions)
242-
else:
243-
expected_python_versions = SpecifierSet(f">={MIN_PYTHON_VERSION}")
244-
245239
def _supports_lowest(release: Version) -> bool:
246240
time.sleep(PYPI_COOLDOWN) # don't DoS PYPI
247241

@@ -356,22 +350,28 @@ def supported_python_versions(
356350
return supported
357351

358352

359-
def pick_python_versions_to_test(python_versions: list[Version]) -> list[Version]:
353+
def pick_python_versions_to_test(
354+
python_versions: list[Version], test_all: bool = False
355+
) -> list[Version]:
360356
"""
361357
Given a list of Python versions, pick those that make sense to test on.
362358
363359
Currently, this is the oldest, the newest, and the second newest Python
364360
version.
365361
"""
366-
filtered_python_versions = {
367-
python_versions[0],
368-
}
362+
if test_all:
363+
filtered_python_versions = python_versions
369364

370-
filtered_python_versions.add(python_versions[-1])
371-
try:
372-
filtered_python_versions.add(python_versions[-2])
373-
except IndexError:
374-
pass
365+
else:
366+
filtered_python_versions = {
367+
python_versions[0],
368+
}
369+
370+
filtered_python_versions.add(python_versions[-1])
371+
try:
372+
filtered_python_versions.add(python_versions[-2])
373+
except IndexError:
374+
pass
375375

376376
return sorted(filtered_python_versions)
377377

@@ -525,6 +525,9 @@ def _add_python_versions_to_release(
525525

526526
time.sleep(PYPI_COOLDOWN) # give PYPI some breathing room
527527

528+
test_on_all_python_versions = (
529+
TEST_SUITE_CONFIG[integration].get("test_on_all_python_versions") or False
530+
)
528531
target_python_versions = TEST_SUITE_CONFIG[integration].get("python")
529532
if target_python_versions:
530533
target_python_versions = SpecifierSet(target_python_versions)
@@ -533,7 +536,8 @@ def _add_python_versions_to_release(
533536
supported_python_versions(
534537
determine_python_versions(release_pypi_data),
535538
target_python_versions,
536-
)
539+
),
540+
test_all=test_on_all_python_versions,
537541
)
538542

539543
release.rendered_python_versions = _render_python_versions(release.python_versions)

scripts/populate_tox/tox.jinja

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ requires =
1717
# This version introduced using pip 24.1 which does not work with older Celery and HTTPX versions.
1818
virtualenv<20.26.3
1919
envlist =
20-
# === Common ===
21-
{py3.7,py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-common
22-
2320
# === Gevent ===
2421
{py3.8,py3.10,py3.11,py3.12}-gevent
2522

@@ -161,15 +158,6 @@ deps =
161158
linters: -r requirements-linting.txt
162159
linters: werkzeug<2.3.0
163160
164-
# === Common ===
165-
py3.8-common: hypothesis
166-
common: pytest-asyncio
167-
# See https://github.com/pytest-dev/pytest/issues/9621
168-
# and https://github.com/pytest-dev/pytest-forked/issues/67
169-
# for justification of the upper bound on pytest
170-
py3.7-common: pytest<7.0.0
171-
{py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-common: pytest
172-
173161
# === Gevent ===
174162
{py3.7,py3.8,py3.9,py3.10,py3.11}-gevent: gevent>=22.10.0, <22.11.0
175163
{py3.12}-gevent: gevent

tox.ini

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
# The file (and all resulting CI YAMLs) then need to be regenerated via
1111
# "scripts/generate-test-files.sh".
1212
#
13-
# Last generated: 2025-04-15T14:53:25.426657+00:00
13+
# Last generated: 2025-04-17T09:53:39.706505+00:00
1414

1515
[tox]
1616
requires =
1717
# This version introduced using pip 24.1 which does not work with older Celery and HTTPX versions.
1818
virtualenv<20.26.3
1919
envlist =
20-
# === Common ===
21-
{py3.7,py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-common
22-
2320
# === Gevent ===
2421
{py3.8,py3.10,py3.11,py3.12}-gevent
2522

@@ -140,6 +137,13 @@ envlist =
140137
# These come from the populate_tox.py script. Eventually we should move all
141138
# integration tests there.
142139

140+
# ~~~ Common ~~~
141+
{py3.7,py3.8}-common-v0.17b0
142+
{py3.7,py3.8}-common-v0.28b1
143+
{py3.7,py3.8}-common-v0.42b0
144+
{py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-common-v0.53b1
145+
146+
143147
# ~~~ AI ~~~
144148
{py3.8,py3.10,py3.11}-huggingface_hub-v0.22.2
145149
{py3.8,py3.10,py3.11}-huggingface_hub-v0.25.2
@@ -168,6 +172,7 @@ envlist =
168172
{py3.8,py3.12,py3.13}-launchdarkly-v9.8.1
169173
{py3.8,py3.12,py3.13}-launchdarkly-v9.9.0
170174
{py3.8,py3.12,py3.13}-launchdarkly-v9.10.0
175+
{py3.8,py3.12,py3.13}-launchdarkly-v9.11.0
171176

172177
{py3.8,py3.12,py3.13}-openfeature-v0.7.5
173178
{py3.9,py3.12,py3.13}-openfeature-v0.8.1
@@ -195,9 +200,9 @@ envlist =
195200
{py3.8,py3.12,py3.13}-graphene-v3.4.3
196201

197202
{py3.8,py3.10,py3.11}-strawberry-v0.209.8
198-
{py3.8,py3.11,py3.12}-strawberry-v0.227.7
199-
{py3.8,py3.11,py3.12}-strawberry-v0.245.0
200-
{py3.9,py3.12,py3.13}-strawberry-v0.264.0
203+
{py3.8,py3.11,py3.12}-strawberry-v0.228.0
204+
{py3.8,py3.12,py3.13}-strawberry-v0.247.2
205+
{py3.9,py3.12,py3.13}-strawberry-v0.265.1
201206

202207

203208
# ~~~ Network ~~~
@@ -303,15 +308,6 @@ deps =
303308
linters: -r requirements-linting.txt
304309
linters: werkzeug<2.3.0
305310

306-
# === Common ===
307-
py3.8-common: hypothesis
308-
common: pytest-asyncio
309-
# See https://github.com/pytest-dev/pytest/issues/9621
310-
# and https://github.com/pytest-dev/pytest-forked/issues/67
311-
# for justification of the upper bound on pytest
312-
py3.7-common: pytest<7.0.0
313-
{py3.8,py3.9,py3.10,py3.11,py3.12,py3.13}-common: pytest
314-
315311
# === Gevent ===
316312
{py3.7,py3.8,py3.9,py3.10,py3.11}-gevent: gevent>=22.10.0, <22.11.0
317313
{py3.12}-gevent: gevent
@@ -496,6 +492,17 @@ deps =
496492
# These come from the populate_tox.py script. Eventually we should move all
497493
# integration tests there.
498494

495+
# ~~~ Common ~~~
496+
common-v0.17b0: opentelemetry-distro==0.17b0
497+
common-v0.28b1: opentelemetry-distro==0.28b1
498+
common-v0.42b0: opentelemetry-distro==0.42b0
499+
common-v0.53b1: opentelemetry-distro==0.53b1
500+
common: pytest
501+
common: pytest-asyncio
502+
py3.7-common: pytest<7.0.0
503+
py3.8-common: hypothesis
504+
505+
499506
# ~~~ AI ~~~
500507
huggingface_hub-v0.22.2: huggingface_hub==0.22.2
501508
huggingface_hub-v0.25.2: huggingface_hub==0.25.2
@@ -525,6 +532,7 @@ deps =
525532
launchdarkly-v9.8.1: launchdarkly-server-sdk==9.8.1
526533
launchdarkly-v9.9.0: launchdarkly-server-sdk==9.9.0
527534
launchdarkly-v9.10.0: launchdarkly-server-sdk==9.10.0
535+
launchdarkly-v9.11.0: launchdarkly-server-sdk==9.11.0
528536

529537
openfeature-v0.7.5: openfeature-sdk==0.7.5
530538
openfeature-v0.8.1: openfeature-sdk==0.8.1
@@ -561,13 +569,13 @@ deps =
561569
py3.6-graphene: aiocontextvars
562570

563571
strawberry-v0.209.8: strawberry-graphql[fastapi,flask]==0.209.8
564-
strawberry-v0.227.7: strawberry-graphql[fastapi,flask]==0.227.7
565-
strawberry-v0.245.0: strawberry-graphql[fastapi,flask]==0.245.0
566-
strawberry-v0.264.0: strawberry-graphql[fastapi,flask]==0.264.0
572+
strawberry-v0.228.0: strawberry-graphql[fastapi,flask]==0.228.0
573+
strawberry-v0.247.2: strawberry-graphql[fastapi,flask]==0.247.2
574+
strawberry-v0.265.1: strawberry-graphql[fastapi,flask]==0.265.1
567575
strawberry: httpx
568576
strawberry-v0.209.8: pydantic<2.11
569-
strawberry-v0.227.7: pydantic<2.11
570-
strawberry-v0.245.0: pydantic<2.11
577+
strawberry-v0.228.0: pydantic<2.11
578+
strawberry-v0.247.2: pydantic<2.11
571579

572580

573581
# ~~~ Network ~~~

0 commit comments

Comments
 (0)