Skip to content

feat: Add UI components for Ledger status screens #26751

feat: Add UI components for Ledger status screens

feat: Add UI components for Ledger status screens #26751

name: Update E2E fixtures
on:
issue_comment:
types:
- created
jobs:
is-cross-repo-pr:
name: Determine whether this PR is cross-repo
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot update-e2e-fixture') }}
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
IS_CROSS_REPO_PR: ${{ steps.is-cross-repo.outputs.IS_CROSS_REPO_PR }}
steps:
- uses: actions/checkout@v6
- name: Determine whether this PR is cross-repo
id: is-cross-repo
run: echo "IS_CROSS_REPO_PR=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
react-to-comment:
name: React to the comment
runs-on: ubuntu-latest
timeout-minutes: 30
needs: is-cross-repo-pr
if: ${{ needs.is-cross-repo-pr.outputs.IS_CROSS_REPO_PR == 'false' }}
environment: default-branch
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: React to the comment
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${REPO}/issues/comments/${COMMENT_ID}/reactions" \
-f content='+1'
env:
COMMENT_ID: ${{ github.event.comment.id }}
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
REPO: ${{ github.repository }}
prepare:
name: Prepare dependencies
runs-on: ubuntu-latest
timeout-minutes: 30
needs: is-cross-repo-pr
if: ${{ needs.is-cross-repo-pr.outputs.IS_CROSS_REPO_PR == 'false' }}
environment: default-branch
outputs:
COMMIT_SHA: ${{ steps.commit-sha.outputs.COMMIT_SHA }}
BRANCH: ${{ steps.branch.outputs.BRANCH }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v3
with:
is-high-risk-environment: false
skip-allow-scripts: true
- name: Get commit SHA
id: commit-sha
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Get branch name
id: branch
run: echo "BRANCH=$(gh pr view "${PR_NUMBER}" --json headRefName --jq '.headRefName')" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Find and download dist artifact
run: |
COMMIT_SHA_FULL=$(git rev-parse HEAD)
# Get the most recent run for the Main workflow on this branch
RUN_INFO=$(gh run list --workflow "Main" --branch "${BRANCH}" --json databaseId,status,conclusion,headSha --limit 1 --jq 'first')
if [ -z "$RUN_INFO" ] || [ "$RUN_INFO" = "null" ]; then
echo "::error::No 'Main' workflow run found for branch ${BRANCH}"
exit 1
fi
RUN_ID=$(echo "$RUN_INFO" | jq -r '.databaseId')
RUN_STATUS=$(echo "$RUN_INFO" | jq -r '.status')
RUN_CONCLUSION=$(echo "$RUN_INFO" | jq -r '.conclusion')
RUN_HEAD_SHA=$(echo "$RUN_INFO" | jq -r '.headSha')
echo "Found run ${RUN_ID} with status: ${RUN_STATUS}, conclusion: ${RUN_CONCLUSION}, headSha: ${RUN_HEAD_SHA}"
echo "Current PR HEAD commit: ${COMMIT_SHA_FULL}"
if [ "${RUN_HEAD_SHA}" != "${COMMIT_SHA_FULL}" ]; then
echo "::error::The latest 'Main' workflow run (commit ${RUN_HEAD_SHA}) does not match the current PR HEAD (commit ${COMMIT_SHA_FULL}). Please ensure the Main workflow has run for the latest commit on this branch."
exit 1
fi
if [ "${RUN_STATUS}" != "completed" ]; then
echo "::notice::The latest 'Main' workflow run is still in progress (status: ${RUN_STATUS}). Attempting to download the dist artifact anyway."
elif [ "${RUN_CONCLUSION}" != "success" ]; then
echo "::warning::The latest 'Main' workflow run concluded with '${RUN_CONCLUSION}'. The build artifact may still be available, proceeding with download attempt."
fi
echo "Attempting to download dist artifact..."
if ! gh run download "${RUN_ID}" -n build-dist-webpack -D build-dist-webpack; then
echo "::error::Failed to download the 'build-dist-webpack' artifact. The build job may not have completed yet, or may have failed. Please ensure the build-dist-webpack job has completed successfully."
exit 1
fi
echo "Successfully downloaded dist artifact."
env:
BRANCH: ${{ steps.branch.outputs.BRANCH }}
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
- name: Cache dist artifact
uses: actions/cache/save@v5
with:
path: build-dist-webpack
key: dist-${{ steps.commit-sha.outputs.COMMIT_SHA }}
update-fixtures:
name: Update E2E fixtures
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- prepare
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.BRANCH }}
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v3
with:
is-high-risk-environment: false
skip-allow-scripts: true
- name: Restore .metamask folder
id: restore-metamask
uses: actions/cache/restore@v5
with:
path: .metamask
key: .metamask-${{ hashFiles('yarn.lock') }}
fail-on-cache-miss: false
- name: Install anvil if cache missed
if: ${{ steps.restore-metamask.outputs.cache-hit != 'true' }}
run: yarn mm-foundryup
- name: Restore dist artifact
uses: actions/cache/restore@v5
with:
path: build-dist-webpack
key: dist-${{ needs.prepare.outputs.COMMIT_SHA }}
fail-on-cache-miss: true
- name: Prepare dist
run: |
rm -rf dist builds
cp -R build-dist-webpack/dist ./dist
cp -R build-dist-webpack/builds ./builds
- name: Update E2E fixtures
run: |
yarn test:e2e:single test/e2e/dist/wallet-fixture-export.spec.ts --browser chrome --retries 1
yarn lint:json:fix
yarn lint:format:fix
env:
SELENIUM_HEADLESS: true
- name: Upload test artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: test-artifacts-fixture-update
path: |
./test-artifacts
./test/test-results/e2e
- name: Cache updated fixture
uses: actions/cache/save@v5
with:
path: |
test/e2e/fixtures/onboarding-fixture.json
test/e2e/fixtures/default-fixture.json
key: fixtures-${{ needs.prepare.outputs.COMMIT_SHA }}
commit-updated-fixtures:
name: Commit the updated E2E fixtures
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- prepare
- is-cross-repo-pr
- update-fixtures
if: ${{ needs.is-cross-repo-pr.outputs.IS_CROSS_REPO_PR == 'false' }}
environment: default-branch
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Restore updated fixtures
uses: actions/cache/restore@v5
with:
path: |
test/e2e/fixtures/onboarding-fixture.json
test/e2e/fixtures/default-fixture.json
key: fixtures-${{ needs.prepare.outputs.COMMIT_SHA }}
fail-on-cache-miss: true
- name: Check whether there are fixture changes
id: fixture-changes
run: |
if git diff --exit-code test/e2e/fixtures/onboarding-fixture.json test/e2e/fixtures/default-fixture.json
then
echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT"
else
echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit the updated fixtures
if: steps.fixture-changes.outputs.HAS_CHANGES == 'true'
run: |
git config --global user.name 'MetaMask Bot'
git config --global user.email 'metamaskbot@users.noreply.github.com'
git commit -am "Update E2E fixtures"
git push
- name: Post comment
run: |
if [[ $HAS_CHANGES == 'true' ]]
then
gh pr comment "${PR_NUMBER}" --body 'E2E fixtures updated.'
else
gh pr comment "${PR_NUMBER}" --body 'No E2E fixture changes detected.'
fi
env:
HAS_CHANGES: ${{ steps.fixture-changes.outputs.HAS_CHANGES }}
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
check-status:
name: Check whether the fixtures update succeeded
runs-on: ubuntu-latest
timeout-minutes: 30
if: ${{ !cancelled() && needs.is-cross-repo-pr.outputs.IS_CROSS_REPO_PR == 'false' }}
needs:
- is-cross-repo-pr
- commit-updated-fixtures
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: |
if [[ "${{ needs.commit-updated-fixtures.result }}" == "success" ]]; then
echo "PASSED=true" >> "$GITHUB_OUTPUT"
else
echo "PASSED=false" >> "$GITHUB_OUTPUT"
fi
failure-comment:
name: Comment about the fixtures update failure
if: ${{ !cancelled() && needs.is-cross-repo-pr.outputs.IS_CROSS_REPO_PR == 'false' }}
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- is-cross-repo-pr
- check-status
environment: default-branch
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
- name: Post comment if the update failed
run: |
passed="${{ needs.check-status.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
gh pr comment "${PR_NUMBER}" --body "E2E fixtures update failed. You can [review the logs or retry the fixture update here](${ACTION_RUN_URL})"
fi
env:
GITHUB_TOKEN: ${{ secrets.FIXTURE_UPDATE_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
ACTION_RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'