Repository navigation
Live tests for the Python and asyncio docs code samples - #241
Open
techwritermat wants to merge 15 commits into
Open
techwritermat wants to merge 15 commits into
techwritermat wants to merge 15 commits into
Conversation
The "Cancel workflow runs for commit on error" step (fast-jobs-failure) cancels every workflow of the commit when one fast job fails, so an unrelated failure cancelled the first attempt of other workflows. The JavaScript SDK removed the same step in PR 539. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds docs-snippets/, a pytest suite that runs the code samples of the Python and asyncio docs against the real PubNub service and asserts the documented effect. The docs embed the snippet regions with EmbeddedCode. * 311 snippet ids in 193 steps (sync and asyncio), roles open and pam * assertions sit outside the snippet markers, a marker lint enforces it * honesty checks: each step must reach snippet.end and make an assertion * run-suffixed names per step, key and token redaction, janitor, no skips * coverage.json manifest with a --check mode * separate workflow: dry job on Python 3.9 to 3.13, live shards in series under one concurrency group, nightly, fork PRs skip live * setup.py excludes docs-snippets from the package Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
techwritermat
requested review from
jguz-pubnub,
kazydek and
parfeon
as code owners
November 12, 2026 10:01
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
The staged copy under docs-snippets/.run/<id>/ cannot find the checkout from its own harness package, so pytest failed with "No module named 'pubnub'" wherever the package is not installed (the CI runner installs only the dev requirements). The run now sets PYTHONPATH to the repository root. The key status line prints only the roles the shard needs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The presence service resolves a channel group some seconds after it was created and answers 400 "No valid channels specified" until then. The read after the write now retries for up to 45 seconds with the same assertion. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Updated lint job names in live integration workflows to remove reference to port map. - Modified lint function in cli.py to conditionally check for base availability before executing port map checks, providing a fallback message for shallow CI checkouts. - Added base_available function in port_map.py to verify if the base commit exists in the current checkout.
…lity - Replaced instances of aeventually with asettled in various test files to ensure consistent state checks. - Updated related imports to include asettled where necessary. - Enhanced test reliability by ensuring that state checks wait for settled conditions before proceeding.
- Added a new `present` function to ensure user IDs are occupants of specified channels during presence tests. - Updated `seed_parallel_async` to include a concurrency parameter, allowing controlled message publishing with error handling. - Modified presence tests to utilize the new `present` function for improved reliability in state checks.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Refactored comments in `live-integration.yml` for clarity on failure alerts. - Improved documentation in `conftest.py` regarding the offline guard feature. - Removed unused `port-map` functionality from `cli.py` and related files. - Updated README and other documentation files for consistency and clarity. - Enhanced test descriptions and fixed minor issues in various test files. - Deleted obsolete files related to endpoint tier moves and port text changes. These changes streamline the testing process and improve the overall documentation for the live tier tests.
- Replaced the `seed_parallel` function with `seed_many` in multiple test files to publish messages sequentially, ensuring unique timetokens for each publish. - Updated relevant test cases to reflect the change in message seeding method, enhancing reliability in message history checks. These changes improve the accuracy of message publishing tests by preventing duplicate timetokens during concurrent operations.
Take master's Ruff setup (#243) for the validations workflow and the lint command, and restore the cross-workflow cancel step in the Tests workflow, so the only differences from master outside tests/live are the live tier's own files. The test command keeps --ignore=tests/live/ because the live tier needs keys and runs in its own workflow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
flake8 is no longer installed (requirements-dev.txt follows master). The live workflow now runs `ruff check tests/live`, the README says so, and the encryption page drops two imports that the samples import themselves and uses a Ruff noqa for the blank lines that the published sample keeps. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Introduced a new `test_objects.py` file for asyncio tests, covering various metadata operations including UUID and channel management. - Updated `coverage.json` to include new test cases for the asyncio API reference. - Modified `groups.py` to reference the new asyncio test file. - Cleaned up `snippet-exceptions.json` by removing obsolete entries related to the asyncio docset. These changes enhance the testing framework for asyncio operations, ensuring comprehensive coverage and improved organization of test cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
docs-snippets/, a pytest suite that runs the code samples of the Python and asyncio SDK docs against the real PubNub service and asserts the documented effect. The docs embed the snippet regions withEmbeddedCodefrom this repo (refs/heads/master/docs-snippets/...). It follows the JavaScript suite (pubnub/javascriptPRs 538 and 539).Two commits:
ci: remove the cross-workflow cancel step. Removes the fourfast-jobs-failuresteps fromrun-tests.ymlandrun-validations.yml. One failing fast job cancelled every workflow of the commit, so the first attempt of other workflows ended cancelled.test: add live docs snippet tests. The suite, its workflow and thesetup.pyexclude.What is covered
How it stays honest
snippet.endor when it made no assertionxfail, no fixed sleeps (eventuallyfor reads after writes), subset runs are refused in CIcoverage.jsonlists every snippet id,python -m harness.cli manifest --checkfails when it is stalepython -m harness.auditlists assertions per step, one log file per step is written toreport/<shard>/steps/Latest live results (open and pam keysets)
get_message_actionsignoresendwhenstartis set (pubnub/endpoints/message_actions/get_message_actions.py:50), andPubNubSubscriptionSet.unsubscribe()leaves the channels subscribed (pubnub/models/subscription.py:162-182), each in sync and asyncio. The nightly stays red until these are fixed or the expectation changes. More SDK findings are in the follow-up message to the maintainersWorkflow
.github/workflows/docs-snippets.yml: achangesjob, adryjob (no network, Python 3.9 to 3.13), alivejob (open shard then pam shard in series under one concurrency group, Python 3.11) and agatejob to require in branch protection. Triggers: pull request, push to master, nightly, manual. Fork PRs skip the live job.Needed before the live job can run
Secrets:
SDK_DOCS_OPEN_PUBLISH_KEY,SDK_DOCS_OPEN_SUBSCRIBE_KEY,SDK_DOCS_PAM_PUBLISH_KEY,SDK_DOCS_PAM_SUBSCRIBE_KEY,SDK_DOCS_PAM_SECRET_KEY. The open keyset needs Message Persistence with Delete-From-History, Presence with a*tracking rule and legacy SDK tracking, App Context with events, Files, Mobile Push and Stream Controller with wildcard subscribe. The pam keyset needs Access Manager with token revocation. Without a GitHub Environment with required reviewers, anyone with push access can read the secrets through a pull request.Not changed
pubnub/,tests/,examples/and the version are untouched. Run it locally withcd docs-snippets && python -u -m harness.cli dry(no keys) orpython -u -m harness.cli run. Seedocs-snippets/README.md.🤖 Generated with Claude Code