Skip to content

Commit

Permalink
chore: yarn modern (3.5.0) migration feature branch (#12579)
Browse files Browse the repository at this point in the history
* chore: migrate to yarn 2 (#12501)
  • Loading branch information
pavellazar authored Jun 1, 2023
1 parent 5f291cf commit 9621788
Show file tree
Hide file tree
Showing 219 changed files with 42,132 additions and 178,268 deletions.
78 changes: 51 additions & 27 deletions .circleci/config.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ jobs:
executor: l_xlarge
steps:
- checkout
- run: yarn config set registry https://registry.npmjs.org
- run: yarn config set script-shell $(which bash)
- run: yarn run production-build
- run: yarn --immutable
- run: yarn production-build
- run:
name: Build tests
command: yarn build-tests
Expand All @@ -133,9 +132,7 @@ jobs:
executor: l_xlarge
steps:
- checkout
- run: yarn config set registry https://registry.npmjs.org
- run: yarn config set script-shell $(which bash)
- run: yarn install --network-concurrency 1
- run: yarn install --immutable
- run:
name: Build tests
command: yarn build-tests
Expand All @@ -152,8 +149,9 @@ jobs:
steps:
- install_node_windows
- checkout
- run: yarn config set script-shell $(which bash)
- run: yarn run production-build
- run: cd scripts && yarn && yarn ts-node remove-pkg-fetch-checksum.ts && cd -
- run: yarn --immutable
- run: yarn production-build
- run:
name: Build tests
command: yarn build-tests
Expand Down Expand Up @@ -243,7 +241,6 @@ jobs:
source .circleci/local_publish_helpers.sh
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
changeNpmGlobalPath
checkPackageVersionsInLocalNpmRegistry
mock_e2e_tests:
Expand Down Expand Up @@ -342,7 +339,6 @@ jobs:
source .circleci/local_publish_helpers.sh
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
changeNpmGlobalPath
generatePkgCli linux
unsetNpmRegistryUrl
- save_cache:
Expand All @@ -367,7 +363,6 @@ jobs:
source .circleci/local_publish_helpers.sh
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
changeNpmGlobalPath
generatePkgCli macos
unsetNpmRegistryUrl
- save_cache:
Expand All @@ -392,7 +387,6 @@ jobs:
source .circleci/local_publish_helpers.sh
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
changeNpmGlobalPath
generatePkgCli win
unsetNpmRegistryUrl
- save_cache:
Expand Down Expand Up @@ -560,7 +554,37 @@ jobs:
cd packages/amplify-migration-tests
unset IS_AMPLIFY_CI
echo $IS_AMPLIFY_CI
retry yarn run migration_v8.2.0 --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
retry yarn migration_v8.2.0 --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
no_output_timeout: 65m
- run: *scan_e2e_test_artifacts
- store_test_results:
path: ~/repo/packages/amplify-migration-tests/
- store_artifacts:
path: ~/repo/packages/amplify-migration-tests/amplify-migration-reports
working_directory: ~/repo

amplify_migration_tests_v6:
parameters:
os:
type: executor
default: l_large
executor: << parameters.os >>
environment:
AMPLIFY_PATH: /home/circleci/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify
steps:
- restore_cache:
key: amplify-cli-repo-{{ .Branch }}-{{ .Revision }}
- restore_cache:
key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- restore_cache:
key: amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}
- run:
name: Run tests migrating from CLI v6.1.0
command: |
source .circleci/local_publish_helpers.sh
changeNpmGlobalPath
cd packages/amplify-migration-tests
retry yarn run migration_v6.1.0 --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
no_output_timeout: 65m
- run: *scan_e2e_test_artifacts
- store_test_results:
Expand Down Expand Up @@ -592,7 +616,7 @@ jobs:
cd packages/amplify-migration-tests
unset IS_AMPLIFY_CI
echo $IS_AMPLIFY_CI
retry yarn run migration_v10.5.1 --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
retry yarn migration_v10.5.1 --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
no_output_timeout: 65m
- run: *scan_e2e_test_artifacts
- store_test_results:
Expand Down Expand Up @@ -622,7 +646,7 @@ jobs:
source .circleci/local_publish_helpers.sh
changeNpmGlobalPath
cd packages/amplify-migration-tests
retry yarn run migration_v4.28.2_nonmultienv_layers --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
retry yarn migration_v4.28.2_nonmultienv_layers --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
no_output_timeout: 90m
- run: *scan_e2e_test_artifacts
- store_test_results:
Expand Down Expand Up @@ -652,7 +676,7 @@ jobs:
source .circleci/local_publish_helpers.sh
changeNpmGlobalPath
cd packages/amplify-migration-tests
retry yarn run migration_v4.52.0_multienv_layers --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
retry yarn migration_v4.52.0_multienv_layers --no-cache --maxWorkers=4 --forceExit $TEST_SUITE
no_output_timeout: 90m
- run: *scan_e2e_test_artifacts
- store_test_results:
Expand All @@ -668,7 +692,7 @@ jobs:
default: l_large
executor: << parameters.os >>
environment:
AMPLIFY_PATH: /home/circleci/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux-x64
steps:
- restore_cache:
key: amplify-cli-repo-{{ .Branch }}-{{ .Revision }}
Expand All @@ -680,9 +704,8 @@ jobs:
name: Run tests using general profile
command: |
source .circleci/local_publish_helpers.sh
changeNpmGlobalPath
cd packages/amplify-e2e-tests
retry yarn run general-config-e2e --no-cache --maxWorkers=3 --forceExit $TEST_SUITE
retry yarn general-config-e2e --no-cache --maxWorkers=3 --forceExit $TEST_SUITE
no_output_timeout: 90m
- run: *scan_e2e_test_artifacts
- store_test_results:
Expand Down Expand Up @@ -710,7 +733,7 @@ jobs:
source .circleci/local_publish_helpers.sh
amplify -v
cd packages/amplify-console-integration-tests
retry yarn run console-integration --no-cache --maxWorkers=4
retry yarn console-integration --no-cache --maxWorkers=4
name: 'Run Amplify Console integration tests'
no_output_timeout: 90m
- run: *scan_e2e_test_artifacts
Expand Down Expand Up @@ -750,23 +773,24 @@ jobs:
name: Configure Amplify CLI
command: |
yarn rm-dev-link && yarn link-dev && yarn rm-aa-dev-link && yarn link-aa-dev
echo 'export PATH="$(yarn global bin):$PATH"' >> $BASH_ENV
echo 'export PATH="$(pwd)/.bin:$PATH"' >> $BASH_ENV
source $BASH_ENV
amplify-dev
- run:
name: Clone auth test package
command: |
cd ..
git clone $AUTH_CLONE_URL
cd aws-amplify-cypress-auth
yarn --cache-folder ~/.cache/yarn
yarn
yarn add [email protected] --save
- run: cd .circleci/ && chmod +x auth.sh
- run: cd .circleci/ && chmod +x amplify_init.sh
- run: cd .circleci/ && chmod +x amplify_init.exp
- run: expect .circleci/amplify_init.exp ../aws-amplify-cypress-auth
- run: expect .circleci/enable_auth.exp
- run: cd ../aws-amplify-cypress-auth
- run: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
- run: yarn --immutable
- run: cd ../aws-amplify-cypress-auth/src && cat $(find . -type f -name 'aws-exports*')
- run:
name: Start Auth test server in background
Expand All @@ -792,12 +816,12 @@ jobs:
cd ..
git clone $API_CLONE_URL
cd aws-amplify-cypress-api
yarn --cache-folder ~/.cache/yarn
yarn
- run: cd .circleci/ && chmod +x api.sh
- run: expect .circleci/amplify_init.exp ../aws-amplify-cypress-api
- run: expect .circleci/enable_api.exp
- run: cd ../aws-amplify-cypress-api
- run: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
- run: yarn --immutable
- run: cd ../aws-amplify-cypress-api/src && cat $(find . -type f -name 'aws-exports*')
- run:
name: Start API test server in background
Expand Down Expand Up @@ -1336,7 +1360,7 @@ commands:
command: |
cd out
ln -sf amplify-pkg-linux-x64 amplify
echo "export PATH=$AMPLIFY_DIR:$PATH" >> $BASH_ENV
echo "export PATH=$AMPLIFY_DIR:$PATH:/home/circleci/repo/node_modules/.bin/" >> $BASH_ENV
source $BASH_ENV
- run:
name: Confirm Amplify CLI is installed and available in PATH
Expand Down Expand Up @@ -1387,10 +1411,10 @@ commands:
name: Run E2e Tests
command: |
source .circleci/local_publish_helpers.sh
source $BASH_ENV
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
changeNpmGlobalPath
source $BASH_ENV
amplify version
cd packages/amplify-e2e-tests
retry runE2eTest
Expand Down
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ jobs:
- restore_cache:
key: >-
amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run: yarn run production-build
- run: yarn --immutable
- run: yarn production-build
- save_cache:
key: >-
amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
Expand Down Expand Up @@ -167,7 +168,7 @@ jobs:
source .circleci/local_publish_helpers.sh
amplify -v
cd packages/amplify-console-integration-tests
retry yarn run console-integration --no-cache --maxWorkers=4
retry yarn console-integration --no-cache --maxWorkers=4
name: Run Amplify Console integration tests
no_output_timeout: 90m
- run:
Expand Down
14 changes: 7 additions & 7 deletions .circleci/local_publish_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function generatePkgCli {

# install package depedencies
cp ../yarn.lock ./
yarn --production
yarn workspaces focus --production

# Optimize package size
find . \
Expand Down Expand Up @@ -142,13 +142,13 @@ function verifyPkgCli {
function unsetNpmRegistryUrl {
# Restore the original NPM and Yarn registry URLs
npm set registry "https://registry.npmjs.org/"
yarn config set registry "https://registry.npmjs.org/"
yarn config set npmRegistryServer "https://registry.npmjs.org/"
}

function unsetSudoNpmRegistryUrl {
# Restore the original NPM and Yarn registry URLs
sudo npm set registry "https://registry.npmjs.org/"
sudo yarn config set registry "https://registry.npmjs.org/"
sudo yarn config set npmRegistryServer "https://registry.npmjs.org/"
}

function changeNpmGlobalPath {
Expand All @@ -166,13 +166,13 @@ function changeSudoNpmGlobalPath {
function setNpmRegistryUrlToLocal {
# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"
yarn config set npmRegistryServer "$custom_registry_url"
}

function setSudoNpmRegistryUrlToLocal {
# Set registry to local registry
sudo npm set registry "$custom_registry_url"
sudo yarn config set registry "$custom_registry_url"
sudo yarn config set npmRegistryServer "$custom_registry_url"
}

function useChildAccountCredentials {
Expand Down Expand Up @@ -273,9 +273,9 @@ function runE2eTest {
if [ -f $FAILED_TEST_REGEX_FILE ]; then
# read the content of failed tests
failedTests=$(<$FAILED_TEST_REGEX_FILE)
yarn run e2e --forceExit --no-cache --maxWorkers=4 $TEST_SUITE -t "$failedTests"
yarn e2e --forceExit --no-cache --maxWorkers=4 $TEST_SUITE -t "$failedTests"
else
yarn run e2e --forceExit --no-cache --maxWorkers=4 $TEST_SUITE
yarn e2e --forceExit --no-cache --maxWorkers=4 $TEST_SUITE
fi
}

Expand Down
6 changes: 6 additions & 0 deletions .circleci/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ function lernaPublishExitOnFailure {
# run lerna publish with the args that were passed to this function
# duplicate stdout to a temp file
# grep the temp file for the lerna err token and return exit 1 if found (-v option inverts grep exit code)

if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
# registy URL update changes .yarnrc.yml file
git update-index --assume-unchanged .yarnrc.yml
fi

npx lerna publish "$@" | tee /tmp/publish-results && grep -qvz "lerna ERR!" < /tmp/publish-results
}

Expand Down
6 changes: 3 additions & 3 deletions .circleci/scan_artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export const hasMatchingContentInFolder = (
return true;
} catch (e) {
// When there is no match exit code is set to 1
if (e.exitCode === 1) {
if ((e as { exitCode: number })?.exitCode === 1) {
return false;
}
if (e.message.includes('No such file or directory')) {
if ((e as { message: string })?.message?.includes('No such file or directory')) {
console.log('No artifacts found at:', folder);
return false;
}
Expand All @@ -34,7 +34,7 @@ export const hasMatchingContentInFolder = (

const main = () => {
const envVarNameWithCredentialValues = (process.env.ENV_VAR_WITH_SECRETS || '').split(',').map((v) => v.trim());
const values = envVarNameWithCredentialValues.map((v) => process.env[v]).filter(Boolean);
const values = envVarNameWithCredentialValues.map((v) => process.env[v]).filter((item): item is string => !!item);
if (values.length) {
for (let folder of ARTIFACT_STORAGE_PATH_ALLOW_LIST) {
if (folder.startsWith('~/')) {
Expand Down
8 changes: 4 additions & 4 deletions .circleci/validate_cdk_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { exec } from 'child_process';

// @aws-cdk/core indicates CDK v1.
exec('yarn why @aws-cdk/core', (err, stdout, stderr) => {
const cdkV1AbsenceIndicator = "We couldn't find a match";
if (stdout.toString().includes(cdkV1AbsenceIndicator) || stderr.toString().includes(cdkV1AbsenceIndicator)) {
console.log('Success! CDK V1 not found');
} else {
const cdkV1PresenceIndicator = '@aws-cdk/core';
if (stdout.toString().includes(cdkV1PresenceIndicator) || stderr.toString().includes(cdkV1PresenceIndicator)) {
console.log('Failure! Found CDK V1 references');
console.log(stdout.toString());
process.exit(1);
} else {
console.log('Success! CDK V1 not found');
}
});
4 changes: 2 additions & 2 deletions .eslint-dictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
"jsconfig",
"jsdoc",
"json2xml",
"junit",
"jwks",
"keyless",
"keyphrase",
Expand Down Expand Up @@ -431,6 +432,7 @@
"wildcard",
"winston",
"workspace",
"workspaces",
"writeable",
"xamznone",
"xcconfig",
Expand All @@ -439,8 +441,6 @@
"xray",
"yaml",
"yarnrc",
"ulid",
"urlencoded",
"yesno",
"yyyymmddhhmmss",
"zoneinfo"
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.yarn/releases/** binary
/.yarn/plugins/** binary
/scripts/.yarn/releases/** binary
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
.yarn/*
.bin/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
**/.DS_Store
.circleci/generated_config.yml
scripts/cci-job.data.json
scripts/cci-test.data.json
scripts/.yarn/*
artifacts/cci-workflow-results.json
artifacts/cci-workflow-results.html
build
Expand Down
Loading

0 comments on commit 9621788

Please sign in to comment.