Skip to content

ci: automate Figma Code Connect validation and publishing - #1369

Draft
georgewrmarshall wants to merge 7 commits into
mainfrom
cursor/figma-code-connect-ci-e628
Draft

ci: automate Figma Code Connect validation and publishing#1369
georgewrmarshall wants to merge 7 commits into
mainfrom
cursor/figma-code-connect-ci-e628

Conversation

@georgewrmarshall

@georgewrmarshall georgewrmarshall commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds automated Figma Code Connect CI/CD following Figma's recommended workflow:

  • Pull requests: yarn figma:connect:publish:dry-run — validates Code Connect files against the Figma API without publishing
  • Push to main: yarn figma:connect:publish — publishes Code Connect mappings to Figma Dev Mode

The job only runs when Code Connect files change (**/*.figma.tsx or figma.config.json in either design system package).

Other changes

  • New reusable workflow: .github/workflows/figma-code-connect.yml, integrated into main.yml as a required check (skipped when no Code Connect files change)
  • Added --exit-on-unreadable-files to all figma:connect:publish scripts (Figma's CI recommendation)
  • Updated docs/figma-code-connect.md and .cursor/rules/figma-integration.md with CI workflow documentation

New components without .figma.tsx files are not enforced in CI — that remains a manual / cursor rule / Bugbot check.

Related issues

Fixes:

Manual testing steps

  1. Confirm the Figma Code Connect / Validate Code Connect job passes on this PR (Code Connect files are changed, so the job should run)
  2. Verify FIGMA_ACCESS_TOKEN is configured as a repository secret with Code Connect (Write) and File content (Read-only) scopes
  3. After merge, confirm Code Connect mappings update in the MMDS Components Figma file Dev Mode

Screenshots/Recordings

N/A — CI infrastructure change

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests if applicable
  • I've documented my code using JSDoc format if applicable

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Setup required

Add a FIGMA_ACCESS_TOKEN repository secret with access to the MMDS Components Figma file. See docs/figma-code-connect.md for scope details.

Open in Web Open in Cursor 

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

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.

Create PR

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.

Comment thread package.json Outdated
"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",

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.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3f023fe. Configure here.

`Unable to diff against ${args.at(-1)}. Skipping change validation. (${message})`,
);
return [];
}

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.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3f023fe. Configure here.

Comment thread scripts/validate-figma-code-connect-changes.ts Fixed
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

@georgewrmarshall

Copy link
Copy Markdown
Contributor Author

@cursoragent token has been added address all comments, then see if CI passes

@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

All review comments are addressed and CI is passing.

Fixes applied

  1. Restored update-readme-content script — accidentally removed from package.json when adding validate:figma-code-connect-changes; yarn create-package depends on it.

  2. Git diff failure now fails CIrunGitDiff throws instead of returning [], so validation can't silently pass.

  3. CodeQL / command injection — replaced execSync with execa for git commands.

  4. Lint failures — refactored to use ValidationContext instead of process.env in tests, switched to toStrictEqual, fixed prettier formatting, and replaced process.exit() with thrown errors.

  5. CI git fetch — added git fetch origin "${GITHUB_BASE_REF:-main}" before change validation so PR diffs resolve correctly.

  6. Docs formatting — fixed prettier issues in docs/figma-code-connect.md.

CI status

Latest run passed (Main workflow — success). With the token configured, Figma Code Connect / Validate Code Connect ran the full dry-run against the Figma API successfully.

PR: #1369

Open in Web Open in Cursor 

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

cursoragent and others added 6 commits July 8, 2026 18:41
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>
@cursor
cursor Bot force-pushed the cursor/figma-code-connect-ci-e628 branch from 803fea5 to ac13d8f Compare July 8, 2026 18:41
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 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>
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📖 Storybook Links

Compare the preview for this pull request with the latest Storybooks from the main branch.

🔀 Pull Request Preview

🌳 Main Branch (Latest)

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.

3 participants