Skip to content

Commit d7721ad

Browse files
committed
fail-on-changes
1 parent b0a0772 commit d7721ad

File tree

5 files changed

+50
-28
lines changed

5 files changed

+50
-28
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
python-version: 3.12
4646

4747
- run: |
48+
pip install -r scripts/populate_tox/requirements.txt
49+
python scripts/populate_tox/populate_tox.py --fail-on-changes
4850
pip install -r scripts/split_tox_gh_actions/requirements.txt
4951
python scripts/split_tox_gh_actions/split_tox_gh_actions.py --fail-on-changes
5052

scripts/populate_tox/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ a specific Werkzeug version to work, you can say:
8282
"<3.0": ["Werkzeug<2.1.0"],
8383
}
8484
}
85-
````
85+
```
8686

8787
Sometimes, things depend on the Python version installed. If the integration
8888
test should only run on specific Python version, e.g. if you want AIOHTTP

scripts/populate_tox/config.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,6 @@
173173
"package": "huggingface_hub",
174174
"deps": {"*": []},
175175
},
176-
# XXX
177-
# langchain-v0.1: openai~=1.0.0
178-
# langchain-v0.1: tiktoken~=0.6.0
179-
# langchain-v0.1: httpx<0.28.0
180-
# langchain-v0.3: langchain-community
181-
# langchain-v0.3: tiktoken
182-
# langchain-v0.3: openai
183-
# langchain-{latest,notiktoken}: langchain
184-
# langchain-{latest,notiktoken}: langchain-openai
185-
# langchain-{latest,notiktoken}: openai>=1.6.1
186-
# langchain-latest: tiktoken~=0.6.0
187176
"langchain": {
188177
"package": "langchain",
189178
"deps": {

scripts/populate_tox/populate_tox.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"""
44

55
import functools
6+
import hashlib
7+
import sys
68
import time
79
from bisect import bisect_left
810
from collections import defaultdict
@@ -154,6 +156,8 @@ def get_supported_releases(integration: str, pypi_data: dict) -> list[Version]:
154156
This takes into account a handful of parameters (Python support, the lowest
155157
version we've defined for the framework, the date of the release).
156158
"""
159+
package = pypi_data["info"]["name"]
160+
157161
# Get a consolidated list without taking into account Python support yet
158162
# (because that might require an additional API call for some
159163
# of the releases)
@@ -355,8 +359,18 @@ def write_tox_file(packages: dict) -> None:
355359
file.write("\n")
356360

357361

358-
if __name__ == "__main__":
362+
def _get_tox_hash():
363+
hasher = hashlib.md5()
364+
with open(TOX_FILE, "rb") as f:
365+
buf = f.read()
366+
hasher.update(buf)
367+
368+
return hasher.hexdigest()
369+
370+
371+
def main(fail_on_changes: bool = False) -> None:
359372
print("Finding out the lowest and highest Python version supported by the SDK...")
373+
global MIN_PYTHON_VERSION, MAX_PYTHON_VERSION
360374
sdk_python_versions = determine_python_versions(fetch_package("sentry_sdk"))
361375
MIN_PYTHON_VERSION = sdk_python_versions[0]
362376
MAX_PYTHON_VERSION = sdk_python_versions[-1]
@@ -439,4 +453,19 @@ def write_tox_file(packages: dict) -> None:
439453
}
440454
)
441455

456+
old_hash = _get_tox_hash()
442457
write_tox_file(packages)
458+
new_hash = _get_tox_hash()
459+
if fail_on_changes and old_hash != new_hash:
460+
raise RuntimeError(
461+
"There are unexpected changes in tox.ini. tox.ini is not meant to "
462+
"be edited directly. It's generated from a template located in "
463+
"scripts/populate_tox/tox.jinja. "
464+
"Please make sure that both the template and the tox generation "
465+
"script in scripts/populate_tox/populate_tox.py are updated as well."
466+
)
467+
468+
469+
if __name__ == "__main__":
470+
fail_on_changes = len(sys.argv) == 2 and sys.argv[1] == "--fail-on-changes"
471+
main(fail_on_changes)

tox.ini

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
# and then run "tox" from this directory.
55
#
66
# This file has been generated from a template
7-
# by scripts/populate_tox/populate_tox.py. Any changes to the file should be made
8-
# in the script and the file regenerated.
7+
# by "scripts/populate_tox/populate_tox.py". Any changes to the file should
8+
# be made in the template (if you want to change a hardcoded part of the file)
9+
# or in the script (if you want to change the auto-generated part).
10+
# The file (and all resulting CI YAMLs) then need to be regenerated via
11+
# "scripts/generate-test-files.sh".
912

1013
[tox]
1114
requires =
@@ -36,6 +39,10 @@ envlist =
3639
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
3740
{py3.8,py3.12,py3.13}-aiohttp-latest
3841

42+
# Anthropic
43+
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
44+
{py3.7,py3.11,py3.12}-anthropic-latest
45+
3946
# Arq
4047
{py3.7,py3.11}-arq-v{0.23}
4148
{py3.7,py3.12,py3.13}-arq-latest
@@ -164,11 +171,6 @@ envlist =
164171
# integration tests there.
165172

166173
# ~~~ AI ~~~
167-
{py3.7,py3.11,py3.12}-anthropic-v0.16.0
168-
{py3.7,py3.11,py3.12}-anthropic-v0.25.9
169-
{py3.7,py3.11,py3.12}-anthropic-v0.34.2
170-
{py3.8,py3.11,py3.12}-anthropic-v0.43.0
171-
172174
{py3.8,py3.10,py3.11}-huggingface_hub-v0.22.2
173175
{py3.8,py3.10,py3.11}-huggingface_hub-v0.24.7
174176
{py3.8,py3.11,py3.12}-huggingface_hub-v0.26.5
@@ -338,6 +340,14 @@ deps =
338340
aiohttp-v3.8: pytest-asyncio
339341
aiohttp-latest: pytest-asyncio
340342

343+
# Anthropic
344+
anthropic: pytest-asyncio
345+
anthropic-v{0.16,0.28}: httpx<0.28.0
346+
anthropic-v0.16: anthropic~=0.16.0
347+
anthropic-v0.28: anthropic~=0.28.0
348+
anthropic-v0.40: anthropic~=0.40.0
349+
anthropic-latest: Anthropic
350+
341351
# Arq
342352
arq-v0.23: arq~=0.23.0
343353
arq-v0.23: pydantic<2
@@ -546,14 +556,6 @@ deps =
546556
# integration tests there.
547557

548558
# ~~~ AI ~~~
549-
anthropic-v0.16.0: anthropic==0.16.0
550-
anthropic-v0.25.9: anthropic==0.25.9
551-
anthropic-v0.34.2: anthropic==0.34.2
552-
anthropic-v0.43.0: anthropic==0.43.0
553-
anthropic: pytest-asyncio
554-
anthropic-v0.16.0: httpx<0.28.0
555-
anthropic-v0.25.9: httpx<0.28.0
556-
557559
huggingface_hub-v0.22.2: huggingface_hub==0.22.2
558560
huggingface_hub-v0.24.7: huggingface_hub==0.24.7
559561
huggingface_hub-v0.26.5: huggingface_hub==0.26.5

0 commit comments

Comments
 (0)