Skip to content

feat: auto-generate README repository table and software tools section - #2

Merged
bcastets-robotiq merged 4 commits into
mainfrom
Update
Sep 21, 2026
Merged

bcastets-robotiq merged 4 commits into
mainfrom
Update

Conversation

@bcastets-robotiq

Copy link
Copy Markdown
Collaborator

Summary

  • Restructure profile/README.md with a prominent link to the docs site, and two auto-generated sections between marker comments: Repositories (pulled from the GitHub API) and Software tools (imported from robotiq/robotiq.github.io's docs/intro.mdx).
  • Add scripts/update-readme.mjs, which regenerates both sections and fails loudly (refuses to write) if the docs site's expected markers are missing or the org's repo list comes back empty — instead of silently publishing broken/partial content.
  • Add .github/workflows/update-readme.yml, running daily (and on demand), which opens a PR only when content actually changed and auto-merges it.

Note

The auto-merge step needs a README_BOT_PAT repo secret (fine-grained PAT scoped to this repo, Contents + Pull requests: write) — see the comment at the top of update-readme.yml for why a second bot identity is required. Until that secret is added, the workflow will open PRs but fail at the approve/merge step.

Test plan

  • Ran scripts/update-readme.mjs locally against the live GitHub API and the live docs site — verified output.
  • Verified the script fails safely (no partial writes) when a marker is missing, confirmed against a real upstream rename that happened mid-development.
  • Add README_BOT_PAT secret and trigger the workflow manually (workflow_dispatch) to confirm the PR/auto-merge flow end-to-end.

🤖 Generated with Claude Code

Adds scripts/update-readme.mjs and a daily GitHub Actions workflow that
regenerate the Repositories table (from the GitHub API) and the Software
tools tables (imported from robotiq.github.io's docs/intro.mdx) between
marker comments, opening and auto-merging a PR when content changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread profile/README.md
Comment thread .github/workflows/update-readme.yml Outdated
Comment thread scripts/update-readme.mjs Outdated
Comment thread scripts/update-readme.mjs Outdated
Comment thread scripts/update-readme.mjs Outdated
Comment thread profile/README.md
@mbegin-robotiq

Copy link
Copy Markdown
Contributor

Suggestion: a small unit test suite, wired in as a required check

Four of the review comments on this PR are the same shape — pure-logic bugs that ship silently because nothing verifies the script's output:

  • a $& in a repo description splicing README text into itself (L135)
  • a half-written README when a marker pair is missing (L158)
  • relative doc links other than ](drivers/ resolving to 404s (L97)
  • upstream intro.mdx format drift

None of these need the network, the GitHub API or the filesystem to catch. A handful of assertions would cover all four:

Test Catches
a description containing $& round-trips literally L135
missing SOFTWARE-TOOLS marker leaves the README unchanged L158
](img/, ](./drivers/, ](/docs/drivers/ → absolute, or throw L97
fixture intro.mdx → expected section upstream drift
running twice produces identical output idempotence

node:test + node:assert, no dependencies, one committed fixture — roughly 60 lines.

The prerequisite is a small refactor: writeBetweenMarkers and the fetch helpers currently mix I/O with logic, so none of it is reachable from a test. Splitting out pure replaceBetweenMarkers(text, key, content) and buildRepoTable(repos) — taking plain data, returning strings — with main() as the only thing touching the network and disk, makes the tests trivial to write. That refactor also fixes the atomicity problem in the L158 comment for free.

Why it's worth more than the bugs it catches: it gives this repo the required status check it's currently missing. Wire the suite into prToMain as a required check and gh pr merge --auto becomes meaningful — the daily PR waits on the tests, and a broken README sits as an open failing PR instead of landing on the org's public page. That's precisely the safety property build-and-test provides on the docs site, and the reason that workflow's comment can argue merging without a human is safe. Right now this PR inherits the argument without the mechanism.

It also covers the failure mode this script is most exposed to: intro.mdx is generated in another repo and can change shape without warning. The marker checks catch a rename; they don't catch a table gaining a column or a link shape changing.

Happy to write the suite and the refactor as a follow-up PR if useful.

@mbegin-robotiq
mbegin-robotiq self-requested a review September 21, 2026 19:10
bcastets-robotiq and others added 3 commits September 21, 2026 15:18
- Add scripts/update-readme.test.mjs + .github/workflows/test.yml as the
  required check needed for the daily workflow's auto-merge to have
  anything to wait on.
- Fix commit author email to github-actions[bot]'s real address, so
  prToMain's require_extra_approval_for_unattributed_changes rule doesn't
  demand a second approval.
- Use a fixed branch name with force-push and reuse an existing open PR,
  instead of a new branch/PR piling up per run.
- Fix a String.replace replacement-string injection: a live repo
  description or docs-site cell containing $&, $1, etc. would otherwise
  splice into the marker block instead of being inserted literally.
- Make the README write atomic: both marker replacements now happen on one
  in-memory string before a single write, instead of two independent
  read-check-write calls.
- Broaden absolutizeDocLinks to rewrite any relative doc link, not just
  "drivers/" ones, so an unrecognized link shape upstream doesn't silently
  404 instead of resolving.

Findings from mbegin-robotiq's review on PR #2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
absolutizeDocLinks treated every non-http(s)/anchor link as document-
relative to docs/, so a link already written as an absolute path from
the site root (e.g. /docs/drivers/Foo) got /docs/ prepended a second
time. Root-relative links now get only the domain prepended.

Flagged in mbegin-robotiq's review on PR #2 (the /docs/drivers/ case
in the original comment) — missed in the first fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Closes the three gaps against mbegin-robotiq's suggested test matrix
(PR #2 comment) that the first test-suite commit didn't cover:

- scripts/fixtures/intro.mdx, a real snapshot of the docs site's
  intro.mdx, used to exercise the marker/link regexes against actual
  badge markup and multi-column tables instead of only synthetic
  single-cell markers — catches upstream format drift that a
  marker-presence check alone wouldn't.
- An idempotence test: regenerating from the same inputs twice
  produces byte-identical output.
- A file-level test that a failed second replaceBetweenMarkers call
  (mirroring main()'s read-transform-write sequence) leaves the
  README file on disk completely untouched, not just that the
  function throws.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@bcastets-robotiq
bcastets-robotiq merged commit deb81a0 into main Sep 21, 2026
1 check passed
@bcastets-robotiq
bcastets-robotiq deleted the Update branch September 21, 2026 20:00
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