Skip to content

ci(api-docs): weekly workflow to regenerate API docs from lynx-stack#1050

Merged
upupming merged 1 commit into
mainfrom
ci/auto-update-api-docs
May 28, 2026
Merged

ci(api-docs): weekly workflow to regenerate API docs from lynx-stack#1050
upupming merged 1 commit into
mainfrom
ci/auto-update-api-docs

Conversation

@upupming

@upupming upupming commented May 27, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a scheduled (weekly) + manual workflow that regenerates the lynx-stack-derived API reference docs and opens a draft PR for review. Runs entirely in lynx-website — no changes to the lynx-stack release pipeline and no cross-repo secrets.

  • scripts/update-api-docs.sh — orchestration (also runnable locally: bash scripts/update-api-docs.sh <lynx-stack-dir>).
  • .github/workflows/update-api-docs.yml — weekly cron + workflow_dispatch, opens a draft PR via peter-evans/create-pull-request.

Pipeline

  • rspeedy/: checkout lynx-stack main, build, run API Extractor + API Documenter, sync into docs/{en,zh}/api/rspeedy.
  • reactlynx-testing-library / lynx-testing-environment: TypeDoc, reading the freshly built lynx-stack packages overlaid into node_modules (so the testing-library README the published @lynx-js/react omits, and the unpublished @lynx-js/testing-environment, are available).
  • The run-typedoc post-process hook normalizes site links and escapes MDX braces, so output builds without manual fixups.
  • The build is validated in-job (pnpm run build) since GITHUB_TOKEN-created PRs don't trigger CI; the result is shown in the generated PR body.

Validation (real CI run)

Triggered a real run on GitHub via a temporary push trigger on this branch (since workflow_dispatch requires the workflow to be on the default branch first). The temporary trigger has been removed. It took three iterations to get the CI environment right:

  1. ❌ turbo's build graph pulls wasm crates (@lynx-js/react-transform, web-corebuild:wasm) which need a Rust toolchain — not present.
  2. ❌ Added actions-rust-lang/setup-rust-toolchain, but rustup couldn't on-demand sync lynx-stack's pinned channel (its rust-toolchain.toml lives in .lynx-stack/, not auto-detected at the repo root).
  3. ✅ Pinned Rust 1.92.0 + targets wasm32-unknown-unknown,wasm32-wasip1 explicitly → all steps green.

Final successful run: https://github.com/lynx-family/lynx-website/actions/runs/26519179834 (~9.5 min)

✓ Checkout lynx-website / lynx-stack
✓ Setup Rust / PNPM / Node
✓ Install dependencies
✓ Regenerate API docs   (lynx-stack build → API Extractor + Documenter → TypeDoc)
✓ Validate build        (full rspress build)
✓ Create Pull Request    (no PR opened — docs already current on main; idempotent)

