diff --git a/.github/workflows/test-snippets.yml b/.github/workflows/test-snippets.yml index 3ae3ffb..873c456 100644 --- a/.github/workflows/test-snippets.yml +++ b/.github/workflows/test-snippets.yml @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 6839791..6d9514f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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)