Skip to content

ci: port docs example compilation check to all client languages - #243

Closed
harish18092002 wants to merge 2 commits into
valkey-io:mainfrom
harish18092002:auto-script
Closed

ci: port docs example compilation check to all client languages#243
harish18092002 wants to merge 2 commits into
valkey-io:mainfrom
harish18092002:auto-script

Conversation

@harish18092002

@harish18092002 harish18092002 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports the existing C# documentation example compilation check to the other GLIDE client languages (Python, Go, Node, Java, PHP). It follows the exact same split design already used for C#: this
docs repo extracts the code snippets embedded in the docs, and each client repo's validate_examples.py compiles them. This catches broken/out-of-date code examples in CI instead of leaving
them for readers to hit.

Issue link

This Pull Request is linked to issue (URL): #243

Content Changes

No documentation pages were changed. This PR only adds tooling that validates the code examples already embedded in src/content/docs/**/*.mdx.

Implementation

Docs-repo half (this repo):

  • scripts/extract_examples.py — new shared, language-aware extractor (library + CLI). Pulls fenced code blocks for a language out of the MDX into a {"<file>:<line>": code} map. Generalizes
    the previously C#-only extraction; verified byte-identical to the old csharp output (10 keys gain +1 on the line number because the old regex pointed at the blank line before the fence — the
    new value is the fence line itself).
  • scripts/check_examples.py — new generic orchestrator: extracts a language's blocks, writes them to a temp JSON file, and hands them to that language's upstream validate_examples.py,
    forwarding artifact args (e.g. --glide-dll/--glide-jar). Supports --skip-if-no-validator.
  • scripts/check_csharp_examples.py — refactored into a thin wrapper over the shared modules. Its CLI is unchanged, so check-csharp-examples.yml keeps working as-is.
  • scripts/README.md — documents the architecture and the validate_examples.py contract each client repo must implement (input JSON format, args, exit codes, dedent responsibility,
    per-language status).
  • .github/workflows/check-{python,go,node,java,php}-examples.yml — one CI job per language. Each probes the upstream repo for its validate_examples.py; until it lands, the job skips cleanly
    (green run + notice) and then enforces automatically once it exists.

Note for reviewers: the non-C# languages are intentionally inert until their upstream validator lands — this PR is the docs-repo half of the agreed split design.

Testing

  • All scripts compile (python -m py_compile).
  • Extractor verified across all six languages (csharp, java, python, go, node, php); errors cleanly on unknown languages.
  • Orchestrator tested end-to-end against a mock validator: success, failure-propagation, --skip-if-no-validator, missing-validator error, and C#-wrapper backward compatibility. Confirmed the exact
    argv forwarded to the validator (no leaked --).
  • All workflow YAML parses; new YAML + scripts/README.md are Prettier-clean (format:check passes).
  • Changes live entirely outside src/content/docs/, so the Astro site build and the rendered link set are unaffected.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • All commits are signed off with --signoff flag.
  • pnpm build runs successfully.
  • Links have been checked for validity.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

@Aryex
Aryex self-requested a review June 17, 2026 17:06
@Aryex

Aryex commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

@harish18092002 Thanks for making this PR. Are you planning on implementing the checker for the other languages as well?

@harish18092002

Copy link
Copy Markdown
Contributor Author

@harish18092002 Thanks for making this PR. Are you planning on implementing the checker for the other languages as well?

No worries @Aryex

Yeah sure

…lize the same extract-and-validate flow to every GLIDE client language so broken snippets are caught in CI instead of by readers.
@harish18092002

Copy link
Copy Markdown
Contributor Author

@Aryex Updated and added support for other languages

@Aryex

Aryex commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Hey @harish18092002, thanks for taking the time to work on this! After looking at it more closely, I realized the original issue #237 wasn't clear enough. I've updated the descriptions with more contexts.

In essence, our current C# example validator extracts the example codes into a C# project and compiles them. This not only catches syntax errors but also API mismatch, and we want to replicate this for other languages as well.

I have opened #253 that implements the Node example validator. It should help illustrate the direction we're going. Feel free to take a look and leave some comments.

That said, let me know if you'd like to continue working on this, or I can take it from here. Either way, appreciate the contribution 🙏

@Aryex

Aryex commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

@harish18092002 Are you still working on this? Otherwise I will close the PR

@Aryex Aryex closed this Jul 13, 2026
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