Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions .github/workflows/snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ jobs:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.78.0"
toolchain: "1.89.0"
components: rustfmt

# -----------------------------------------------------------------------
# Python — pinned minor version; patch resolved by setup-python.
Expand Down Expand Up @@ -134,19 +135,34 @@ jobs:
python3 --version
bash --version | head -1

# Runs both the extended fence checks and the Rust quickstart
# guide/crate extraction check (check:snippets-extended chains both).
- name: Check extended snippets (Rust / Python / shell / JSON / TOML / YAML)
run: pnpm run check:snippets-extended

# ---------------------------------------------------------------------------
# Stellar testnet snippet validation — split into two steps so that
# deterministic content regressions block merges while provider outages
# are surfaced as annotations without blocking.
#
# Exit codes from check-stellar-testnet-snippets.ts:
# 0 – passed
# 1 – content regression → always a hard failure
# 2 – provider outage → warning annotation, does NOT block merge
# ---------------------------------------------------------------------------
# -----------------------------------------------------------------------
# Compile the Rust quickstart crate — this is the ground-truth check
# that all documented crypto code actually compiles and its tests pass.
# The second pass enables the "network" feature so the scan / send
# modules (reqwest / tokio) are type-checked too; it is compile-only,
# no RPC calls are made.
# -----------------------------------------------------------------------
- name: Compile Rust quickstart crate
working-directory: snippets/rust-quickstart
run: cargo build --features testnet 2>&1

- name: Type-check Rust quickstart network modules
working-directory: snippets/rust-quickstart
run: cargo check --features testnet,network 2>&1

- name: Check Rust quickstart formatting
working-directory: snippets/rust-quickstart
run: cargo fmt --check

- name: Run Rust quickstart unit tests
working-directory: snippets/rust-quickstart
run: cargo test --features testnet 2>&1

stellar-testnet-snippets:
name: Stellar snippet testnet validation
runs-on: ubuntu-latest
Expand Down Expand Up @@ -361,3 +377,4 @@ jobs:
pnpm exec tsx scripts/generate-stellar-reference.ts
--check
--require-contracts=stealth-announcer,wraith-names

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ node_modules/
.npm/
test-results/
playwright-report/

# Rust build artifacts
snippets/rust-quickstart/target/
64 changes: 46 additions & 18 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,56 @@ request must hit a route documented on the page, and each fixture is compiled wi
When an example calls an endpoint, add one fixture per request it makes. `no-check`
is not allowed on that page.

### Python quickstart
### Rust quickstart crate

`guides/quickstarts/python.mdx` runs end to end in CI, offline, as part of
`check:snippets-extended`:
`guides/quickstarts/rust.mdx` is backed by a real crate,
`snippets/rust-quickstart`, that CI builds with `cargo build` / `cargo test` /
`cargo fmt --check`. Fences in that guide that belong to the crate are tagged:

```bash
npm run check:python-quickstart
````mdx
```rust crate
// src/stealth.rs
...
```
````

`scripts/python-quickstart/run_quickstart.py` builds `wraith_crypto.py` from the
fence that starts with `# wraith_crypto.py` (plus any `# Add to wraith_crypto.py`
fences), then runs every other Python fence in page order in one session. The
Soroban RPC, Horizon, and Soroban transaction calls go to local fakes that serve
recorded announcer events and verify each transaction's signatures. Results are
compared with `scripts/python-quickstart/vectors.json`, which
`npm run generate:python-quickstart-vectors` computes from the pinned SDK.

Dependencies are pinned in `scripts/python-quickstart/requirements.txt`. The
`--bootstrap` flag creates a virtualenv with those pins under
`node_modules/.cache`. Every Python fence in the guide must run. A fence that
cannot run needs both words after the language, `python Pseudocode no-check`, so
readers see it is pseudocode.
- `crate` fences are **not** compiled standalone by
`check:snippets-extended` (they reference crate-internal modules). Instead,
`scripts/check-rust-quickstart.ts` extracts every `// src/<file>` fence,
concatenates continuation fences, and byte-compares the result against
`snippets/rust-quickstart/src/<file>.rs` (after stripping crate-only
regions). If the crate and the guide drift apart, CI fails.
- The first fence for a file keeps its `// src/<file>` marker line. Later
fences start with `// src/<file> (continued)`; that line is dropped when the
fences are concatenated.
- Code that exists only in the crate (unit tests, test fixtures) is wrapped in
markers and hidden from the guide:

```rust
// crate-only-begin: reason, not shown in the guide
#[cfg(test)]
mod tests { /* ... */ }
// crate-only-end
```

- Fences that intentionally diverge from the crate (aspirational APIs,
self-contained `main` variants) use `no-check` plus a marker line and must be
listed with a reason in the `EXEMPT` map of
`scripts/check-rust-quickstart.ts`. The script also fails on stale exemptions
and on crate sources that no fence covers, so every `src/*.rs` file is
either shown in the guide or explicitly exempted.
- `Cargo.toml` is compared structurally: feature names, default features, and
dependency names (including optional flags) must match. Version strings may
differ so the guide can pin looser ranges.

After editing either side, regenerate or fix until both pass:

```bash
npm run check:rust-quickstart
# print the crate source (crate-only regions stripped) for a file:
npx tsx scripts/check-rust-quickstart.ts --emit stealth.rs
cd snippets/rust-quickstart && cargo build --features testnet && cargo test && cargo fmt --check
```

## Navigation coverage

Expand Down
Loading
Loading