Skip to content

tests: smoke-test all Go + Python examples for compile/syntax regressions#1

Merged
TeoSlayer merged 2 commits into
mainfrom
add-test-coverage
May 28, 2026
Merged

tests: smoke-test all Go + Python examples for compile/syntax regressions#1
TeoSlayer merged 2 commits into
mainfrom
add-test-coverage

Conversation

@TeoSlayer
Copy link
Copy Markdown
Contributor

Summary

  • Add placeholder TestExampleCompiles in each of the 6 Go example dirs (client, echo, httpclient, secure, webserverconfig/ is JSON only) so go test ./... exercises the type-check + link path per example. Compile is implicit: the test binary cannot link if main.go references a missing or renamed symbol in the upstream SDK.
  • Add python_sdk/tests/test_examples_syntax.py that parameterizes over every top-level *.py demo and asserts (a) the file parses as valid Python via ast.parse, (b) it gates side effects on if __name__ == "__main__": so future importlib-based loaders cannot accidentally fire real daemon calls on import. Plus a guard test that fails fast if the glob ever matches zero files.
  • Wire both into .github/workflows/ci.yml: go test ./... in the go-examples job and pytest tests/ in the python-examples job (alongside the existing go build / py_compile steps — those stay as the cheapest first-line check).

Why

The Go examples were previously covered by go build ./... and the Python demos by python -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 through go test / pytest makes 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)
  • CI go-examples job builds + tests cleanly on Ubuntu w/ Go 1.25
  • CI python-examples job runs pytest cleanly on Ubuntu w/ Python 3.11

teovl added 2 commits May 27, 2026 19:18
…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.
@TeoSlayer TeoSlayer merged commit 571c98c into main May 28, 2026
4 checks passed
@TeoSlayer TeoSlayer deleted the add-test-coverage branch May 28, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants