Skip to content

chore: split eslint ignore react-compiler directives #34546

chore: split eslint ignore react-compiler directives

chore: split eslint ignore react-compiler directives #34546

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
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get token
id: token
uses: MetaMask/github-tools/.github/actions/get-token@v1
with:
token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }}
permissions: |
actions: read
contents: write
pull_requests: write
- 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: ${{ steps.token.outputs.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
permissions:
id-token: write
contents: read
outputs:
COMMIT_SHA: ${{ steps.commit-sha.outputs.COMMIT_SHA }}
BRANCH: ${{ steps.branch.outputs.BRANCH }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Get token
id: token
uses: MetaMask/github-tools/.github/actions/get-token@v1
with:
token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }}
permissions: |
actions: read
statuses: read
contents: write
pull_requests: write
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ steps.token.outputs.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: ${{ steps.token.outputs.token }}
PR_NUMBER: ${{ github.event.issue.number }}
# The build-reuse feature skips the build jobs on a PR's Main run when its
# build-source hash matches a prior run (commonly a `main` run); in that
# case the artifact lives on the donor run, not the PR's own run.
# get-requirements.yml publishes the canonical run that holds the builds
# (this run for fresh builds, the donor run when reused) as a
# `builds-from-run` commit status on the PR head, so we just read it.
- name: Find dist artifact run
id: find-dist
uses: actions/github-script@v8
with:
github-token: ${{ steps.token.outputs.token }}
script: |
const { owner, repo } = context.repo;
const { stdout: headOut } = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], { silent: true });
const headSha = headOut.trim();
// getCombinedStatusForRef de-duplicates to the most recent status
// per context, so a single page is sufficient.
const { data: { statuses } } = await github.rest.repos.getCombinedStatusForRef({
owner, repo, ref: headSha, per_page: 100,
});
const buildsFromRun = statuses.find((s) => s.context === 'builds-from-run')?.description;
if (!buildsFromRun) {
core.setFailed(`No 'builds-from-run' commit status found on ${headSha}. This commit's Main run may predate the build-reuse pointer, or its best-effort status post failed. Re-run the Main workflow on this branch, then '@metamaskbot update-e2e-fixture'.`);
return;
}
core.info(`-> builds-from-run: ${buildsFromRun}`);
core.setOutput('run-id', buildsFromRun);
- name: Download dist artifact
run: |
echo "Attempting to download dist artifact from run ${RUN_ID}..."
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 from run ${RUN_ID}. 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:
RUN_ID: ${{ steps.find-dist.outputs.run-id }}
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
- name: Upload dist artifact
uses: actions/upload-artifact@v6
with:
name: dist-${{ steps.commit-sha.outputs.COMMIT_SHA }}
path: build-dist-webpack
if-no-files-found: error
# Allow workflow re-runs to replace the artifact from a prior attempt.
overwrite: true
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: Install anvil
run: yarn mm-foundryup
- name: Download dist artifact
uses: actions/download-artifact@v7
with:
name: dist-${{ needs.prepare.outputs.COMMIT_SHA }}
path: build-dist-webpack
- 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: Upload updated fixtures
uses: actions/upload-artifact@v6
with:
name: fixtures-${{ needs.prepare.outputs.COMMIT_SHA }}
path: |
test/e2e/fixtures/onboarding-fixture.json
test/e2e/fixtures/default-fixture.json
if-no-files-found: error
# Allow workflow re-runs to replace the artifact from a prior attempt.
overwrite: true
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
permissions:
id-token: write
contents: read
steps:
- name: Get token
id: token
uses: MetaMask/github-tools/.github/actions/get-token@v1
with:
token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }}
permissions: |
actions: read
contents: write
pull_requests: write
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ steps.token.outputs.token }}
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Download updated fixtures
uses: actions/download-artifact@v7
with:
name: fixtures-${{ needs.prepare.outputs.COMMIT_SHA }}
path: test/e2e/fixtures
- 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: ${{ steps.token.outputs.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
permissions:
id-token: write
contents: read
steps:
- name: Get token
id: token
uses: MetaMask/github-tools/.github/actions/get-token@v1
with:
token-exchange-url: ${{ vars.TOKEN_EXCHANGE_URL }}
permissions: |
actions: read
contents: write
pull_requests: write
- uses: actions/checkout@v6
with:
token: ${{ steps.token.outputs.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: ${{ steps.token.outputs.token }}
PR_NUMBER: ${{ github.event.issue.number }}
ACTION_RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'