Skip to content

feat: add draft-segment-schema-pr action - #294

Open
NicolasMassart wants to merge 9 commits into
mainfrom
feat/mcwp-575-schema-pr-workflow
Open

NicolasMassart wants to merge 9 commits into
mainfrom
feat/mcwp-575-schema-pr-workflow

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a reusable draft-segment-schema-pr composite action that reads Mobile/Extension analytics diffs through the GitHub API, comments one proposal, and opens a draft Consensys/segment-schema PR after the author comments I agree to open a draft Segment schema PR.
  • Client file list uses pulls.listFiles (three-dot PR comparison). Schema YAML is still committed and pushed with git. Helper, not a merge gate.
  • Consumer workflows stay in Mobile/Extension; pin a commit SHA until @v1 exists.

fixes MCWP-575

See also platform implementation PRs:

Test plan

  • yarn test and yarn lint on this branch
  • Confirm propose posts or edits a single sticky proposal comment and does not comment on PRs with no analytics changes
  • (LATER: Requires workflow merged on main to test) Confirm create opens a draft schema PR only after the author agreement comment on an open, same-repo PR
  • (LATER: Requires workflow merged on main to test) Confirm later propose runs update the same bot branch when a schema PR is already open
  • (LATER: Requires workflow merged on main to test) Confirm close closes the schema PR when the client PR closes unmerged, and leaves it open when merged

Screenshots

Extension PR:
Extension PR screenshot

Mobile PR:
Mobile PR screenshot

NicolasMassart and others added 2 commits September 14, 2026 18:46
Open a Consensys/segment-schema draft from Mobile or Extension analytics diffs after the PR author agrees, using the GitHub API for the client file list.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@socket-security

socket-security Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedyaml@​2.9.010010010088100

View full report

@socket-security

socket-security Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • yaml@2.9.0

View full report

@NicolasMassart

Copy link
Copy Markdown
Contributor Author

@SocketSecurity ignore npm/yaml@2.9.0

official parser; we only call parseDocument(text), no reviver/onAnchor.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Analytics detection, YAML generation, comment ownership, and existing branch updates contain correctness and reliability issues.

Review effort: Balanced
Findings: 1 High severity · 9 Medium severity · 1 Low severity

Open (11)
What changed in this PR

Adds a reusable composite action that detects Mobile/Extension analytics changes and manages draft Segment schema PRs.

Changes:

  • Adds analytics extraction, schema generation, and GitHub publishing.
  • Adds gating for proposal, creation, update, and closure workflows.
  • Adds tests, documentation, dependencies, and lint/coverage configuration.
File Description
yarn.lock Locks the YAML dependency.
src/​segment-schema-draft-pr/​types.ts Defines action data models.
src/​segment-schema-draft-pr/​schema-index.ts Indexes existing schema YAML.
src/​segment-schema-draft-pr/​publish.ts Publishes comments and schema PRs.
src/​segment-schema-draft-pr/​publish.test.ts Tests publishing behavior.
src/​segment-schema-draft-pr/​pr-body.ts Renders proposal and PR text.
src/​segment-schema-draft-pr/​pr-body.test.ts Tests rendered text and splicing.
src/​segment-schema-draft-pr/​parse-args.ts Parses CLI arguments.
src/​segment-schema-draft-pr/​parse-args.test.ts Tests argument parsing.
src/​segment-schema-draft-pr/​names.ts Normalizes schema names.
src/​segment-schema-draft-pr/​names.test.ts Tests name normalization.
src/​segment-schema-draft-pr/​github-output.ts Writes action outputs.
src/​segment-schema-draft-pr/​github-output.test.ts Tests output writing.
src/​segment-schema-draft-pr/​github-api.ts Wraps GitHub API operations.
src/​segment-schema-draft-pr/​github-api.test.ts Tests GitHub API helpers.
src/​segment-schema-draft-pr/​generate.ts Orchestrates schema generation.
src/​segment-schema-draft-pr/​generate.test.ts Tests end-to-end generation.
src/​segment-schema-draft-pr/​diff-models.ts Computes analytics changesets.
src/​segment-schema-draft-pr/​diff-models.test.ts Tests changeset calculation.
src/​segment-schema-draft-pr/​constants.ts Defines shared action constants.
src/​segment-schema-draft-pr/​config.ts Defines platform configuration.
src/​segment-schema-draft-pr/​config.test.ts Tests platform configuration.
src/​segment-schema-draft-pr/​client-diff.ts Reads PR TypeScript diffs.
src/​segment-schema-draft-pr/​client-diff.test.ts Tests PR diff handling.
src/​segment-schema-draft-pr/​cli.ts Provides the action CLI entrypoint.
src/​segment-schema-draft-pr/​apply-changes.ts Creates and updates schema YAML.
src/​segment-schema-draft-pr/​apply-changes.test.ts Tests schema mutations.
src/​segment-schema-draft-pr/​analytics-model.ts Extracts analytics from TypeScript.
src/​segment-schema-draft-pr/​analytics-model.test.ts Tests analytics extraction.
src/​env-utils.ts Exposes process environment access.
src/​env-utils.test.ts Tests environment helpers.
README.md Documents action usage and workflows.
package.json Adds scripts, YAML, and action tests.
jest.config.js Raises coverage thresholds.
CHANGELOG.md Records the new action.
.github/​actions/​draft-segment-schema-pr/​gate.test.mjs Tests pre-install gating.
.github/​actions/​draft-segment-schema-pr/​gate.mjs Implements pre-install gating.
.github/​actions/​draft-segment-schema-pr/​action.yml Defines the composite action.
.eslintrc.js Adds linting for action modules.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/segment-schema-draft-pr/apply-changes.ts Outdated
Comment thread .github/actions/draft-segment-schema-pr/action.yml Outdated
Comment thread .github/actions/draft-segment-schema-pr/gate.mjs Outdated
Comment thread .github/actions/draft-segment-schema-pr/gate.mjs Outdated
Comment thread src/segment-schema-draft-pr/apply-changes.ts Outdated
Comment thread src/segment-schema-draft-pr/constants.ts Outdated
Comment thread src/segment-schema-draft-pr/diff-models.ts Outdated
Comment thread src/segment-schema-draft-pr/github-api.ts Outdated
Comment thread src/segment-schema-draft-pr/pr-body.ts Outdated
Comment thread README.md Outdated
NicolasMassart and others added 5 commits October 9, 2026 12:56
…ema draft action

- Increased coverage thresholds for branches, functions, lines, and statements in jest.config.js.
- Improved README.md to clarify the usage of the Segment schema draft CLI.
- Modified the draft-segment-schema-pr action to ensure proper fetching of remote branches and handle analytics hits more accurately.
- Updated various functions to correctly count and manage TypeScript file changes, including handling renamed files and ensuring unique event paths in the schema.
- Added tests to validate new functionality and ensure existing behavior remains intact.
Prettier rejects the unaligned markdown table in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
The github-script client replaces Authorization, so schema reads need their own client.

Co-authored-by: Cursor <cursoragent@cursor.com>
Declaring getOctokit again throws because github-script already injects it.

Co-authored-by: Cursor <cursoragent@cursor.com>
Publish called GET /user, and the workflow token rejects that request.

Co-authored-by: Cursor <cursoragent@cursor.com>
@NicolasMassart
NicolasMassart marked this pull request as ready for review October 15, 2026 12:10
Callers re-read the client pull request under the write lock before minting the App token.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
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