Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using the Core local environment #17004

Merged
merged 91 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
8a67776
First pass at use core local env.
pento Aug 12, 2019
ef8e1c3
Delete all the files this setup will replace. (Many of them are not y…
pento Aug 13, 2019
95b671d
Retrieve the compose file version from Core's docker-compose.yml, to …
pento Aug 13, 2019
37ed924
Change NPM scripts to use the Core Docker environment.
pento Aug 13, 2019
94be79d
Use local-env in Travis.
pento Aug 13, 2019
0498428
Run composer locally, instead of in Docker.
pento Aug 13, 2019
a39012e
Run `npm install` for WordPress in Travis.
pento Aug 13, 2019
5a9e154
Upgrade Docker on Travis
pento Aug 13, 2019
5242cd8
Use the right build script name.
pento Aug 13, 2019
1cdd12a
Travis needs to `npm ci` for all jobs now.
pento Aug 13, 2019
32070c1
push !== append
pento Aug 13, 2019
edb7b6a
Run `composer install` in the PHP Unit Test jobs.
pento Aug 13, 2019
94e456d
Add debugging
pento Aug 13, 2019
1342f4d
Change the COMPOSER env var to COMPOSER_INSTALL. The former is used b…
pento Aug 13, 2019
c3c2d7c
Build Gutenberg before running it.
pento Aug 13, 2019
a679ae9
Fix the PHPUnit multisite test command.
pento Aug 13, 2019
bd92a8d
Activate the Gutenberg plugin after installing it.
pento Aug 13, 2019
020f721
Run e2e tests against the build dir.
pento Aug 13, 2019
cfd0933
Build to the build dir
pento Aug 13, 2019
88bb0b8
Gutenberg is in the build directory on Travis.
pento Aug 14, 2019
96af4a1
Travis debugging.
pento Aug 14, 2019
dbfe7ad
Run PHP unit tests in the build dir.
pento Aug 14, 2019
4cbd978
Configure WordPress to load from the build directory.
pento Aug 14, 2019
c99524c
Run author e2e tests as an author.
pento Aug 14, 2019
d372e1f
Fix the command for setting up the author user.
pento Aug 14, 2019
c8dd498
Travis: create the uploads directory.
pento Aug 14, 2019
f8f6460
Travis: Don't need to disable SCRIPT_DEBUG for e2e tests.
pento Aug 14, 2019
f10a38a
Move the env scripts to wp-scripts.
pento Aug 14, 2019
02ca863
Add a bunch of env helper scripts.
pento Aug 15, 2019
92c0117
Travis: Composer tasks need WP installed, now.
pento Aug 15, 2019
370ef52
Fix the mount directory in the PHPUnit container.
pento Aug 15, 2019
273c761
Don't lint CSS in the WordPress directory.
pento Aug 15, 2019
9e48716
Disable SCRIPT_DEBUG, and clean up the globals.
pento Aug 15, 2019
1e948c9
Generate docker-compose.override.yml from a template file.
pento Aug 15, 2019
8b0c239
Add start/stop scripts.
pento Aug 16, 2019
fcc1467
Add an install script.
pento Aug 16, 2019
519de4d
Tidy up .travis.yml
pento Aug 16, 2019
baf81fb
Travis: WordPress install now needs to happen after npm ci.
pento Aug 16, 2019
8227869
Allow other plugins using these scripts to override the docker-compos…
pento Aug 19, 2019
83b0aa7
Try activating the plugin using the core WP-CLI script.
pento Aug 19, 2019
ece0f01
Run the correct core build command.
pento Aug 19, 2019
843f622
b0d7330cf773d06a292a56ab9cb27793a7874c39 is obseleted by #16243.
pento Aug 20, 2019
ecc8b25
Check if WordPress is already installed before trying to install it a…
pento Aug 21, 2019
028460a
If we're running in a managed environment, encourage updating if it h…
pento Aug 21, 2019
52059be
Check the Node version before trying to do any environment work.
pento Aug 22, 2019
9e6054b
Add a placeholder for setup-local-env.sh, pointing folks at the new w…
pento Aug 22, 2019
07be5aa
Update the documentation for the local-env.
pento Aug 22, 2019
78bdc3b
Add inline commenting for mergeConfigs().
pento Aug 22, 2019
548b10a
Ensure we catch invalid YAML template files.
pento Aug 22, 2019
2b020f4
Improve behaviour on Windows.
pento Aug 22, 2019
ebaffd8
Simplify the array merging, so old items aren't left hanging around.
pento Aug 22, 2019
8248c80
Add an extra prompt to help people who run env commands without a WP_…
pento Aug 22, 2019
69a91df
List the commands when no arguments are passed to npm run env.
pento Aug 22, 2019
6fd7805
Auto switch between running PHPUnit tests from the src or build direc…
pento Aug 22, 2019
6d628a2
Fix PHPUnit tests not properly running in the build directory.
pento Aug 23, 2019
837e6d1
Let's keep the welcome message when installing local-env.
pento Aug 23, 2019
56e2009
Normalise WP_DEVELOP_DIR when it's generated, so we don't need to nor…
pento Aug 26, 2019
e97900c
Fix an incorrect comment referring to PHPUnit instead of WP-CLI.
pento Aug 26, 2019
15db588
Expand abbreviated variable names.
pento Aug 26, 2019
f963793
Remove an unnecessary normalize()
pento Aug 26, 2019
4859699
Use Array.isArray() to test for arrays.
pento Aug 26, 2019
e8bc7f3
Use isPlainObject() to test for objects.
pento Aug 26, 2019
a6d2e73
Make require look a little more like import.
pento Aug 26, 2019
a52430d
Make require look a little more like import.
pento Aug 26, 2019
92def6a
Make require look a little more like import.
pento Aug 26, 2019
18183ea
Remove a bonus \n
pento Aug 26, 2019
0e1596f
Travis: Rename some environment variables, to make their meaning a li…
pento Aug 26, 2019
602bbb7
Refactor repetitive code into util functions.
pento Aug 26, 2019
ef7d0b7
s/mergeYamlConfigs/mergeYAMLConfigs/g
pento Aug 26, 2019
13c1f90
Reset the database before running e2e tests.
pento Aug 27, 2019
bd90182
Try using Travis build stages to cache the slow parts.
pento Aug 27, 2019
12c52bb
Tweak the Travis caching.
pento Aug 27, 2019
50748b9
Try to share the cache between builds.
pento Aug 27, 2019
8b356eb
Speed up the cache warmup
pento Aug 27, 2019
0903b9c
Don't clone the repo if it's already cached.
pento Aug 27, 2019
e64edb8
Set the PHP version for PHP 5.6 tests.
pento Aug 27, 2019
a6cf935
Fix a .travis.yml parse error.
pento Aug 27, 2019
62e035c
Give MySQL some time to start.
pento Aug 27, 2019
472ca38
No need to cache wordpress/node_modules.
pento Aug 27, 2019
4cdf186
More Travis tweaking.
pento Aug 27, 2019
1b2cba5
Try not caching node_modules
pento Aug 27, 2019
4957667
Try manually downloading the built version of WordPress.
pento Aug 28, 2019
8159801
Fix up some Travis bugs.
pento Aug 28, 2019
1c582ce
Add some debugging.
pento Aug 28, 2019
f8e5524
Travis: HALP HOW DO I mv
pento Aug 28, 2019
84035b1
A little more tweaking.
pento Aug 28, 2019
f36fb00
Copy the tests directory from WP, too.
pento Aug 28, 2019
a09be70
Improve performance of lint and license tests.
pento Aug 28, 2019
a47f54c
Add documentation to README.md.
pento Aug 28, 2019
bc69eda
Travis: Cache the cacheable bits of Composer.
pento Aug 28, 2019
ab6f7e0
Update the @wordpress/scripts changelog.
pento Aug 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ gutenberg.zip
*.log
phpcs.xml
yarn.lock
docker-compose.override.yml
pento marked this conversation as resolved.
Show resolved Hide resolved
/wordpress

playground/dist
Expand Down
140 changes: 82 additions & 58 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,79 @@ cache:
- $HOME/.jest-cache
- $HOME/.npm
- $HOME/.nvm/.cache
- $HOME/.phpbrew

branches:
only:
- master

env:
global:
pento marked this conversation as resolved.
Show resolved Hide resolved
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- WP_DEVELOP_DIR: ./wordpress
- LOCAL_SCRIPT_DEBUG: false
- INSTALL_COMPOSER: false
- INSTALL_WORDPRESS: true

before_install:
- nvm install

env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
- |
if [[ "$INSTALL_WORDPRESS" = "true" ]]; then
# Upgrade docker-compose.
sudo rm /usr/local/bin/docker-compose
curl -sL https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
fi

install:
# Build Gutenberg.
- npm ci
- npm run build
- |
if [[ "$INSTALL_WORDPRESS" = "true" ]]; then
# Download and unpack WordPress.
curl -sL https://wordpress.org/nightly-builds/wordpress-latest.zip -o /tmp/wordpress-latest.zip
unzip -q /tmp/wordpress-latest.zip -d /tmp
mkdir -p wordpress/src
mv /tmp/wordpress/* wordpress/src

# Create the upload directory with permissions that Travis can handle.
mkdir -p wordpress/src/wp-content/uploads
chmod 767 wordpress/src/wp-content/uploads

# Grab the tools we need for WordPress' local-env.
curl -sL https://github.com/WordPress/wordpress-develop/archive/master.zip -o /tmp/wordpress-develop.zip
unzip -q /tmp/wordpress-develop.zip -d /tmp
mv \
/tmp/wordpress-develop-master/tools \
/tmp/wordpress-develop-master/tests \
/tmp/wordpress-develop-master/.env \
/tmp/wordpress-develop-master/docker-compose.yml \
/tmp/wordpress-develop-master/wp-cli.yml \
/tmp/wordpress-develop-master/*config-sample.php \
/tmp/wordpress-develop-master/package.json wordpress

# Install WordPress.
cd wordpress
npm install dotenv wait-on
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the purpose or need for these installs.

wait-on seems like something which could have been useful in place of the sleep 10 which follows a few lines down. I suppose it might have been an initial attempt to try to react to the availability of the environment in a more reliable way than a sleep?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run env:start
sleep 10
npm run env:install
cd ..

# Connect Gutenberg to WordPress.
npm run env connect
npm run env cli plugin activate gutenberg
fi
- |
if [[ "$INSTALL_COMPOSER" = "true" ]]; then
npm run env docker-run -- php composer install
fi
- |
if [[ "$E2E_ROLE" = "author" ]]; then
npm run env cli -- user create author author@example.com --role=author --user_pass=authpass
npm run env cli -- post update 1 --post_author=2
fi

jobs:
include:
Expand All @@ -52,125 +115,86 @@ jobs:
- npm run check-licenses

- name: JavaScript unit tests
env: INSTALL_WORDPRESS=false
install:
- npm ci
script:
# It's not necessary to run the full build, since Jest can interpret
# source files with `babel-jest`. Some packages have their own custom
# build tasks, however. These must be run.
- npx lerna run build
script:
- npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache"

- name: JavaScript native mobile tests
install:
- npm ci
script:
# It's not necessary to run the full build, since Jest can interpret
# source files with `babel-jest`. Some packages have their own custom
# build tasks, however. These must be run.
- npx lerna run build
script:
- npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache"

- name: PHP unit tests (Docker)
env: WP_VERSION=latest DOCKER=true
- name: PHP unit tests
env: INSTALL_COMPOSER=true
script:
- ./bin/run-wp-unit-tests.sh
- npm run test-php && npm run test-unit-php-multisite

- name: PHP unit tests (PHP 5.6)
language: php
php: 5.6
env: WP_VERSION=latest
env: INSTALL_COMPOSER=true LOCAL_PHP=5.6-fpm
script:
- ./bin/run-wp-unit-tests.sh
if: branch = master and type != "pull_request"

- 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"

- name: PHP unit tests (PHP 5.2)
env: WP_VERSION=latest SWITCH_TO_PHP=5.2
script:
- ./bin/run-wp-unit-tests.sh
pento marked this conversation as resolved.
Show resolved Hide resolved
- npm run test-php && npm run test-unit-php-multisite

- name: E2E tests (Admin) (1/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests )

- name: E2E tests (Admin) (2/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests )

- name: E2E tests (Admin) (3/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests )

- name: E2E tests (Admin) (4/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests )

- name: E2E tests (Author) (1/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 0' < ~/.jest-e2e-tests )

- name: E2E tests (Author) (2/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 1' < ~/.jest-e2e-tests )

- name: E2E tests (Author) (3/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 2' < ~/.jest-e2e-tests )

- name: E2E tests (Author) (4/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
install:
- ./bin/setup-travis-e2e-tests.sh
env: E2E_ROLE=author FORCE_REDUCED_MOTION=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
script:
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests
- $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == 3' < ~/.jest-e2e-tests )

allow_failures:
- name: JavaScript native mobile tests
- 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"

- name: PHP unit tests (PHP 5.2)
env: WP_VERSION=latest SWITCH_TO_PHP=5.2
script:
- ./bin/run-wp-unit-tests.sh

before_deploy:
- npm install
Expand Down
12 changes: 0 additions & 12 deletions bin/bootstrap-env.sh

This file was deleted.

17 changes: 17 additions & 0 deletions bin/docker-compose.override.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
wordpress-develop:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins
php:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins
- %PLUGIN_MOUNT_DIR%/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins
cli:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
phpunit:
volumes:
- %PLUGIN_MOUNT_DIR%:/var/www/${LOCAL_DIR-src}/wp-content/plugins/%PLUGIN_INSTALL_DIR%
134 changes: 0 additions & 134 deletions bin/includes.sh

This file was deleted.

Loading