From 7ef2730c9a585c4addfeb9d9cb225794578d932e Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 12 Jul 2023 19:50:31 -0230 Subject: [PATCH] Fix preview builds on CI (#19970) Preview builds were setup to install correctly on CircleCI prior to the Yarn v3 upgrade, but that integration broke with that upgrade. The Yarn and CircleCI configuration has been updated to fix this. The `.yarnrc.yaml` file has been updated to configure the GitHub registry but leave it disabled by default. It can be enabled dynamically using an environment variable. This lets us switch between registries without updating the file. The new workflow is documented here: https://github.com/MetaMask/core/pull/1481 --- .circleci/config.yml | 10 ++++------ .yarnrc.yml | 9 +++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a8522d1ad..e8b002718 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -353,17 +353,15 @@ jobs: echo "Not a PR; skipping" fi - run: - name: Setup registry config for using package previews on draft PRs + name: Install dependencies command: | if [[ $IS_DRAFT == 'true' ]] then - printf '%s\n\n%s' '@metamask:registry=https://npm.pkg.github.com' "//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGE_READ_TOKEN}" > .npmrc + # Use GitHub registry on draft PRs, allowing the use of preview builds + METAMASK_NPM_REGISTRY=https://npm.pkg.github.com yarn --immutable else - echo "Not draft; skipping GitHub registry setup" + yarn --immutable fi - - run: - name: Install deps - command: yarn --immutable - save_cache: key: dependency-cache-v1-{{ checksum "yarn.lock" }} paths: diff --git a/.yarnrc.yml b/.yarnrc.yml index 5d351f8e2..03fa25aa0 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -8,6 +8,15 @@ logFilters: nodeLinker: node-modules +npmRegistries: + "https://npm.pkg.github.com": + npmAlwaysAuth: true + npmAuthToken: "${GITHUB_PACKAGE_READ_TOKEN-}" + +npmScopes: + metamask: + npmRegistryServer: "${METAMASK_NPM_REGISTRY:-https://registry.yarnpkg.com}" + plugins: - path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"