-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Migrate metamaskbot PR comment #29373
Conversation
051cd52
to
3cbc139
Compare
Builds ready [6a4182e]
Bundle size diffs
|
Builds ready [dc9fd81]
Page Load Metrics (1422 ± 42 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [fb737b2]
Page Load Metrics (1766 ± 68 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [44f95d4]
Page Load Metrics (1610 ± 85 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
54e05e1
to
0bce5e0
Compare
Builds ready [0bce5e0]
Page Load Metrics (1771 ± 75 ms)
Bundle size diffs
|
0bce5e0
to
e10477e
Compare
@@ -9,7 +9,7 @@ async function getHighlights({ artifactBase }) { | |||
// here we assume the PR base branch ("target") is `main` in lieu of doing | |||
// a query against the github api which requires an access token | |||
// see https://discuss.circleci.com/t/how-to-retrieve-a-pull-requests-base-branch-name-github/36911 | |||
const changedFiles = await getChangedFiles({ target: 'main' }); | |||
const changedFiles = await getChangedFiles({ target: 'origin/main' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now running on GitHub Actions rather than CircleCI, which doesn't checkout the main branch locally. origin/main
works across both CI systems.
BRANCH: ${{ github.head_ref }} | ||
HEAD_COMMIT_HASH: ${{ github.event.pull_request.head.sha }} | ||
run: | | ||
pipeline_id=$(curl --silent "https://circleci.com/api/v2/project/gh/$OWNER/$REPOSITORY/pipeline?branch=$BRANCH" | jq -r ".items | map(select(.vcs.revision == \"${HEAD_COMMIT_HASH}\" )) | first | .id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same strategy as used elsewhere for getting the CircleCI workflow corresponding to the current branch+commit:
pipeline_id=$(curl --silent "https://circleci.com/api/v2/project/gh/$OWNER/$REPOSITORY/pipeline?branch=$BRANCH" | jq -r ".items | map(select(.vcs.revision == \"${HEAD_COMMIT_HASH}\" )) | first | .id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could probably refactor this later into something reusable, to avoid this duplication. But it is a temporary workaround anyway - since we intend to migrate away from CircleCI.
|
||
echo "Getting artifacts from pipeline '${pipeline_id}', workflow '${workflow_id}', build number '${build_num}', job ID '${job_id}'" | ||
|
||
- name: Get CircleCI job artifacts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the artifacts referenced in the metamaskbot
comment are referenced by CircleCI artifact link. We didn't need to download those.
These three are pulled from the filesystem by the script though, so we needed to download these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we could also fetch it in the .js script and keep it in memory instead of having it on the filesystem, but in my original implementation I did not want to make any "breaking changes" to the script.
PR_COMMENT_TOKEN: ${{ secrets.PR_COMMENT_TOKEN }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
HEAD_COMMIT_HASH: ${{ github.event.pull_request.head.sha }} | ||
MERGE_BASE_COMMIT_HASH: ${{ steps.get-merge-base.outputs.MERGE_BASE }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to the PARENT_COMMIT
used previously, they both use git merge-base
to find the base commit between the current branch and the target branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a much better name, PARENT_COMMIT
had me confused before.
const sourceMapRoot = '/build-artifacts/source-map-explorer/'; | ||
const bundleFiles = await glob(`.${sourceMapRoot}*${fileType}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strategy used to collect these links was changed. Previously we used glob
to look for these files on the filesystem. It would have been tedious to migrate each file one-by-one between CI systems, so instead we're hard-coding the 5 bundle types and testing each bundle index until we get a 404.
This ensures the links are constructed correctly even as the number of bundles fluctuates (which is common), and it doesn't require transferring the files between CI systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how many requests are we making here? It seems like a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a lot. A bit regrettable. But at least we can replace this soon, and in the overall comment building this is very fast in comparison to the other steps.
Builds ready [2727f61]
Page Load Metrics (1783 ± 125 ms)
Bundle size diffs
|
*/ | ||
async function artifactExists(url) { | ||
// Using a regular GET request here rather than HEAD because for some reason CircleCI always | ||
// returns 404 for HEAD requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can feel the frustration you must have felt when you discovered this fact :DDD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on this one! Seems good overall
2727f61
to
df4b0c5
Compare
Builds ready [df4b0c5]
Page Load Metrics (1966 ± 102 ms)
|
Strange. Had a LavaMoat policy validation failure (unexpected end of JSON input), but it passed upon retry. No policy changes here though, or even build system changes. Edit: We discovered the likely cause, tracked here: #29482 |
Discovered another broken link, details here: #29485 This was broken in another PR, and I will fix it separately from this as well. Just noting for anyone testing this. I'll update the manual testing instructions as well. |
@@ -76,6 +76,15 @@ jobs: | |||
name: Wait for CircleCI workflow status | |||
uses: ./.github/workflows/wait-for-circleci-workflow-status.yml | |||
|
|||
publish-prerelease: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally not required for all-jobs-completed
because this is informational only, not a quality gate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked all the links and the ones I found that were not working were covered in other issues for that reason I am fine to approve this.
Description
Migrate the
metamaskbot
PR comment from CircleCI to GitHub Actions. CircleCI is still used for artifact storage for linked artifacts.Related issues
Relates to #28572
These changes were extracted from #29256
Manual testing steps
metamaskbot
comment work correctly, except those that are already broken. Links already broken onmain
include:metamaskbot
comment test build links #29403 ):Screenshots/Recordings
N/A
Pre-merge author checklist
Pre-merge reviewer checklist