tests: smoke-test all Go + Python examples for compile/syntax regressions#1
Merged
Conversation
…ions Add a placeholder TestExampleCompiles in each Go example dir so `go test ./...` exercises the type-check + link path per example. This catches upstream pkg/protocol or SDK API breakage that plain `go build ./...` already catches today, but routes it through the test runner so future test-only CI gates also exercise the examples. Add tests/test_examples_syntax.py at the python_sdk level that parameterizes over every top-level *.py demo and asserts two properties: the file parses as valid Python and it gates side effects on `if __name__ == "__main__":`. Validates the demos remain import-safe so downstream tooling can introspect them without firing real daemon calls. Wire both into ci.yml: `go test ./...` in the go-examples job and `pytest tests/` in the python-examples job.
The examples module floats against web4 via a relative replace directive. When web4 HEAD advances its go directive or transitive deps, go.sum here goes stale and `go build ./...` fails with "updates to go.mod needed". Run `go mod tidy` in CI before build so the drift is absorbed automatically. Also bump the go directive to 1.25.10 to match what current web4 already requires.
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.
Summary
TestExampleCompilesin each of the 6 Go example dirs (client,echo,httpclient,secure,webserver—config/is JSON only) sogo test ./...exercises the type-check + link path per example. Compile is implicit: the test binary cannot link ifmain.goreferences a missing or renamed symbol in the upstream SDK.python_sdk/tests/test_examples_syntax.pythat parameterizes over every top-level*.pydemo and asserts (a) the file parses as valid Python viaast.parse, (b) it gates side effects onif __name__ == "__main__":so futureimportlib-based loaders cannot accidentally fire real daemon calls on import. Plus a guard test that fails fast if the glob ever matches zero files..github/workflows/ci.yml:go test ./...in thego-examplesjob andpytest tests/in thepython-examplesjob (alongside the existinggo build/py_compilesteps — those stay as the cheapest first-line check).Why
The Go examples were previously covered by
go build ./...and the Python demos bypython -m py_compile. That catches the same breakage, but routes nothing through the test runner — so any future test-only quality gate (race detector, coverage roll-up, dependency-graph audit) would silently skip the examples. Routing throughgo test/pytestmakes the examples visible to those tools as they land.Test plan
pytest python_sdk/tests/locally: 13/13 pass (1 directory-non-empty guard + 6 parse + 6 main-guard)go-examplesjob builds + tests cleanly on Ubuntu w/ Go 1.25python-examplesjob runspytestcleanly on Ubuntu w/ Python 3.11