From d9b53e573943c31819c9b8a24912d42018e5768e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Van=20Eyck?= Date: Wed, 17 Apr 2024 10:22:17 +0200 Subject: [PATCH 1/7] fix(8667): trigger swap tx on approval tx confirmed (#9173) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** When swapping a token that needs approval (and requires a 2 step swap process), it's needed for the user, when using a hardware wallet, to manually sign transactions. Currently, second modal opening is triggered when approval transaction is finished (meaning when it has been submitted). But this would end up in a situation where the first modal was not unmounted before it was asked to be mounted again. This flow was creating an issue where the user could not confirm the second transaction (as second modal was never displayed) To mitigate this issue, we choose to wait for first transaction completion before starting the second one. This is not perfect from user POV as a long delay can happen between approval and swap txs, but as discussed with @AlexJupiter and @gantunesr it's considered as a temporary solution until we figure out a long term one. ## **Related issues** Fixes: https://github.com/MetaMask/metamask-mobile/issues/8667 ## **Manual testing steps** For ease the explanation, we are using `AAVE` and `MATIC` on Polygon network and will sign txs with a Ledger account. You also need blind signing to be enabled on your Ledger device. 1. make sure `AAVE` token approval has been revoked here https://polygonscan.com/tokenapprovalchecker for your Ledger account 2. select swap action from actions dropdown 3. select your Ledger account 4. select `AAVE` token as origin token 5. type a value that you want to swap (`0.0000001` is fine) 6. select `MATIC` token as destination token 7. get quotes (you may need to retry several times this step) 8. Swipe to swap 9. First modal should be displayed. Sign approval tx on your ledger device 10. Once approval txs is confirmed, second modal is opening. Sign swap tx on your ledger device 11. Swap should be completed ## **Screenshots/Recordings** ### **Before** https://recordit.co/Vg7MLtediW ### **After** https://github.com/MetaMask/metamask-mobile/assets/574787/fbe01613-2dd5-4762-98f6-4072782e7491 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] 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](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. --- app/components/UI/Swaps/QuotesView.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/UI/Swaps/QuotesView.js b/app/components/UI/Swaps/QuotesView.js index d6e54ffc731..14faa6ae1ef 100644 --- a/app/components/UI/Swaps/QuotesView.js +++ b/app/components/UI/Swaps/QuotesView.js @@ -992,9 +992,9 @@ function SwapsQuotesView({ }; if (isHardwareAddress) { TransactionController.hub.once( - `${transactionMeta.id}:finished`, + `${transactionMeta.id}:confirmed`, (transactionMeta) => { - if (transactionMeta.status === TransactionStatus.submitted) { + if (transactionMeta.status === TransactionStatus.confirmed) { handleSwapTransaction( TransactionController, newSwapsTransactions, From 67e6fcced9a9f8906d4d20344d923a2f8b3db3b6 Mon Sep 17 00:00:00 2001 From: Gauthier Petetin Date: Wed, 17 Apr 2024 09:39:52 -0300 Subject: [PATCH 2/7] fix(labeling guidelines): Add definition of regression-develop label (#9142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** - New definition added to labelling guidelines: `regression-develop`. - Same PR on Extension reop: https://github.com/MetaMask/metamask-extension/pull/23855 ## **Related issues** - Fixes: None ## **Manual testing steps** - None ## **Screenshots/Recordings** - Preview available here: https://github.com/MetaMask/metamask-mobile/blob/efaf3bb3fe2d36219f67345dd921cd9e890944fd/.github/guidelines/LABELING_GUIDELINES.md ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. --- .github/guidelines/LABELING_GUIDELINES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/guidelines/LABELING_GUIDELINES.md b/.github/guidelines/LABELING_GUIDELINES.md index 84366a5de80..f3fbc606f22 100644 --- a/.github/guidelines/LABELING_GUIDELINES.md +++ b/.github/guidelines/LABELING_GUIDELINES.md @@ -21,6 +21,9 @@ Every PR shall include one the QA labels below: Once PR has been tested by QA (only if the PR was labeled with `needs-qa`): - **QA Passed**: If the PR was labeled with `needs-qa`, this label must be added once QA has signed off +### Optional labels: +- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on development branch (i.e. `main`), but is not yet released in production. + ### Labels prohibited when PR needs to be merged: Any PR that includes one of the following labels can not be merged: From 420defa2569ce26c0c27caa330efa28d6c460adf Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 17 Apr 2024 18:16:52 +0530 Subject: [PATCH 3/7] Extend blockaid validations to base network (#9030) --- .../__snapshots__/SecuritySettings.test.tsx.snap | 2 +- app/util/networks/index.js | 2 ++ locales/languages/de.json | 2 -- locales/languages/el.json | 2 -- locales/languages/en.json | 4 ++-- locales/languages/es.json | 2 -- locales/languages/fr.json | 2 -- locales/languages/hi.json | 2 -- locales/languages/id.json | 2 -- locales/languages/ja.json | 2 -- locales/languages/ko.json | 2 -- locales/languages/pt.json | 2 -- locales/languages/ru.json | 2 -- locales/languages/tl.json | 2 -- locales/languages/tr.json | 2 -- locales/languages/vi.json | 2 -- locales/languages/zh.json | 2 -- 17 files changed, 5 insertions(+), 31 deletions(-) diff --git a/app/components/Views/Settings/SecuritySettings/__snapshots__/SecuritySettings.test.tsx.snap b/app/components/Views/Settings/SecuritySettings/__snapshots__/SecuritySettings.test.tsx.snap index 14607b59c9b..478224ef980 100644 --- a/app/components/Views/Settings/SecuritySettings/__snapshots__/SecuritySettings.test.tsx.snap +++ b/app/components/Views/Settings/SecuritySettings/__snapshots__/SecuritySettings.test.tsx.snap @@ -741,7 +741,7 @@ exports[`SecuritySettings should render correctly 1`] = ` } } > - Privacy preserving - no data is shared with third parties. Available on Arbitrum, Avalanche, BNB chain, Ethereum Mainnet, Optimism, Polygon and Sepolia. + Privacy preserving - no data is shared with third parties. Available on Arbitrum, Avalanche, BNB chain, Ethereum Mainnet, Optimism, Polygon, Sepolia and Base. Date: Wed, 17 Apr 2024 22:54:47 +0800 Subject: [PATCH 4/7] fix: missing walletConnect prop (#9283) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** - Issue with `generateRawSignature` that didn't include the `isWalletConnect` property. - Issue undetected because of a missing type (set as any) in the method signature. ## **Related issues** Fixes: https://github.com/MetaMask/metamask-mobile/issues/9246 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. --- app/core/RPCMethods/RPCMethodMiddleware.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/core/RPCMethods/RPCMethodMiddleware.ts b/app/core/RPCMethods/RPCMethodMiddleware.ts index 9ff5444a3a7..edf11157f08 100644 --- a/app/core/RPCMethods/RPCMethodMiddleware.ts +++ b/app/core/RPCMethods/RPCMethodMiddleware.ts @@ -208,8 +208,23 @@ const generateRawSignature = async ({ chainId, channelId, getSource, + isWalletConnect, checkTabActive, -}: any) => { +}: { + version: string; + req: any; + hostname: string; + url: { current: string }; + title: { current: string }; + icon: { current: string | undefined }; + analytics: { [key: string]: string | boolean }; + chainId: number; + isMMSDK: boolean; + channelId?: string; + getSource: () => string; + isWalletConnect: boolean; + checkTabActive: any; +}) => { const { SignatureController } = Engine.context; const pageMeta = { @@ -230,7 +245,7 @@ const generateRawSignature = async ({ channelId, address: req.params[0], chainId, - isWalletConnect: false, + isWalletConnect, }); const rawSig = await SignatureController.newUnsignedTypedMessage( From 191456dbda3086fac32c3ea3b3801ba4f242e26a Mon Sep 17 00:00:00 2001 From: abretonc7s <107169956+abretonc7s@users.noreply.github.com> Date: Wed, 17 Apr 2024 22:55:06 +0800 Subject: [PATCH 5/7] fix: invalid url on inapp-browser (#9284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Invalid url when using in-app browser. ## **Related issues** Fixes: https://github.com/MetaMask/metamask-mobile/issues/9259 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. --- .../Views/AccountConnect/AccountConnect.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/components/Views/AccountConnect/AccountConnect.tsx b/app/components/Views/AccountConnect/AccountConnect.tsx index fa7b47a4da2..9bea2310084 100644 --- a/app/components/Views/AccountConnect/AccountConnect.tsx +++ b/app/components/Views/AccountConnect/AccountConnect.tsx @@ -172,6 +172,15 @@ const AccountConnect = (props: AccountConnectProps) => { ); const loadHostname = useCallback(async () => { + // walletconnect channelId format: 1713357238460272 + // sdk channelId format: uuid + // inappbrowser channelId format: app.uniswap.io + + // check if channelId contains dot, it comes from in-app browser and we can use it. + if (channelId.indexOf('.') !== -1) { + return origin; + } + if (sdkConnection) { const _hostname = ( sdkConnection?.originatorInfo?.url ?? metadataOrigin @@ -180,7 +189,7 @@ const AccountConnect = (props: AccountConnectProps) => { } return wc2Metadata?.url ?? channelId; - }, [channelId, metadataOrigin, sdkConnection, wc2Metadata]); + }, [channelId, metadataOrigin, sdkConnection, origin, wc2Metadata]); // Retrieve hostname info based on channelId useEffect(() => { From 3ef99f10fb668d6acfc883a5e463b4423d70fe83 Mon Sep 17 00:00:00 2001 From: Desi McAdam Date: Wed, 17 Apr 2024 11:24:20 -0600 Subject: [PATCH 6/7] feat: Improve localization workflow such that it allows for branch/PR focused translation (#8565) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows for branch/PR focused translations ## **Description** Currently, translation only happens once changes to the en.json file are merged to main. These changes could include new keys being added or changes to english text. What this means is that there is no way currently to require that translations be in place before the feature goes live. It could make it through translation before being released but there is currently no way to require that we wait for translations. ## **Related issues** Fixes: [8564](https://github.com/MetaMask/metamask-mobile/issues/8564) ## **Manual testing steps - To be done after merge and with Desi** **Use case 1 (feature branch requires translation):** - Developer creates a branch for feature which requires translations - They add keys or change english source and when they are ready for translations to be done they create a PR and add the label “ready-for-translation” - Manually trigger crowdin-branch-pr-ready-for-translation.yml ON THE BRANCH - Confirm branch created in crowdin with just the untranslated keys (plus any untranslated ones from main or any translated but not merged keys from main) - This is where we could get confusion on the BLEND side. - Wait for translations (Desi will likely have to talk to BLEND to let them know what we are doing and get these translations done so that we can finish out the test) - Manually trigger the translation check before translations complete (confirm no translation PR created) - Manually trigger the translation check after translations complete (confirm PR created off this branch) - Merge translation PR into branch, manually remove label (later PR will do this automatically), manually delete localization branch for this branch (later PR will do this automatically) - Merge PR for feature to main - Manually trigger crowdin-upload-both-sources-translations.yml and ensure translations show on main in crowdin. - Manually trigger crowdin-branch-cleanup.yml and make sure the branch is removed from crowdin **Use Case 2 (main branch translations):** - Developer is working just normally and adds new keys or changes english version in some way. - They go through normal PR flow once they merge to main - Manually trigger crowdin-upload-both-sources-translations.yml - Confirm new keys are on main - Work with Blend to get one thing translated so we can see crowdin-pull-branch-pr-completed-translations.yml pull down the partial translation - Manually trigger crowdin-pull-branch-pr-completed-translations.yml and check the localization PR has the translations. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --------- Co-authored-by: Elliot Winkler --- .github/workflows/crowdin-branch-cleanup.yml | 73 +++++++++++++++++++ ...rowdin-branch-pr-ready-for-translation.yml | 50 +++++++++++++ ...-pull-branch-pr-completed-translations.yml | 63 ++++++++++++++++ .../crowdin-reusable-translation-download.yml | 64 ++++++++++++++++ ...owdin-upload-both-sources-translations.yml | 31 ++++++++ 5 files changed, 281 insertions(+) create mode 100644 .github/workflows/crowdin-branch-cleanup.yml create mode 100644 .github/workflows/crowdin-branch-pr-ready-for-translation.yml create mode 100644 .github/workflows/crowdin-pull-branch-pr-completed-translations.yml create mode 100644 .github/workflows/crowdin-reusable-translation-download.yml create mode 100644 .github/workflows/crowdin-upload-both-sources-translations.yml diff --git a/.github/workflows/crowdin-branch-cleanup.yml b/.github/workflows/crowdin-branch-cleanup.yml new file mode 100644 index 00000000000..7515abfa034 --- /dev/null +++ b/.github/workflows/crowdin-branch-cleanup.yml @@ -0,0 +1,73 @@ +name: Crowdin - Branch and Label Cleanup for merged localization PR +# This action should delete the branch from Crowdin after the localization PR is +# merged to the original branch. It should also remove the "ready-for-translation" label + +# TODO: Add trigger for merge of localization PR. +on: workflow_dispatch + +jobs: + prestep: + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.extract_current_branch.outputs.branch }} + pr: ${{ steps.get-prs.outputs.pr }} + steps: + - name: Extract current branch name + shell: bash + run: | + echo "running on branch ${GITHUB_REF##*/}" + echo "other version: ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT" + id: extract_current_branch + + - name: Get PR with Label for this branch + id: get-prs + run: | + LABEL="ready-for-translation" + API_URL="https://api.github.com/repos/Metamask/crowdin-sandbox/pulls?head:${{steps.extract_current_branch.outputs.branch}}&state=open&per_page=100" + # Fetch the list of open pull requests with the specified label using curl + PRS=$(curl -sS --header "Authorization: Bearer $GITHUB_TOKEN" "$API_URL") + PR=$(echo "$PRS" | jq -r '.[] | select(.labels[].name == "'"$LABEL"'") | .number | @json') + echo "Found PR: $PR" + echo "pr=$PR" >> "$GITHUB_OUTPUT" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CURRENT_BRANCH: ${{ steps.extract_current_branch.outputs.branch }} + + github_cleanup: + runs-on: ubuntu-latest + needs: prestep + steps: + - name: Remove label from PR + uses: actions/github-script@v3 + if: needs.prestep.outputs.pr != null || needs.prestep.outputs.pr != '' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const label = "ready-for-translation"; + await github.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ needs.prestep.outputs.pr }}, + name: label + }); + + crowdin_cleanup: + runs-on: ubuntu-latest + needs: prestep + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ needs.prestep.outputs.branch }} + + - name: Delete branch within Crowdin + if: needs.prestep.outputs.branch != 'main' + uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d + with: + command: branch delete ${{ needs.prestep.outputs.branch }} + command_args: -v diff --git a/.github/workflows/crowdin-branch-pr-ready-for-translation.yml b/.github/workflows/crowdin-branch-pr-ready-for-translation.yml new file mode 100644 index 00000000000..36ec31ba547 --- /dev/null +++ b/.github/workflows/crowdin-branch-pr-ready-for-translation.yml @@ -0,0 +1,50 @@ +name: Crowdin - Ready for translations label added, push to crowdin + +# When an individual is working on a feature which requires translations, they can +# add a label "ready-for-translation" which will trigger this action to push the +# source and translation files to Crowdin. We will always push main as the base of +# the crowdin branch creation and then push in the changes over the top. This ensures +# that the translations which have already been done and approved previously do not +# show as needing to be translated again in the crowdin branch. + +# TODO: switch to trigger on label add once testing complete +on: workflow_dispatch + +jobs: + crowdin-upload: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + steps: + - name: Extract current branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT" + id: extract_current_branch + + - name: Checkout + uses: actions/checkout@v3 + with: + ref: main + + - name: Crowdin push main as baseline + uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d + with: + crowdin_branch_name: ${{ steps.extract_current_branch.outputs.branch }} + upload_sources: true + upload_translations_args: --import-eq-suggestions --auto-approve-imported --verbose + upload_translations: true + + - name: Checkout Branch and push to crowdin + uses: actions/checkout@v3 + with: + ref: ${{ steps.extract_current_branch.outputs.branch }} + - name: Crowdin sources push + uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d + with: + crowdin_branch_name: ${{ steps.extract_current_branch.outputs.branch }} + upload_sources: true + upload_sources_args: --auto-update --verbose + upload_translations: false diff --git a/.github/workflows/crowdin-pull-branch-pr-completed-translations.yml b/.github/workflows/crowdin-pull-branch-pr-completed-translations.yml new file mode 100644 index 00000000000..1669e2b7b47 --- /dev/null +++ b/.github/workflows/crowdin-pull-branch-pr-completed-translations.yml @@ -0,0 +1,63 @@ +name: Crowdin - Find all branches with translations and trigger completion checks +# This workflow will run on a schedule. It will pull all pull requests with a label of +# ready-for-translation and create a matrix of the associated branches to run the +# crowdin-reusable-translation-download.yml workflow on. +# That workflow will check the status of the translations and if complete create a pull +# request with the translations off of the branch. + +permissions: + contents: write + pull-requests: write + +# TODO: Add a schedule to run this workflow twice a day(?) once the testing is complete +on: workflow_dispatch + +jobs: + run-check-and-download-for-branch: + needs: get-branches + if: ${{ needs.get-branches.outputs.matrix != '[]' && needs.get-branches.outputs.matrix != '' }} + strategy: + fail-fast: false + matrix: + branch: ${{fromJson(needs.get-branches.outputs.matrix)}} + uses: ./.github/workflows/crowdin-reusable-translation-download.yml + with: + branch: ${{ matrix.branch }} + secrets: + gh_token: ${{ secrets.GITHUB_TOKEN }} + crowdin_personal_token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + crowdin_project_id: ${{ secrets.CROWDIN_PROJECT_ID }} + + get-branches: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix-outputs.outputs.matrix }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get Branches with Label + id: get-branches + run: | + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" + + LABEL="ready-for-translation" + API_URL="https://api.github.com/repos/Metamask/crowdin-sandbox/pulls?state=open&per_page=100" + + # Fetch the list of open pull requests with the specified label using curl + PRS=$(curl -sS --header "Authorization: Bearer $GITHUB_TOKEN" "$API_URL") + + BRANCHES=$(echo "$PRS" | jq -r '[.[] | select(.labels[].name == "'"$LABEL"'") | .head.ref] | @json') + echo "Found branches: $BRANCHES" + echo "branches=$BRANCHES" >> "$GITHUB_OUTPUT" + + - name: Set up matrix + id: matrix-outputs + run: | + # Parse the branches output and create a matrix + BRANCHES="${{ toJson(steps.get-branches.outputs.branches) }}" + echo "Creating matrix from branches..." + MATRIX="${BRANCHES}" + echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT" + + diff --git a/.github/workflows/crowdin-reusable-translation-download.yml b/.github/workflows/crowdin-reusable-translation-download.yml new file mode 100644 index 00000000000..355beef39f7 --- /dev/null +++ b/.github/workflows/crowdin-reusable-translation-download.yml @@ -0,0 +1,64 @@ +name: Crowdin - Check translation progress and download if complete (unless main) +# This is a reusable workflow that is called by crowdin-pull-branch-pr-completed-translations +# across all branches which have a label of "ready-for-translation" aka being translated. +# This workflow will check the translation progress and download the translations if +# they are 100% translated. If the branch that is running this is main it will skip completion +# check and just pull whatever translations are available. + + +permissions: + contents: write + pull-requests: write + +on: + workflow_call: + inputs: + branch: + required: true + type: string + secrets: + gh_token: + required: true + crowdin_project_id: + required: true + crowdin_personal_token: + required: true + +jobs: + crowdin: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.gh_token }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.crowdin_personal_token }} + CROWDIN_PROJECT_ID: ${{ secrets.crowdin_project_id }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + + - name: Check translation progress + # when main just pull whatever you have (aka skip this) - need to test + if: ${{ inputs.branch != 'main' }} + uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d + with: + command: 'status translation' + command_args: '-b ${{ inputs.branch }} --fail-if-incomplete' + + - name: Synchronize with Crowdin + uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d + with: + crowdin_branch_name: ${{ inputs.branch }} + upload_sources: false + upload_translations: false + download_translations: true + skip_untranslated_strings: true + export_only_approved: true + localization_branch_name: l10n_crowdin_translations_${{ inputs.branch }} + + create_pull_request: true + skip_ref_checkout: true + pull_request_title: New Crowdin translations for ${{ inputs.branch }} + pull_request_body: New Crowdin pull request with translations for ${{ inputs.branch }} + pull_request_base_branch_name: ${{ inputs.branch }} diff --git a/.github/workflows/crowdin-upload-both-sources-translations.yml b/.github/workflows/crowdin-upload-both-sources-translations.yml new file mode 100644 index 00000000000..a96cfd0b9d3 --- /dev/null +++ b/.github/workflows/crowdin-upload-both-sources-translations.yml @@ -0,0 +1,31 @@ +name: Crowdin - Upload Both Sources and Translations Crowdin Action +# This action is intended to ensure our main branch on crowdin is in sync with our +# main branch on github and will run on every push to main that has changes to any +# locales files. + +# TODO: Change to trigger on merge to main when locales files are changed (after testing) +# This should replace the current crowdin_action.yml file (after testing) +on: workflow_dispatch + +jobs: + crowdin-upload: + runs-on: ubuntu-latest + steps: + - name: Extract current branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT" + id: extract_current_branch + - name: Checkout + uses: actions/checkout@v3 + + - name: Crowdin push + uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d + with: + crowdin_branch_name: ${{ steps.extract_current_branch.outputs.branch }} + upload_sources: true + upload_translations: true + upload_translations_args: --import-eq-suggestions --verbose + download_translations: false + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} From a9eef466418f2b773bf8dad8c68ae4edfbd2ebf5 Mon Sep 17 00:00:00 2001 From: Jonathan Ferreira <44679989+Jonathansoufer@users.noreply.github.com> Date: Thu, 18 Apr 2024 00:31:34 +0100 Subject: [PATCH 7/7] fix: e2e test permission problem (#9302) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR adds a permission flag on e2e init file so that Notification native dialog don't shows up. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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. --- e2e/init.js | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/init.js b/e2e/init.js index 63763f07630..b191bf8d222 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -7,5 +7,6 @@ import Utilities from './utils/Utilities'; beforeAll(async () => { device.appLaunchArgs.modify({ detoxURLBlacklistRegex: Utilities.BlacklistURLs, + permissions: { notifications: 'YES' }, }); });