Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test-snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ on:
- '*.mdx'
- 'tests/**'

# These tests create shared, named resources on one Eden AI account (custom
# tokens, uploaded files), so two runs of the same ref must not overlap.
# update-dates.yml pushes a dateModified bump to every .mdx PR, which starts a
# second run seconds after the first, so serialise them per ref.
#
# Deliberately NOT cancel-in-progress: cleanup happens in pytest_sessionfinish,
# so cancelling a started run orphans the tokens and uploaded file it created.
# The next run then snapshots those as pre-existing and never deletes them,
# leaking a little account state on every .mdx PR. Queuing costs one extra
# minute of CI and always runs cleanup. (A still-pending run carries no
# resources, so GitHub replacing it is harmless.)
concurrency:
group: test-snippets-${{ github.ref }}
cancel-in-progress: false

jobs:
execute:
name: Execution Tests
Expand Down
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ def pytest_sessionstart(session: pytest.Session) -> None:
try:
create_custom_token(**token_spec)
except requests.HTTPError as exc:
# token may already exist
if not exc.response or exc.response.status_code != 400:
# Token may already exist — another run on the same account can
# create it first. Test `is None` explicitly: Response.__bool__
# returns self.ok, so a 400 response is falsy and `not
# exc.response` was short-circuiting to True, re-raising the one
# case this handler exists to swallow.
if exc.response is None or exc.response.status_code != 400:
raise

path = _shared_state_path(session.config)
Expand Down
Loading