From afef74fd0ad5b1ac911c71ab18ab5b2d82df3aeb Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Tue, 7 Dec 2021 09:20:49 -0700 Subject: [PATCH 1/2] chore(test): make all tests install with `npm ci` Previously, individual tests were updating `npm` and running `npm install`, which was redundant with the config in the test runner. This also updates all test runners to `npm@8` and fixes the local Docker test runner, which wasn't working previously. --- .github/workflows/build.yml | 4 ++-- .github/workflows/integration.yml | 4 ++-- .github/workflows/lint.yml | 4 ++-- azure-pipelines-test-job.yml | 4 ++-- tasks/e2e-behavior.sh | 8 -------- tasks/e2e-installs.sh | 8 -------- tasks/e2e-kitchensink-eject.sh | 8 -------- tasks/e2e-kitchensink.sh | 8 -------- tasks/e2e-simple.sh | 8 -------- tasks/local-test.sh | 28 +++++++++++++++------------- tasks/publish.sh | 1 + 11 files changed, 24 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e70e13cb520..3ebb67c48e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,8 +11,8 @@ jobs: with: node-version: '14' cache: 'npm' - - name: Install npm@7 - run: npm i -g npm@7 + - name: Install npm@8 + run: npm i -g npm@8 - name: Install run: npm ci --prefer-offline - name: Build diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 66e9dd59dc9..88699dfa278 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -22,8 +22,8 @@ jobs: with: node-version: ${{ matrix.node }} cache: 'npm' - - name: Install npm@7 - run: npm i -g npm@7 + - name: Install npm@8 + run: npm i -g npm@8 - name: Install yarn run: npm i -g yarn - name: Install packages diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ba82da56f35..d9835010a9c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,8 +11,8 @@ jobs: with: node-version: '14' cache: 'npm' - - name: Install npm@7 - run: npm i -g npm@7 + - name: Install npm@8 + run: npm i -g npm@8 - name: Install run: npm ci --prefer-offline - name: Alex diff --git a/azure-pipelines-test-job.yml b/azure-pipelines-test-job.yml index fb3ce4eff9c..cdf3f4dacfd 100644 --- a/azure-pipelines-test-job.yml +++ b/azure-pipelines-test-job.yml @@ -31,8 +31,8 @@ jobs: versionSpec: $(nodeVersion) displayName: 'Install Node.js' - - script: npm i -g npm@7 - displayName: 'Update npm to v7' + - script: npm i -g npm@8 + displayName: 'Update npm to v8' - script: npm ci displayName: 'Run npm ci' diff --git a/tasks/e2e-behavior.sh b/tasks/e2e-behavior.sh index 2619ed5aa08..79059fdf94e 100755 --- a/tasks/e2e-behavior.sh +++ b/tasks/e2e-behavior.sh @@ -61,14 +61,6 @@ set -x cd .. root_path=$PWD -if hash npm 2>/dev/null -then - npm i -g --force npm@latest -fi - -# Bootstrap monorepo -npm install - # ****************************************************************************** # First, publish the monorepo. # ****************************************************************************** diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 5736507318d..92407134a65 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -83,14 +83,6 @@ set -x cd .. root_path=$PWD -if hash npm 2>/dev/null -then - npm i -g npm@latest -fi - -# Bootstrap monorepo -npm install - # ****************************************************************************** # First, publish the monorepo. # ****************************************************************************** diff --git a/tasks/e2e-kitchensink-eject.sh b/tasks/e2e-kitchensink-eject.sh index 622a396d652..fa124f9ec30 100755 --- a/tasks/e2e-kitchensink-eject.sh +++ b/tasks/e2e-kitchensink-eject.sh @@ -69,14 +69,6 @@ if [ "$AGENT_OS" == 'Windows_NT' ]; then root_path=$(cmd //c cd) fi -if hash npm 2>/dev/null -then - npm i -g npm@latest -fi - -# Bootstrap monorepo -npm install - # ****************************************************************************** # First, publish the monorepo. # ****************************************************************************** diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index c29b9840c34..48af65e6031 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -69,14 +69,6 @@ if [ "$AGENT_OS" == 'Windows_NT' ]; then root_path=$(cmd //c cd) fi -if hash npm 2>/dev/null -then - npm i -g npm@latest -fi - -# Bootstrap monorepo -npm install - # ****************************************************************************** # First, publish the monorepo. # ****************************************************************************** diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 3d01fba6f0c..55f777fc5b2 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -76,14 +76,6 @@ if [ "$EXPECTED" != "$ACTUAL" ]; then exit 1 fi -if hash npm 2>/dev/null -then - npm i -g npm@latest -fi - -# Bootstrap monorepo -npm install - # Start the local NPM registry startLocalRegistry "$root_path"/tasks/verdaccio.yaml diff --git a/tasks/local-test.sh b/tasks/local-test.sh index 0e8af29f0b0..0a9bd35fe39 100755 --- a/tasks/local-test.sh +++ b/tasks/local-test.sh @@ -4,26 +4,26 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +node_version=14 +current_git_branch=`git rev-parse --abbrev-ref HEAD` +git_branch=${current_git_branch} +test_suite=all +interactive=false + function print_help { echo "Usage: ${0} [OPTIONS]" echo "" echo "OPTIONS:" - echo " --node-version the node version to use while testing [12]" - echo " --git-branch the git branch to checkout for testing [the current one]" - echo " --test-suite which test suite to use ('all', 'behavior', installs', 'kitchensink', 'kitchensink-eject', 'simple') ['all']" - echo " --interactive gain a bash shell after the test run" + echo " --node-version the node version to use while testing [${node_version}]" + echo " --git-branch the git branch to checkout for testing [${current_git_branch}]" + echo " --test-suite which test suite to use ('all', 'behavior', installs', 'kitchensink', 'kitchensink-eject', 'simple') ['${test_suite}']" + echo " --interactive gain a bash shell after the test run [${interactive}]" echo " --help print this message and exit" echo "" } cd $(dirname $0) -node_version=14 -current_git_branch=`git rev-parse --abbrev-ref HEAD` -git_branch=${current_git_branch} -test_suite=all -interactive=false - while [ "$1" != "" ]; do case $1 in "--node-version") @@ -84,6 +84,8 @@ cd - mv /var/create-react-app/patch . git apply patch rm patch +git add -A +git commit -m 'Apply local changes' CMD if [ ${git_branch} != ${current_git_branch} ]; then @@ -91,15 +93,15 @@ if [ ${git_branch} != ${current_git_branch} ]; then fi read -r -d '' command <<- CMD -echo "prefix=~/.npm" > ~/.npmrc -mkdir ~/.npm -export PATH=\$PATH:~/.npm/bin +npm install npm@8 -g +export PATH=\$(npm config get prefix -g)/bin:\$PATH set -x git clone /var/create-react-app create-react-app --branch ${git_branch} cd create-react-app ${apply_changes} node --version npm --version +npm ci set +x ${test_command} result_code=\$? diff --git a/tasks/publish.sh b/tasks/publish.sh index 0fed73e0078..f58d670b9a5 100755 --- a/tasks/publish.sh +++ b/tasks/publish.sh @@ -28,6 +28,7 @@ root_path=$PWD if [ -n "$(git status --porcelain)" ]; then echo "Your git status is not clean. Aborting."; + git diff exit 1; fi From 09d9db5ec82329ad8a42fd1f119cbcf9ac61aabb Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 8 Dec 2021 09:58:41 -0700 Subject: [PATCH 2/2] fixup! chore(test): make all tests install with `npm ci` --- tasks/publish.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/publish.sh b/tasks/publish.sh index f58d670b9a5..0fed73e0078 100755 --- a/tasks/publish.sh +++ b/tasks/publish.sh @@ -28,7 +28,6 @@ root_path=$PWD if [ -n "$(git status --porcelain)" ]; then echo "Your git status is not clean. Aborting."; - git diff exit 1; fi