Commit 2600ea4
authored
test: MM 1525 - Create a production sync job to sync feature flags from PROD (MetaMask#27405)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## 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
```gherkin
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
<img width="720" height="188" alt="image"
src="https://github.com/user-attachments/assets/e6d466c5-119e-4f49-a45c-d6affec641ac"
/>
<img width="594" height="154" alt="image"
src="https://github.com/user-attachments/assets/7e9127f1-0e42-4611-a992-31efb0d5de1a"
/>
## 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
<!-- CURSOR_SUMMARY -->
---
> [!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.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0bc4a67. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent d99884d commit 2600ea4
4 files changed
Lines changed: 1145 additions & 0 deletions
File tree
- .github/workflows
- tests/feature-flags
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| |||
0 commit comments