Skip to content

Add verified README examples and an executable-README CI test - #16

Merged
kwsantiago merged 1 commit into
mainfrom
readme-examples
Jun 28, 2026
Merged

kwsantiago merged 1 commit into
mainfrom
readme-examples

Conversation

@kwsantiago

Copy link
Copy Markdown
Contributor

Expands the README with a worked example for every command, modeled on nak's example-driven docs, and adds a test that keeps those examples honest.

README

A new "Examples" section covering key, event (sign-only, tags, PoW, publish), req, count, verify, relay, sync, and decode. Every example was run before being added:

  • Read examples (req, count, relay) run against the public wss://relay.damus.io.
  • Publish and sync examples use a local relay on ws://127.0.0.1:7777, with a note that any relay URL works.
  • Deterministic offline examples (key, decode, verify, event sign-only) show exact output.

The intro flags the three things that can't be reproduced verbatim: key generate is random, event signatures use random BIP-340 aux data (so sig differs each run while id does not), and the live-query numbers reflect the relay at capture time.

Executable-README test

tests/integration_readme.sh parses the ```shell blocks in README.md, runs each example, and asserts the output matches what's shown, so a drifted example fails CI. It is offline-only and added to the build job after the existing offline tests.

  • Relay examples (any :// URL) and key generate are skipped and reported.
  • A "sig" field is normalized to "..." on both sides before comparing, so the id, content, and tags are checked exactly while the unreproducible signature is ignored.
  • The run exits non-zero if zero examples are asserted, guarding against a silent no-op.

Current run: 12 examples asserted, 0 failed, 12 skipped.

@kwsantiago
kwsantiago merged commit 235d6f4 into main Jun 28, 2026
3 checks passed
@kwsantiago
kwsantiago deleted the readme-examples branch June 28, 2026 16:49
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.

1 participant