Repository navigation
feat: add shared gh, topology and Slack block helpers for workflow scripts - #338
cryptodev-2s wants to merge 18 commits into
Conversation
fa9f662 to
08cb86e
Compare
…ripts Adds ghApi and GraphQL wrappers that only retry transient failures, a typed topology.json fetch with lookups, and Slack block helpers (escape, truncate, chunk, cap). Nothing uses them yet, other scripts can adopt them later.
topology.json holds handles like @Core-platform-Team in slackHandle.team, not Slack user group IDs. Slack turns a handle in message text into a mention, so no lookup is needed.
08cb86e to
746f14b
Compare
Retries are opt in so a write is never repeated, match what gh prints for network errors, skip malformed topology entries, and cut text by its escaped length without splitting an escape or an emoji.
Octokit avoids spawning gh. It does not retry, so reads and queries go through a small retry helper that looks at the HTTP status.
| return new Octokit({ auth: token }); | ||
| } | ||
|
|
||
| // Octokit doesn't retry. Only retry what can succeed later: rate limits and |
There was a problem hiding this comment.
https://github.com/octokit/plugin-retry.js/#readme
Isn't this enabled by default?
There was a problem hiding this comment.
I can use the plugin, but it introduces another dependency. I’m wondering if we should just use Octokit directly instead. Any recommendations?
There was a problem hiding this comment.
It's already a dependency of octokit.js. I think your assumption that Octokit doesn't retry is wrong?
There was a problem hiding this comment.
I am using @octokit/rest thats why I asked if you prefer we switch to Octokit directly.
There was a problem hiding this comment.
Ah, sorry, I misunderstood. Yes, I think using Octokit directly is fine.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning MetaMask internal reviewing guidelines:
|
Explanation
Adds small shared helpers for workflow scripts, so each script doesn't write its own: a
gh apiwrapper that retries rate limits, server errors and network errors when the caller opts in (a write isn't safe to repeat), a typedtopology.jsonfetch with the Slack handle lookup, and the Slack text helpers (escape, escape and cut to a length, section).Nothing uses them yet. The Dependabot reminder in #305 is the first user. The team label action, the RC commits script and the changelog cleaner can move onto them in their own PRs.
Note
Low Risk
Additive shared utilities and tests only; no workflow or runtime behavior changes until later PRs adopt them.
Overview
Introduces reusable shared modules under
.github/scripts/shared/for upcoming workflow refactors (e.g. Dependabot reminder in #305). Nothing in production workflows imports them yet.github-cli.mtswrapsgh apiwith configurable tokens, retries only transient failures (rate limits, 5xx, network) via existingretry.mts, and addsghGraphql/ghGraphqlPageshelpers with pagination support.topology.mtsfetches and parses MetaMask-planning'stopology.jsonin one raw API call, plus slug normalization and lookups for teams, Slack user-group handles (with validation to block markup like<!channel>), and membership by GitHub user.slack-blocks.mtscentralizes Slack mrkdwn escaping, truncation, section chunking under size limits, and block capping with an overflow notice.Vitest coverage thresholds are bumped slightly to reflect the new tested code.
Reviewed by Cursor Bugbot for commit 08cb86e. Bugbot is set up for automated code reviews on this repo. Configure here.