This confirms end-to-end: the lynx-stack wasm build, doc generation, the full-site build gate, and the create-PR step all work — and the job is idempotent (no spurious PR when docs are already up to date, which was the case here since #1049 had merged).

Known limitations (surfaced in the generated PR's reviewer checklist)

  • docs/{en,zh}/api/_meta.json sidebar nav is not auto-reconciled (added/removed members need a manual nav edit).
  • docs/{en,zh}/api/react is not auto-regenerated (bespoke: custom intro + projectDocuments whose sources don't ship).

Companion to #1049 (the docs refresh this automates). Draft for review.

Set up weekly automated API documentation regeneration from lynx-stack

  • Add GitHub Actions workflow to regenerate lynx-stack-derived API reference on a weekly cron and via manual dispatch, serialize runs with a concurrency group, and limit job timeout to 40 minutes
  • Checkout lynx-stack main into .lynx-stack and configure Rust 1.92.0 and Node.js 24 with PNPM caching for the build
  • Run API Extractor and API Documenter inside lynx-stack to generate rspeedy docs and sync results into docs/{en,zh}/api/rspeedy while preserving hand-written index.md and pruning obsolete pages
  • Overlay freshly built lynx-stack packages into lynx-website node_modules and run TypeDoc to regenerate reactlynx-testing-library and lynx-testing-environment docs, then post-process output for site compatibility (link normalization and MDX brace escaping)
  • Validate generation by running a full site build in-job and include the build output in the generated PR body while continuing on error to surface failures without aborting the job
  • Open a draft pull request (branch bot/update-api-docs) via peter-evans/create-pull-request scoped to docs/en/api and docs/zh/api, include build output and a reviewer checklist, and auto-delete the branch after merge
  • Add scripts/update-api-docs.sh as a local, runnable orchestration script (usage: bash scripts/update-api-docs.sh )
  • Add .lynx-stack/ to .gitignore to avoid committing the external checkout
  • Harden workflow security by setting persist-credentials: false on checkouts and scoping top-level permissions

Review Change Stack

@netlify

netlify Bot commented May 27, 2026

Copy link
Copy Markdown

Deploy Preview for lynx-doc ready!

Name Link
🔨 Latest commit 7d4e223
🔍 Latest deploy log https://app.netlify.com/projects/lynx-doc/deploys/6a17c41dc2bdd60008553db0
😎 Deploy Preview https://deploy-preview-1050--lynx-doc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 213a65de-624b-448d-9e7e-977ef48da428

📥 Commits

Reviewing files that changed from the base of the PR and between d49cae4 and 7d4e223.

📒 Files selected for processing (3)
  • .github/workflows/update-api-docs.yml
  • .gitignore
  • scripts/update-api-docs.sh
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/update-api-docs.yml
  • scripts/update-api-docs.sh

Walkthrough

Adds a weekly/manual GitHub Actions workflow and a Bash script to regenerate API docs from a lynx-stack checkout, sync rspeedy-generated markdown into docs/{en,zh}/api/rspeedy, overlay built artifacts for TypeDoc, run typedoc, and open a draft PR with the build outcome.

Changes

API Documentation Automation Setup

Layer / File(s) Summary
Doc generation script and workspace setup
scripts/update-api-docs.sh, .gitignore
The update-api-docs.sh script validates a <lynx-stack-dir> argument, builds rspeedy packages, runs Microsoft API Extractor/API Documenter, syncs generated markdown into docs/{en,zh}/api/rspeedy while preserving hand-written index.md and pruning stale member pages, overlays built package artifacts into node_modules for TypeDoc accuracy, runs pnpm run typedoc, and prints completion hints. .gitignore adds .lynx-stack/ used by the workflow.
GitHub Actions workflow automation
.github/workflows/update-api-docs.yml
New Update API docs workflow triggered weekly (Sun 18:00 UTC) and manual dispatch. It sets top-level permissions: {}, gates execution via a job if, serializes runs with concurrency, checks out both repositories (placing lynx-stack under .lynx-stack with persist-credentials: false), sets up Rust 1.92.0 and Node.js 24 with pnpm caching, installs dependencies (pnpm install --frozen-lockfile), runs bash scripts/update-api-docs.sh .lynx-stack, runs pnpm run build with continue-on-error: true while capturing the result, and creates a draft PR scoped to docs/en/api and docs/zh/api using peter-evans/create-pull-request including the build outcome and a reviewer checklist.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Huxpro
  • colinaaa
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: a CI workflow that automatically regenerates API documentation from lynx-stack on a weekly schedule.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/auto-update-api-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 27, 2026

Copy link
Copy Markdown

Deploying lynx-website-next with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7d4e223
Status: ✅  Deploy successful!
Preview URL: https://2fb123ed.lynx-website-next.pages.dev
Branch Preview URL: https://ci-auto-update-api-docs.lynx-website-next.pages.dev

View logs

@upupming upupming marked this pull request as ready for review May 27, 2026 15:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/update-api-docs.yml (1)

7-11: ⚡ Quick win

Add workflow concurrency to avoid branch update races.

This workflow can be triggered by cron and manual dispatch, but both write to bot/update-api-docs. A concurrency group prevents overlapping runs from contending on the same branch.

Suggested fix
 on:
   schedule:
     - cron: '0 18 * * 0' # Weekly, Sunday 18:00 UTC
   workflow_dispatch:

+concurrency:
+  group: update-api-docs
+  cancel-in-progress: false
+
 permissions: {}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/update-api-docs.yml around lines 7 - 11, Add a top-level
"concurrency" configuration to the workflow to prevent overlapping runs writing
to the same branch (use a stable group name like "bot/update-api-docs" or
include the branch name) and set "cancel-in-progress" to true so newer runs
cancel older ones; place this concurrency block at the top level of the workflow
YAML (alongside "on", not inside a job) to ensure both the cron and
workflow_dispatch triggers use the same concurrency group.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/update-api-docs.yml:
- Around line 24-33: Update both checkout steps ("Checkout lynx-website" and
"Checkout lynx-stack") to disable credential persistence by adding
persist-credentials: false to their actions/checkout@... invocations, and add a
workflow-level concurrency key (e.g., a group using the workflow name and branch
or run id) to the workflow so runs that write to the fixed branch
bot/update-api-docs don't overlap; reference the step names and the branch
bot/update-api-docs when making these changes.

In `@scripts/update-api-docs.sh`:
- Around line 69-79: Guard the empty-glob cases in the two sync loops by
skipping iterations when the glob didn’t match and use rm -f for safe removals:
inside the first loop over "$web"/*.md and the second over "$gen"/*.md, add a
check like [ -e "$f" ] || continue (so the loop skips the literal "*.md" when
there are no matches) and replace rm "$f" with rm -f "$f"; keep the existing
basename (bn="$(basename "$f")") and cp "$f" "$web/$bn" but likewise guard the
cp loop with [ -e "$f" ] || continue so cp is never invoked on a non-existent
literal glob.

---

Nitpick comments:
In @.github/workflows/update-api-docs.yml:
- Around line 7-11: Add a top-level "concurrency" configuration to the workflow
to prevent overlapping runs writing to the same branch (use a stable group name
like "bot/update-api-docs" or include the branch name) and set
"cancel-in-progress" to true so newer runs cancel older ones; place this
concurrency block at the top level of the workflow YAML (alongside "on", not
inside a job) to ensure both the cron and workflow_dispatch triggers use the
same concurrency group.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d295d0c2-b7cb-43c5-ad47-676fb95505f2

📥 Commits

Reviewing files that changed from the base of the PR and between 0bdc280 and 7c5bc4f.

📒 Files selected for processing (3)
  • .github/workflows/update-api-docs.yml
  • .gitignore
  • scripts/update-api-docs.sh

Comment thread .github/workflows/update-api-docs.yml
Comment thread scripts/update-api-docs.sh
upupming added a commit that referenced this pull request May 28, 2026
Address CodeRabbit review on #1050:
- persist-credentials: false on both actions/checkout (avoid leaving
  GITHUB_TOKEN in git config for later steps); peter-evans/create-pull-request
  uses its own auth.
- concurrency group to serialize schedule + workflow_dispatch runs that
  write to the same bot/update-api-docs branch.

Change-Id: Ide8e5890e09ef24277ae3492404c395bf0e1f679

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05308ab331

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/update-api-docs.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/update-api-docs.yml:
- Around line 8-10: Remove the temporary push trigger added for the PR by
deleting the block that sets push: branches: [ci/auto-update-api-docs] (and the
adjacent comment "# TEMP: validation run on the PR branch — remove before
merge.") from the workflow so the workflow no longer triggers on pushes to the
ci/auto-update-api-docs branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7c0f945f-1b06-4f9e-a504-6bd9652264ec

📥 Commits

Reviewing files that changed from the base of the PR and between 4926887 and 05308ab.

📒 Files selected for processing (1)
  • .github/workflows/update-api-docs.yml

Comment thread .github/workflows/update-api-docs.yml Outdated

@Huxpro Huxpro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lfg!

Adds a scheduled (weekly) + manual workflow that regenerates the
lynx-stack-derived API reference docs and opens a draft PR for review. Runs
entirely in lynx-website — no changes to the lynx-stack release pipeline and
no cross-repo secrets.

- rspeedy/*: build lynx-stack main, run API Extractor + API Documenter, sync.
- reactlynx-testing-library / lynx-testing-environment: TypeDoc against the
  freshly built lynx-stack packages overlaid into node_modules (so the
  testing-library README and unpublished testing-environment are available).
- Sets up Rust 1.92.0 + wasm targets for lynx-stack's wasm build.
- run-typedoc post-process normalizes site links and escapes MDX braces.
- persist-credentials: false on checkouts; concurrency group serializes runs.
- Build validated in-job; opens a draft PR via peter-evans/create-pull-request.

scripts/update-api-docs.sh is also runnable locally:
  bash scripts/update-api-docs.sh <lynx-stack-dir>

Change-Id: Ibc8624cb0df8cccdb79bb3f953cbaa51f357c6a0
@upupming upupming force-pushed the ci/auto-update-api-docs branch from d49cae4 to 7d4e223 Compare May 28, 2026 04:27
@upupming upupming merged commit aadeb86 into main May 28, 2026
15 checks passed
@upupming upupming deleted the ci/auto-update-api-docs branch May 28, 2026 05:16
@coderabbitai coderabbitai Bot mentioned this pull request May 29, 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