Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/check-feature-flag-registry-drift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Check Feature Flag Registry Drift PROD

on:
schedule:
# Run every Tuesday at 01:00 UTC
- cron: "0 1 * * 2"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
check-feature-flag-registry:
name: Check feature flag registry against production
environment: default-branch
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
has-drift: ${{ steps.check.outputs.HAS_DRIFT }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"

- name: Install dependencies with retry
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
with:
timeout_minutes: 10
max_attempts: 3
retry_wait_seconds: 30
command: yarn install --immutable

- name: Check for drift and generate report
id: check
shell: bash
run: |
set +e
yarn feature-flags:sync:check 2>&1 | tee sync-report.txt
EXIT="${PIPESTATUS[0]}"
set -e
echo "HAS_DRIFT=$( [ "$EXIT" -eq 1 ] && echo true || echo false )" >> "$GITHUB_OUTPUT"
echo "HAS_ERROR=$( [ "$EXIT" -eq 2 ] && echo true || echo false )" >> "$GITHUB_OUTPUT"
# Succeed for 0 (no drift) and 1 (drift); fail for 2 (API/script error)
[ "$EXIT" -eq 0 ] || [ "$EXIT" -eq 1 ] || exit "$EXIT"

- name: Update registry and prepare artifacts
if: steps.check.outputs.HAS_DRIFT == 'true'
shell: bash
run: |
yarn feature-flags:sync:update
cp sync-report.json report.json

- name: Upload drift report
if: steps.check.outputs.HAS_DRIFT == 'true'
uses: actions/upload-artifact@v4
with:
name: drift-report
path: report.json

- name: Upload updated registry
if: steps.check.outputs.HAS_DRIFT == 'true'
uses: actions/upload-artifact@v4
with:
name: updated-registry
path: tests/feature-flags/feature-flag-registry.ts

create-drift-pr:
name: Create PR for feature flag registry drift
needs: check-feature-flag-registry
if: needs.check-feature-flag-registry.outputs.has-drift == 'true'
uses: MetaMask/github-tools/.github/workflows/create-pr-feature-flag-registry-drift.yml@e37c7027dd6f73d20f36b1d9dbeab3b084874eb6
with:
repository: metamask-mobile
registry-file-path: tests/feature-flags/feature-flag-registry.ts
registry-artifact-name: updated-registry
report-artifact-name: drift-report
workflow-run-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
pr-title-prefix: 'test: Sync Feature Flag Registry'
pr-label: 'team-qa,no-changelog'
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}

notify-slack:
name: Notify Slack on drift
needs: [check-feature-flag-registry, create-drift-pr]
if: always() && needs.check-feature-flag-registry.outputs.has-drift == 'true' && !cancelled()
runs-on: ubuntu-latest
environment: default-branch
steps:
- name: Send Slack notification
uses: MetaMask/github-tools/.github/actions/feature-flag-drift-slack-noti@e37c7027dd6f73d20f36b1d9dbeab3b084874eb6
with:
title: MetaMask Mobile
slack-webhook: ${{ secrets.SLACK_WEBHOOK_FEATURE_FLAG_DRIFT }}
workflow-run-url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
pr-url: ${{ needs.create-drift-pr.outputs.pr-url || '' }}

This file was deleted.

1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ npmAuditIgnoreAdvisories:
- 1113402 # bn.js affected by an infinite loop. No fix available yet (latest is 5.2.1, affected <=5.2.3). Suppressing for now to unblock CI. https://github.com/advisories/GHSA-378v-28hj-76wf
- 1113441 # bn.js affected by an infinite loop. No fix available yet (latest is 5.2.1, affected <=5.2.3). Suppressing for now to unblock CI. https://github.com/advisories/GHSA-378v-28hj-76wf
- 1113442 # bn.js affected by an infinite loop. No fix available yet (latest is 5.2.1, affected <=5.2.3). Suppressing for now to unblock CI. https://github.com/advisories/GHSA-378v-28hj-76wf
- 1115765 # XML injection via unsafe CDATA serialization allows attacker-controlled markup insertion https://github.com/advisories/GHSA-wh4c-j3r5-mjhp

