mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
perf(CI): Shallow git clone that works with PRs from forks (#19757)
* perf(CI): Shallow git clone that works with PRs from forks Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> * added CircleCI link and removed rc_or_master_branch_only --------- Co-authored-by: Brad Decker <bhdecker84@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
This commit is contained in:
parent
b13b9438b7
commit
b36487ab52
@ -30,6 +30,45 @@ rc_branch_only: &rc_branch_only
|
||||
only:
|
||||
- /^Version-v(\d+)[.](\d+)[.](\d+)/
|
||||
|
||||
aliases:
|
||||
# Shallow Git Clone
|
||||
- &shallow-git-clone
|
||||
name: Shallow Git Clone
|
||||
command: |
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
# This Shallow Git Clone code is adapted from what the standard CircleCI `checkout` command does for the case of an external PR (link to example below):
|
||||
# https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/49817/workflows/dc195ea6-ac06-4de1-9edf-4c949427b5fb/jobs/1430976/parallel-runs/0/steps/0-101
|
||||
### git clone --no-checkout "$CIRCLE_REPOSITORY_URL" .
|
||||
### git fetch --force origin +refs/pull/18748/head:refs/remotes/origin/pull/18748
|
||||
### git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1"
|
||||
### git --no-pager log --no-color -n 1 --format='HEAD is now at %h %s'
|
||||
|
||||
# Set up SSH access
|
||||
# This SSH key is the current github.com SSH key as of June 2023, but it will need to be changed whenever github changes their key (probably every few years)
|
||||
GITHUB_SSH_KEY="AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl"
|
||||
mkdir -p ~/.ssh
|
||||
echo github.com ssh-ed25519 $GITHUB_SSH_KEY >> ~/.ssh/known_hosts
|
||||
|
||||
# Take a different clone path depending on if it's a tag, a PR from an external repo, or the normal case
|
||||
if [ -n "${CIRCLE_TAG-}" ]; then
|
||||
# tag
|
||||
git clone --depth 1 --no-checkout "$CIRCLE_REPOSITORY_URL" .
|
||||
git fetch --depth 1 --force origin "+refs/tags/${CIRCLE_TAG}:refs/tags/${CIRCLE_TAG}"
|
||||
git checkout --force -q "$CIRCLE_TAG" "$CIRCLE_SHA1"
|
||||
elif [[ "$CIRCLE_BRANCH" =~ ^pull\/* ]]; then
|
||||
# pull request
|
||||
git clone --depth 1 --no-checkout "$CIRCLE_REPOSITORY_URL" .
|
||||
git fetch --depth 1 --force origin "${CIRCLE_BRANCH}/head:remotes/origin/${CIRCLE_BRANCH}"
|
||||
git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1"
|
||||
else
|
||||
# normal case
|
||||
git clone --depth 1 "$CIRCLE_REPOSITORY_URL" --branch "$CIRCLE_BRANCH" .
|
||||
fi
|
||||
|
||||
workflows:
|
||||
test_and_release:
|
||||
jobs:
|
||||
@ -241,7 +280,7 @@ jobs:
|
||||
trigger-beta-build:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- when:
|
||||
@ -270,7 +309,7 @@ jobs:
|
||||
create_release_pull_request:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -289,7 +328,7 @@ jobs:
|
||||
prep-deps:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- restore_cache:
|
||||
keys:
|
||||
# First try to get the specific cache for the checksum of the yarn.lock file.
|
||||
@ -339,7 +378,7 @@ jobs:
|
||||
validate-lavamoat-allow-scripts:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -352,7 +391,7 @@ jobs:
|
||||
validate-lavamoat-policy-build:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -368,7 +407,7 @@ jobs:
|
||||
build-type:
|
||||
type: string
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -381,7 +420,7 @@ jobs:
|
||||
prep-build:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- when:
|
||||
@ -415,7 +454,7 @@ jobs:
|
||||
prep-build-desktop:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -439,7 +478,7 @@ jobs:
|
||||
prep-build-flask:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- when:
|
||||
@ -479,7 +518,7 @@ jobs:
|
||||
prep-build-test-flask:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -500,7 +539,7 @@ jobs:
|
||||
prep-build-test-mv3:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -521,7 +560,7 @@ jobs:
|
||||
prep-build-test:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -542,7 +581,7 @@ jobs:
|
||||
prep-build-storybook:
|
||||
executor: node-browsers-large
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -556,7 +595,7 @@ jobs:
|
||||
prep-build-ts-migration-dashboard:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -570,7 +609,7 @@ jobs:
|
||||
test-yarn-dedupe:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -580,7 +619,7 @@ jobs:
|
||||
test-lint:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -593,7 +632,7 @@ jobs:
|
||||
test-storybook:
|
||||
executor: node-browsers-large
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -615,7 +654,7 @@ jobs:
|
||||
test-lint-lockfile:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -625,7 +664,7 @@ jobs:
|
||||
test-lint-changelog:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- when:
|
||||
@ -651,7 +690,7 @@ jobs:
|
||||
test-deps-audit:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -661,7 +700,7 @@ jobs:
|
||||
test-deps-depcheck:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -672,7 +711,7 @@ jobs:
|
||||
executor: node-browsers
|
||||
parallelism: 8
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Re-Install Chrome
|
||||
command: ./.circleci/scripts/chrome-install.sh
|
||||
@ -709,7 +748,7 @@ jobs:
|
||||
executor: node-browsers
|
||||
parallelism: 8
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Re-Install Chrome
|
||||
command: ./.circleci/scripts/chrome-install.sh
|
||||
@ -737,7 +776,7 @@ jobs:
|
||||
executor: node-browsers
|
||||
parallelism: 4
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Install Firefox
|
||||
command: ./.circleci/scripts/firefox-install.sh
|
||||
@ -774,7 +813,7 @@ jobs:
|
||||
executor: node-browsers
|
||||
parallelism: 4
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Re-Install Chrome
|
||||
command: ./.circleci/scripts/chrome-install.sh
|
||||
@ -811,7 +850,7 @@ jobs:
|
||||
executor: node-browsers-medium-plus
|
||||
parallelism: 8
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Install Firefox
|
||||
command: ./.circleci/scripts/firefox-install.sh
|
||||
@ -847,7 +886,7 @@ jobs:
|
||||
benchmark:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Re-Install Chrome
|
||||
command: ./.circleci/scripts/chrome-install.sh
|
||||
@ -873,7 +912,7 @@ jobs:
|
||||
user-actions-benchmark:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Re-Install Chrome
|
||||
command: ./.circleci/scripts/chrome-install.sh
|
||||
@ -899,7 +938,7 @@ jobs:
|
||||
stats-module-load-init:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- run:
|
||||
name: Re-Install Chrome
|
||||
command: ./.circleci/scripts/chrome-install.sh
|
||||
@ -996,7 +1035,7 @@ jobs:
|
||||
job-publish-release:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1016,7 +1055,7 @@ jobs:
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- '3d:49:29:f4:b2:e8:ea:af:d1:32:eb:2a:fc:15:85:d8'
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1031,7 +1070,7 @@ jobs:
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- '8b:21:e3:20:7c:c9:db:82:74:2d:86:d6:11:a7:2f:49'
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1045,7 +1084,7 @@ jobs:
|
||||
test-unit-mocha:
|
||||
executor: node-browsers-medium-plus
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1060,7 +1099,7 @@ jobs:
|
||||
test-unit-jest-development:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1077,7 +1116,7 @@ jobs:
|
||||
executor: node-browsers-medium-plus
|
||||
parallelism: 12
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1093,7 +1132,7 @@ jobs:
|
||||
upload-and-validate-coverage:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- codecov/upload
|
||||
@ -1108,7 +1147,7 @@ jobs:
|
||||
test-unit-global:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1118,7 +1157,7 @@ jobs:
|
||||
validate-source-maps:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1128,7 +1167,7 @@ jobs:
|
||||
validate-source-maps-beta:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1139,7 +1178,7 @@ jobs:
|
||||
validate-source-maps-desktop:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1155,7 +1194,7 @@ jobs:
|
||||
validate-source-maps-flask:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1171,7 +1210,7 @@ jobs:
|
||||
test-mozilla-lint:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1181,7 +1220,7 @@ jobs:
|
||||
test-mozilla-lint-desktop:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
@ -1197,7 +1236,7 @@ jobs:
|
||||
test-mozilla-lint-flask:
|
||||
executor: node-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- run: *shallow-git-clone
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
|
Loading…
Reference in New Issue
Block a user