Add docs.nats.io examples to main with typecheck CI - #425
Conversation
Consolidates the docs-io-nats-examples, core-docs and jetstream-docs branches' examples into docs-io-nats-examples/ on main. The dir is outside every module matrix and imported by nothing, so deno never typechecks it; adds a docs-examples job to test.yml running 'deno check docs-io-nats-examples/*.ts'. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Claude finished @Jarema's task in 4m 26s —— View job PR Review
SummaryThe PR is structurally sound — 72 standalone typecheck-only examples moved from pruned branches into a permanent, CI-guarded location is the right call. The async/resource patterns across the JetStream and core examples are generally correct (proper Floating Promises (2 files)
delay(1000).then(() => {
nc.publish("weather.updates", "Weather: Sunny in NYC");
}) // no .catch()
Missing Apache 2.0 license headers (10 files) CLAUDE.md requires the license header on every source file. These 10 files are missing it:
CI job not wired into branch protection The |
|
|
||
| delay(1000).then(() => { | ||
| nc.publish("weather.updates", "Weather: Sunny in NYC"); | ||
| }) |
There was a problem hiding this comment.
Floating Promise — the .then() fires without a .catch(). If delay() rejects for any reason the error is silently swallowed. As documentation this teaches the wrong pattern. Either await the whole thing (wrapping in an immediately-invoked async block) or add .catch(console.error):
| }) | |
| delay(1000).then(() => { | |
| nc.publish("weather.updates", "Weather: Sunny in NYC"); | |
| }).catch(console.error); |
Same issue exists verbatim in getting-started-subscribe.ts.
| @@ -0,0 +1,23 @@ | |||
| // import the connect function from a transport | |||
There was a problem hiding this comment.
Missing the Apache 2.0 license header. CLAUDE.md states: "All source files must include the Apache 2.0 license header." Ten files in this PR are missing it:
learn-jetstream-pull-consumers-consumeContinuous.tslearn-jetstream-pull-consumers-fetchBatch.tslearn-jetstream-pull-consumers-emptyFetch.tslearn-jetstream-ordered-consumer-read.tslearn-jetstream-worker-pool-worker.tslearn-jetstream-worker-pool-max-pending.tslearn-jetstream-worker-pool-redelivery-count.tslearn-jetstream-shaping-the-stream-discardNew.tslearn-jetstream-shaping-the-stream-perSubjectLimit.tslearn-jetstream-shaping-the-stream-setLimits.ts
| uses: denoland/setup-deno@v2 | ||
| with: | ||
| deno-version: 2.7.x | ||
| - name: Typecheck docs examples |
There was a problem hiding this comment.
The docs-examples job is not listed in coveralls-finish's needs. That's fine for coverage (docs examples produce no coverage data), but it means coveralls-finish can pass even when docs-examples fails. If this job should truly gate merges, it needs to be added to the required status checks in the repo's branch protection settings — the workflow alone won't enforce it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every client's docs.nats.io examples are now merged into their repo's main branch, so point EXAMPLES_CONFIG there and stop tracking the per-chapter staging branches (doc-examples, core-docs, jetstream-docs). Covers nats.go, nats.rs, nats.py, nats.java, nats.net and the matching Orbit repos. Verified every configured path resolves on main before switching. nats.js stays on its branches: nats-io/nats.js#425 is still open and main has no docs-io-nats-examples directory yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UbUdMQBRUZp8MfocV15vQ5
Moves the documentation examples from the
docs-io-nats-examples,core-docsandjetstream-docsbranches intodocs-io-nats-examples/on main (72 standalone TS scripts, additive union).Unlike the other clients, merging alone gives these no CI coverage — the dir is outside every module matrix, not a workspace member, and deno only typechecks entrypoints it's told about. So this PR also adds a small
docs-examplesjob totest.yml:deno check docs-io-nats-examples/*.ts(rootdeno.jsonscopes resolve the@nats-io/*imports to the local modules).Verified locally with deno 2.7.1: all 72 files typecheck clean.
Why: the new docs.nats.io build fetches these snippets at build time; on main with a check job they can't rot silently or vanish with a pruned branch. Please keep the docs branches until the docs repo's fetch config is switched to
main(follow-up PR there).🤖 Generated with Claude Code