ci: automate Figma Code Connect validation and publishing - #1369
ci: automate Figma Code Connect validation and publishing#1369georgewrmarshall wants to merge 7 commits into
Conversation
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Removed update-readme-content script
- Restored the root package.json script to run scripts/update-readme-content.ts via tsx so create-package and docs references work again.
- ✅ Fixed: Git diff failure skips validation
- Changed the git diff error path to throw and fail the process so CI cannot skip Code Connect validation when the diff cannot be computed.
Or push these changes by commenting:
@cursor push 0b29c63402
Preview (0b29c63402)
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -53,6 +53,7 @@
"test:scripts": "NODE_OPTIONS=--experimental-vm-modules yarn jest --config ./jest.config.scripts.js --silent",
"test:storybook": "yarn workspace @metamask/storybook-react test-storybook",
"test:verbose": "yarn workspaces foreach --all --parallel --verbose run test:verbose",
+ "update-readme-content": "tsx scripts/update-readme-content.ts",
"validate:figma-code-connect-changes": "tsx scripts/validate-figma-code-connect-changes.ts",
"workspaces:list-versions": "./scripts/list-workspace-versions.sh"
},
diff --git a/scripts/validate-figma-code-connect-changes.ts b/scripts/validate-figma-code-connect-changes.ts
--- a/scripts/validate-figma-code-connect-changes.ts
+++ b/scripts/validate-figma-code-connect-changes.ts
@@ -120,10 +120,10 @@
.filter(Boolean);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
- console.warn(
- `Unable to diff against ${args.at(-1)}. Skipping change validation. (${message})`,
+ // Fail validation if we cannot determine the diff, rather than silently skipping.
+ throw new Error(
+ `Unable to diff against ${args.at(-1)}. Failing change validation. (${message})`,
);
- return [];
}
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 3f023fe. Configure here.
| "test:storybook": "yarn workspace @metamask/storybook-react test-storybook", | ||
| "test:verbose": "yarn workspaces foreach --all --parallel --verbose run test:verbose", | ||
| "update-readme-content": "tsx scripts/update-readme-content.ts", | ||
| "validate:figma-code-connect-changes": "tsx scripts/validate-figma-code-connect-changes.ts", |
There was a problem hiding this comment.
Removed update-readme-content script
High Severity
The root package.json scripts entry for update-readme-content was replaced by validate:figma-code-connect-changes, but scripts/update-readme-content.ts is unchanged and yarn create-package still invokes yarn update-readme-content after creating a workspace.
Reviewed by Cursor Bugbot for commit 3f023fe. Configure here.
| `Unable to diff against ${args.at(-1)}. Skipping change validation. (${message})`, | ||
| ); | ||
| return []; | ||
| } |
There was a problem hiding this comment.
Git diff failure skips validation
Medium Severity
When git diff against the PR base ref fails, runGitDiff logs a warning, returns an empty file list, and main exits successfully, so CI can pass without enforcing Code Connect rules for new components.
Reviewed by Cursor Bugbot for commit 3f023fe. Configure here.
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
|
@cursoragent token has been added address all comments, then see if CI passes |
|
All review comments are addressed and CI is passing. Fixes applied
CI statusLatest run passed ( PR: #1369 |
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
Add GitHub Actions workflow to dry-run Code Connect on every pull request and publish mappings when changes merge to main. Includes a change validation script for new components and CI documentation updates. Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Fall back to parse-only validation on PRs when the repository secret is not configured, so CI passes while the token is being set up. Publishing on main still requires the token. Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
- Restore update-readme-content script removed from package.json - Fail validation when git diff fails instead of silently passing - Use execa instead of execSync for safer git commands - Refactor validation context to avoid process.env in tests - Fix eslint/prettier/jest issues in validation script and tests - Fetch PR base branch in CI before running change validation Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Remove custom validation scripts and CI wrappers. PRs run figma:connect:publish:dry-run directly; merges to main run figma:connect:publish. Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
803fea5 to
ac13d8f
Compare
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|
Add a path detection job so dry-run and publish run only when .figma.tsx or figma.config.json files change, per Figma CI guidance. Treat a skipped figma job as success in the required checks gate. Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
📖 Storybook LinksCompare the preview for this pull request with the latest Storybooks from the 🔀 Pull Request Preview
🌳 Main Branch (Latest)
|





Description
This PR adds automated Figma Code Connect CI/CD following Figma's recommended workflow:
yarn figma:connect:publish:dry-run— validates Code Connect files against the Figma API without publishingmain:yarn figma:connect:publish— publishes Code Connect mappings to Figma Dev ModeThe job only runs when Code Connect files change (
**/*.figma.tsxorfigma.config.jsonin either design system package).Other changes
.github/workflows/figma-code-connect.yml, integrated intomain.ymlas a required check (skipped when no Code Connect files change)--exit-on-unreadable-filesto allfigma:connect:publishscripts (Figma's CI recommendation)docs/figma-code-connect.mdand.cursor/rules/figma-integration.mdwith CI workflow documentationNew components without
.figma.tsxfiles are not enforced in CI — that remains a manual / cursor rule / Bugbot check.Related issues
Fixes:
Manual testing steps
Figma Code Connect / Validate Code Connectjob passes on this PR (Code Connect files are changed, so the job should run)FIGMA_ACCESS_TOKENis configured as a repository secret with Code Connect (Write) and File content (Read-only) scopesScreenshots/Recordings
N/A — CI infrastructure change
Pre-merge author checklist
Pre-merge reviewer checklist
Setup required
Add a
FIGMA_ACCESS_TOKENrepository secret with access to the MMDS Components Figma file. Seedocs/figma-code-connect.mdfor scope details.