yarnPath: .yarn/releases/yarn-4.10.3.cjs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const SAMPLE_ACCOUNT_GROUP = {
name: 'Account 1',
pinned: false,
hidden: false,
lastSelected: 0,
},
accounts: ['account-1'],
id: 'keyring:test-group/ethereum' as const,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export const createMockState = (
AccountTreeController: {
accountTree: {
wallets: walletMap,
selectedAccountGroup: firstGroupId ?? '',
},
selectedAccountGroup: firstGroupId ?? '',
},
AccountsController: {
internalAccounts: {
Expand Down
6 changes: 4 additions & 2 deletions app/components/UI/Bridge/_mocks_/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ export const initialState = {
},
AccountTreeController: {
accountTree: {
selectedAccountGroup: `${AccountWalletType.Entropy}:wallet1/0`,
wallets: {
[`${AccountWalletType.Entropy}:wallet1`]: {
id: `${AccountWalletType.Entropy}:wallet1`,
type: AccountWalletType.Entropy,
status: 'ready' as const,
metadata: {
name: 'Test Wallet 1',
entropy: {
Expand All @@ -503,6 +503,7 @@ export const initialState = {
name: 'Test Group 1',
pinned: false,
hidden: false,
lastSelected: 0,
entropy: {
groupIndex: 0,
},
Expand All @@ -517,7 +518,8 @@ export const initialState = {
},
},
},
} as AccountTreeControllerState['accountTree']['wallets'],
} as AccountTreeControllerState['accountTree'],
selectedAccountGroup: `${AccountWalletType.Entropy}:wallet1/0` as const,
},
SmartTransactionsController: {
smartTransactionsState: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const setupMultichainState = (
...(multichainEnabled && {
AccountTreeController: {
accountTree: {
selectedAccountGroup: `${AccountWalletType.Entropy}:wallet1/0`,
wallets: options.emptyWalletsMap
? {}
: (options.walletsMap ??
Expand All @@ -97,6 +96,7 @@ const setupMultichainState = (
[accountId],
)),
},
selectedAccountGroup: `${AccountWalletType.Entropy}:wallet1/0`,
},
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ describe('EarnLendingWithdrawalConfirmationView', () => {
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
AccountTreeController: {
accountTree: {
selectedAccountGroup: 'keyring:test-wallet/ethereum',
wallets: {
'keyring:test-wallet': {
id: 'keyring:test-wallet',
Expand All @@ -180,6 +179,7 @@ describe('EarnLendingWithdrawalConfirmationView', () => {
},
},
},
selectedAccountGroup: 'keyring:test-wallet/ethereum',
},
},
},
Expand Down Expand Up @@ -1064,7 +1064,6 @@ describe('EarnLendingWithdrawalConfirmationView', () => {
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
AccountTreeController: {
accountTree: {
selectedAccountGroup: 'keyring:test-wallet/ethereum',
wallets: {
'keyring:test-wallet': {
id: 'keyring:test-wallet',
Expand All @@ -1077,6 +1076,7 @@ describe('EarnLendingWithdrawalConfirmationView', () => {
},
},
},
selectedAccountGroup: 'keyring:test-wallet/ethereum',
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Earn/hooks/useEarnNetworkPolling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('useEarnNetworkPolling', () => {
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
AccountTreeController: {
accountTree: {
selectedAccountGroup: 'keyring:test-wallet/ethereum',
wallets: {
'keyring:test-wallet': {
id: 'test-wallet',
Expand All @@ -90,6 +89,7 @@ describe('useEarnNetworkPolling', () => {
},
},
},
selectedAccountGroup: 'keyring:test-wallet/ethereum',
},
PreferencesController: {
useTokenDetection: true,
Expand Down Expand Up @@ -233,9 +233,9 @@ describe('useEarnNetworkPolling', () => {
},
AccountTreeController: {
accountTree: {
selectedAccountGroup: '',
wallets: {},
},
selectedAccountGroup: '',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Earn/hooks/useEarningsHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe('useEarningsHistory', () => {
},
AccountTreeController: {
accountTree: {
selectedAccountGroup: groupId,
wallets: {
[walletId]: {
id: walletId,
Expand All @@ -69,6 +68,7 @@ describe('useEarningsHistory', () => {
},
},
},
selectedAccountGroup: groupId,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export function getOnboardingNavbarOptions(
/>
</View>
)
: null,
: '',
headerRight: headerRightHide,
headerLeft: headerLeftHide,
headerTintColor: themeColors.primary.default,
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Navbar/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe('Navbar', () => {
false,
);

expect(options.headerTitle).toBeNull();
expect(options.headerTitle).toBe('');
});
});

Expand Down
Loading
Loading