From 0b2f88023b9d8648de153c8ef1f68c716163a58e Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Thu, 27 Dec 2018 11:41:26 +1100 Subject: [PATCH 1/7] Optimize Travis CI integration - Cache npm and nvm artifacts - Use jest caching - Run E2E tests in parallel --- .travis.yml | 66 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 877794f883a38c..5658ce025b559d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ dist: trusty -language: php +language: generic services: - docker @@ -13,56 +13,84 @@ notifications: cache: directories: - $HOME/.composer/cache - - $HOME/.phpbrew + - $HOME/.jest-cache - $HOME/.npm - -before_install: - - nvm install && nvm use - - npm install npm -g + - $HOME/.nvm/.cache + - $HOME/.phpbrew + - node_modules branches: only: - master +before_install: + - nvm install + jobs: include: - - stage: test + - name: JS unit tests env: WP_VERSION=latest + before_install: + - nvm install --latest-npm + install: + - npm install script: - - npm install || exit 1 - - npm run ci || exit 1 + - npm run lint + - npm run check-local-changes + - npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - stage: test + - name: PHP unit tests (Docker) env: WP_VERSION=latest DOCKER=true script: - ./bin/run-wp-unit-tests.sh - - stage: test + - name: PHP unit tests (PHP 5.6) + language: php php: 5.6 env: WP_VERSION=latest script: - ./bin/run-wp-unit-tests.sh if: branch = master and type != "pull_request" - - stage: test - php: 7.1 + - name: PHP unit tests (PHP 5.3) env: WP_VERSION=latest SWITCH_TO_PHP=5.3 script: - ./bin/run-wp-unit-tests.sh if: branch = master and type != "pull_request" - - stage: test - php: 7.1 + - name: PHP unit tests (PHP 5.2) env: WP_VERSION=latest SWITCH_TO_PHP=5.2 script: - ./bin/run-wp-unit-tests.sh - - stage: test + - name: E2E tests (Admin with plugins) (1/2) env: WP_VERSION=latest POPULAR_PLUGINS=true + install: + - ./bin/setup-local-env.sh + script: + - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests + - npm run test-e2e -- $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + + - name: E2E tests (Admin with plugins) (2/2) + env: WP_VERSION=latest POPULAR_PLUGINS=true + install: + - ./bin/setup-local-env.sh + script: + - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests + - npm run test-e2e -- $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + + - name: E2E tests (Author without plugins) (1/2) + env: WP_VERSION=latest E2E_ROLE=author + install: + - ./bin/setup-local-env.sh script: - - ./bin/run-e2e-tests.sh || exit 1 + - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests + - npm run test-e2e -- $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - - stage: test + - name: E2E tests (Author without plugins) (2/2) env: WP_VERSION=latest E2E_ROLE=author + install: + - ./bin/setup-local-env.sh script: - - ./bin/run-e2e-tests.sh || exit 1 + - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests + - npm run test-e2e -- $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) From 976e8c23326131fa6f66414a19809281b4b464b9 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 28 Dec 2018 11:15:03 +1100 Subject: [PATCH 2/7] Use `npm ci` instead of `npm install` This feels "more correct" and doesn't significantly affect build performance. --- .checksum | 1 + .travis.yml | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .checksum diff --git a/.checksum b/.checksum new file mode 100644 index 00000000000000..c4d77615d40b6f --- /dev/null +++ b/.checksum @@ -0,0 +1 @@ +72208ee53c4681d45961928c311bfbdf \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5658ce025b559d..2853b3b02061cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ cache: - $HOME/.npm - $HOME/.nvm/.cache - $HOME/.phpbrew - - node_modules branches: only: @@ -33,7 +32,7 @@ jobs: before_install: - nvm install --latest-npm install: - - npm install + - npm ci script: - npm run lint - npm run check-local-changes From c37ba2840381642023c84a20742ba5441e1ddd62 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 28 Dec 2018 12:04:30 +1100 Subject: [PATCH 3/7] Remove unnecessary npm scripts --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 95ce65ad2682f3..50048e3bc45e76 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,6 @@ "check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"", "precheck-local-changes": "npm run docs:build", "check-local-changes": "( git diff -U0 | xargs -0 node bin/process-git-diff ) || ( echo \"There are local uncommitted changes after one or both of 'npm install' or 'npm run docs:build'!\" && exit 1 );", - "ci": "concurrently \"npm run lint\" \"npm run test-unit:ci\" \"npm run check-local-changes\"", "predev": "npm run check-engines", "dev": "npm run build:packages && concurrently \"cross-env webpack --watch\" \"npm run dev:packages\"", "dev:packages": "node ./bin/packages/watch.js", @@ -183,7 +182,6 @@ "test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.json", "test-unit:update": "npm run test-unit -- --updateSnapshot", "test-unit:watch": "npm run test-unit -- --watch", - "test-unit:ci": "npm run test-unit -- --ci --runInBand", "test-unit-php": "docker-compose run --rm wordpress_phpunit phpunit", "test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit" }, From 95f9981fa181ddcb357a254a2e4be89a2b5a13dc Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 28 Dec 2018 12:09:13 +1100 Subject: [PATCH 4/7] Configure E2E tests to use caching and to not update snapshots --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2853b3b02061cf..05cbb37d8c5ab6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin with plugins) (2/2) env: WP_VERSION=latest POPULAR_PLUGINS=true @@ -76,7 +76,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (1/2) env: WP_VERSION=latest E2E_ROLE=author @@ -84,7 +84,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (2/2) env: WP_VERSION=latest E2E_ROLE=author @@ -92,4 +92,4 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) From 1bb8a1c62ccfc649f684a7d178b0e78611d8d46e Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 28 Dec 2018 12:23:33 +1100 Subject: [PATCH 5/7] Tell jest to not bother with regular expressions --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05cbb37d8c5ab6..4b12f20318945d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin with plugins) (2/2) env: WP_VERSION=latest POPULAR_PLUGINS=true @@ -76,7 +76,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (1/2) env: WP_VERSION=latest E2E_ROLE=author @@ -84,7 +84,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (2/2) env: WP_VERSION=latest E2E_ROLE=author @@ -92,4 +92,4 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) From 94ffdce82b3763b184a86f4974da1b91e8155b9d Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Fri, 28 Dec 2018 16:44:38 +1100 Subject: [PATCH 6/7] Oops, how'd this get here? --- .checksum | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .checksum diff --git a/.checksum b/.checksum deleted file mode 100644 index c4d77615d40b6f..00000000000000 --- a/.checksum +++ /dev/null @@ -1 +0,0 @@ -72208ee53c4681d45961928c311bfbdf \ No newline at end of file From af4100d4853556dc2775a1526d8a187606431520 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Thu, 3 Jan 2019 11:09:39 +1100 Subject: [PATCH 7/7] Don't provide unnecessary --runInBand argument --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b12f20318945d..6fcc4d931c1942 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Admin with plugins) (2/2) env: WP_VERSION=latest POPULAR_PLUGINS=true @@ -76,7 +76,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (1/2) env: WP_VERSION=latest E2E_ROLE=author @@ -84,7 +84,7 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 0' < ~/.jest-e2e-tests ) - name: E2E tests (Author without plugins) (2/2) env: WP_VERSION=latest E2E_ROLE=author @@ -92,4 +92,4 @@ jobs: - ./bin/setup-local-env.sh script: - $( npm bin )/jest --config test/e2e/jest.config.json --listTests > ~/.jest-e2e-tests - - npm run test-e2e -- --ci --runInBand --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests ) + - npm run test-e2e -- --ci --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 2 == 1' < ~/.jest-e2e-tests )