-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into bowen/interactiveui
- Loading branch information
Showing
918 changed files
with
67,113 additions
and
33,594 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ git clone [email protected]:MetaMask/extension_bundlesize_stats.git temp | |
|
||
{ | ||
echo " '${CIRCLE_SHA1}': "; | ||
cat test-artifacts/chrome/mv3/bundle_size_stats.json; | ||
cat test-artifacts/chrome/bundle_size_stats.json; | ||
echo ", "; | ||
} >> temp/stats/bundle_size_data.temp.js | ||
|
||
|
@@ -57,14 +57,14 @@ if [ -f temp/stats/bundle_size_data.json ]; then | |
{ | ||
echo "},"; | ||
echo "\"$CIRCLE_SHA1\":"; | ||
cat test-artifacts/chrome/mv3/bundle_size_stats.json; | ||
cat test-artifacts/chrome/bundle_size_stats.json; | ||
echo "}"; | ||
} >> bundle_size_stats.temp.json | ||
else | ||
{ | ||
echo "{"; | ||
echo "\"$CIRCLE_SHA1\":"; | ||
cat test-artifacts/chrome/mv3/bundle_size_stats.json; | ||
cat test-artifacts/chrome/bundle_size_stats.json; | ||
echo "}"; | ||
} > bundle_size_stats.temp.json | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import * as core from '@actions/core'; | ||
import { context, getOctokit } from '@actions/github'; | ||
import { GitHub } from '@actions/github/lib/utils'; | ||
|
||
import { retrieveLabel } from './shared/label'; | ||
import { Labelable, addLabelByIdToLabelable } from './shared/labelable'; | ||
import { retrievePullRequest } from './shared/pull-request'; | ||
|
||
main().catch((error: Error): void => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
|
||
async function main(): Promise<void> { | ||
// "GITHUB_TOKEN" is an automatically generated, repository-specific access token provided by GitHub Actions. | ||
// We can't use "GITHUB_TOKEN" here, as its permissions are scoped to the repository where the action is running. | ||
// "GITHUB_TOKEN" does not have access to other repositories, even when they belong to the same organization. | ||
// As we want to get files which are not necessarily located in the same repository, | ||
// we need to create our own "RELEASE_LABEL_TOKEN" with "repo" permissions. | ||
// Such a token allows to access other repositories of the MetaMask organisation. | ||
const personalAccessToken = process.env.RELEASE_LABEL_TOKEN; | ||
if (!personalAccessToken) { | ||
core.setFailed('RELEASE_LABEL_TOKEN not found'); | ||
process.exit(1); | ||
} | ||
|
||
// Initialise octokit, required to call Github GraphQL API | ||
const octokit: InstanceType<typeof GitHub> = getOctokit(personalAccessToken, { | ||
previews: ['bane'], // The "bane" preview is required for adding, updating, creating and deleting labels. | ||
}); | ||
|
||
// Retrieve pull request info from context | ||
const pullRequestRepoOwner = context.repo.owner; | ||
const pullRequestRepoName = context.repo.repo; | ||
const pullRequestNumber = context.payload.pull_request?.number; | ||
if (!pullRequestNumber) { | ||
core.setFailed('Pull request number not found'); | ||
process.exit(1); | ||
} | ||
|
||
// Retrieve pull request | ||
const pullRequest: Labelable = await retrievePullRequest( | ||
octokit, | ||
pullRequestRepoOwner, | ||
pullRequestRepoName, | ||
pullRequestNumber, | ||
); | ||
|
||
// Get the team label id based on the author of the pull request | ||
const teamLabelId = await getTeamLabelIdByAuthor( | ||
octokit, | ||
pullRequestRepoOwner, | ||
pullRequestRepoName, | ||
pullRequest.author, | ||
); | ||
|
||
// Add the team label by id to the pull request | ||
await addLabelByIdToLabelable(octokit, pullRequest, teamLabelId); | ||
} | ||
|
||
// This helper function gets the team label id based on the author of the pull request | ||
const getTeamLabelIdByAuthor = async ( | ||
octokit: InstanceType<typeof GitHub>, | ||
repoOwner: string, | ||
repoName: string, | ||
author: string, | ||
): Promise<string> => { | ||
// Retrieve the teams.json file from the repository | ||
const { data } = (await octokit.request( | ||
'GET /repos/{owner}/{repo}/contents/{path}', | ||
{ owner: repoOwner, repo: 'MetaMask-planning', path: 'teams.json' }, | ||
)) as { data: { content: string } }; | ||
|
||
// Parse the teams.json file content to json from base64 | ||
const teamMembers: Record<string, string> = JSON.parse(atob(data.content)); | ||
|
||
// Get the label name based on the author | ||
const labelName = teamMembers[author]; | ||
|
||
if (!labelName) { | ||
core.setFailed(`Team label not found for author: ${author}`); | ||
process.exit(1); | ||
} | ||
|
||
// Retrieve the label id based on the label name | ||
const labelId = await retrieveLabel(octokit, repoOwner, repoName, labelName); | ||
|
||
return labelId; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Add team label to PR when it is opened | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
|
||
jobs: | ||
add-team-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- run: corepack enable | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # This is needed to checkout all branches | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: yarn | ||
|
||
- name: Install dependencies | ||
run: yarn --immutable | ||
|
||
- name: Add team label to PR | ||
id: add-team-label-to-pr | ||
env: | ||
RELEASE_LABEL_TOKEN: ${{ secrets.RELEASE_LABEL_TOKEN }} | ||
run: yarn run add-team-label-to-pr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Check Attributions | ||
|
||
on: | ||
push: | ||
branches: Version-v* | ||
pull_request: | ||
branches: Version-v* | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
|
||
jobs: | ||
check-attributions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
- name: Install dependencies from cache | ||
run: yarn --immutable | ||
- name: Check attributions changes | ||
run: yarn attributions:check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.