Skip to content

test: MM 1525 - Create a production sync job to sync feature flags from PROD#27405

Merged
LeVinhGithub merged 56 commits intomainfrom
harry/MMQA-1525
Apr 1, 2026
Merged

test: MM 1525 - Create a production sync job to sync feature flags from PROD#27405
LeVinhGithub merged 56 commits intomainfrom
harry/MMQA-1525

Conversation

@LeVinhGithub
Copy link
Copy Markdown
Contributor

@LeVinhGithub LeVinhGithub commented Mar 12, 2026

Description

Automates detection of drift between the local feature flag registry and production, with CI workflow and Slack notification so the team is alerted when the registry diverges from what is live.

Why: The local feature flag registry can drift from production without notice, causing E2E or config problems.

What was added:

  • Production sync script (tests/feature-flags/sync-production-flags.ts): Fetches from production client-config API, compares to registry, and reports drift (new flags, removed flags, value mismatches, inProd mismatches). Excludes mobileMinimumVersions.
  • CLI: yarn feature-flags:sync, yarn feature-flags:sync:check, yarn feature-flags:sync:update
  • Daily CI workflow: Runs sync check, uploads drift report artifact, notifies Slack on drift
  • Unit tests: For drift detection logic

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MMQA-1525

Manual testing steps

Feature: Feature flag registry drift detection

  Scenario: Developer checks for registry drift

    Given the local feature flag registry may differ from production
    When the developer runs `yarn feature-flags:sync`
    Then they see a report of new, removed, or mismatched flags (or no drift)

  Scenario: Developer updates registry from production
    
    Given drift is detected between registry and production
    When the developer runs `yarn feature-flags:sync:update`
    Then the registry file is updated and Prettier-formatted

  Scenario: CI detects drift

    Given the workflow runs and production differs from the registry
    When the workflow completes
    Then a drift report artifact is uploaded and Slack is notified

Screenshots/Recordings

image image

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards
  • 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
  • I've applied the right labels on the PR

Pre-merge reviewer checklist

  • I've manually tested the PR
  • I confirm this PR addresses all acceptance criteria and includes necessary testing evidence

Note

Medium Risk
Adds a scheduled GitHub Actions workflow that fetches production flags, writes artifacts, and can open PRs/notify Slack, which could generate noise or unintended updates if the sync logic or API behavior is wrong.

Overview
Adds an automated production drift detector for the feature-flag registry. A new tests/feature-flags/sync-production-flags.ts CLI fetches flags from the production client-config API, compares them to tests/feature-flags/feature-flag-registry.ts, emits a JSON report, and supports --check (exit 1 on drift) and --update (rewrite registry values, add/remove entries, and flip stale inProd flags).

Introduces unit coverage for drift detection and registry rewriting, and wires it into CI via a scheduled/manual GitHub Actions workflow that runs the check weekly, uploads drift artifacts, opens an automated PR with the updated registry, and posts a Slack notification when drift is found.

Written by Cursor Bugbot for commit 0bc4a67. This will update automatically on new commits. Configure here.

@LeVinhGithub LeVinhGithub requested a review from a team as a code owner March 12, 2026 07:59
@LeVinhGithub LeVinhGithub self-assigned this Mar 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-qa QA team label Mar 12, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 12, 2026
@github-actions github-actions bot added size-XL and removed size-L labels Mar 12, 2026
pnarayanaswamy
pnarayanaswamy previously approved these changes Mar 12, 2026
@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 26, 2026
pnarayanaswamy
pnarayanaswamy previously approved these changes Mar 26, 2026
@github-actions github-actions bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 26, 2026
@LeVinhGithub LeVinhGithub enabled auto-merge March 26, 2026 15:08
@github-actions github-actions bot removed the risk-low Low testing needed · Low bug introduction risk label Mar 26, 2026
pnarayanaswamy
pnarayanaswamy previously approved these changes Mar 31, 2026
Copy link
Copy Markdown
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Nice work, just a few comments that require change imo:

  • GH action targeting main (security risk, blocking)
  • risk of label invalid values (silent failure risk, blocking)
  • use of strings instead of enums in test (not blocking)

Copy link
Copy Markdown

@cursor cursor bot left a comment

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 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 97%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 4 changed files are purely CI/tooling infrastructure with zero impact on app runtime behavior:

  1. .github/workflows/check-feature-flag-registry-drift.yml - A brand new scheduled GitHub Actions workflow (runs weekly on Tuesdays or manually). It only checks for drift between the local feature flag registry and production API values. It does not affect any PR CI pipeline or E2E test execution.

  2. tests/feature-flags/sync-production-flags.ts - A new Node.js utility script for fetching and comparing production feature flags. This is a standalone CLI tool that runs outside of the app, has no imports from app source code, and cannot affect any E2E test behavior.

  3. tests/feature-flags/sync-production-flags.test.ts - Unit tests (Jest) for the sync script above. These are not Detox E2E tests and test only the utility script logic.

  4. package.json - Only adds 3 new yarn script aliases pointing to the new sync script. No new dependencies were added, no existing scripts were modified, no version bumps occurred.

None of these changes:

  • Modify any app source code, components, or controllers
  • Change any E2E test infrastructure (Detox config, page objects, fixtures, test files)
  • Affect the feature flag registry values themselves (only adds tooling to sync them)
  • Impact any shared components used by E2E tests (navigation, modals, confirmations, etc.)
  • Modify any build configuration that could affect test execution

Running any E2E test tags would provide zero validation value for these changes and would waste CI resources.

Performance Test Selection:
No app code, UI components, state management, or performance-sensitive paths were modified. All changes are CI tooling and utility scripts that run outside the app. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-low Low testing needed · Low bug introduction risk size-XL team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants