Skip to content

Commit c1457f6

Browse files
committed
Fix problem with evn var
1 parent 90e5d26 commit c1457f6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

.github/workflows/stubsabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
id: runstubsabot
4343
run: |
4444
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything
45+
STUBS=$(cat /tmp/stubs.txt)
4546
echo "Stubs that should be tested by stubtest: $STUBS"
4647
echo "STUBS=$STUBS" >> $GITHUB_OUTPUT
4748

scripts/stubsabot.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
POLICY_MONTHS_DELTA = 6
4848

49+
DEFAULT_STUBTEST_FILE = Path("/tmp/stubs.txt") # Sync with `stubsabot` github job
50+
4951

5052
class ActionLevel(enum.IntEnum):
5153
def __new__(cls, value: int, doc: str) -> Self:
@@ -629,6 +631,17 @@ def is_new_release(upload_datetime: datetime.datetime) -> bool:
629631
return upload_datetime > yesterday
630632

631633

634+
def append_stub_to_stubtest_list(distribution: str, *, file_path: Path = DEFAULT_STUBTEST_FILE) -> None:
635+
if Path.exists(file_path):
636+
with Path.open(file_path, "r") as f:
637+
stubs = f.read().strip()
638+
else:
639+
stubs = ""
640+
stubs = f"{stubs} {distribution}" if stubs else distribution
641+
with Path.open(file_path, "w") as f:
642+
f.write(stubs)
643+
644+
632645
async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete | Remove | Error:
633646
try:
634647
return await determine_action_no_error_handling(distribution, session)
@@ -673,11 +686,7 @@ async def determine_action_no_error_handling(
673686
obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session)
674687
if obsolete_since is None and latest_version in stub_info.version_spec:
675688
if is_new_release(latest_release.upload_date):
676-
stubs = os.environ.get("STUBS", "").strip()
677-
if stubs:
678-
stubs = f"{stubs} {latest_release.distribution}"
679-
else:
680-
stubs = latest_release.distribution
689+
append_stub_to_stubtest_list(latest_release.distribution)
681690
return NoUpdate(stub_info.distribution, "up to date")
682691

683692
relevant_version = obsolete_since.version if obsolete_since else latest_version

0 commit comments

Comments
 (0)