Skip to content

Commit 82d7870

Browse files
committed
Build Tools: Add a WordPress Development Environment.
This commit adds the first iteration of a Docker-based config for setting up a local WordPress development environment. Props pento, noisysocks, mcsf, pbearne, isabel_brison. See #47767. git-svn-id: https://develop.svn.wordpress.org/trunk@45745 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3705fdd commit 82d7870

16 files changed

Lines changed: 930 additions & 546 deletions

.env

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
##
2+
# Default configuration options for the local dev environment.
3+
#
4+
# All of these options can be overriden by setting them as environment variables before starting
5+
# the environment. You will need to restart your environment when changing any of these.
6+
##
7+
8+
# The site will be available at http://localhost:LOCAL_PORT
9+
LOCAL_PORT=8889
10+
11+
# Where to run WordPress from. Valid options are 'src' and 'build'.
12+
LOCAL_DIR=src
13+
14+
# The PHP version to use. Valid options are 'latest', and '{version}-fpm', where '{version}' is any
15+
# x.y PHP version from 5.2 onwards.
16+
LOCAL_PHP=latest
17+
18+
# Whether or not to enable XDebug.
19+
LOCAL_PHP_XDEBUG=false
20+
21+
# The MySQL version to use. See https://hub.docker.com/_/mysql/ for valid versions.
22+
LOCAL_MYSQL=5.7
23+
24+
# The debug settings to add to `wp-config.php`.
25+
LOCAL_WP_DEBUG=true
26+
LOCAL_WP_DEBUG_LOG=true
27+
LOCAL_WP_DEBUG_DISPLAY=true
28+
LOCAL_SCRIPT_DEBUG=true

.travis.yml

Lines changed: 72 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,49 @@
1-
sudo: false
2-
dist: trusty
31
language: php
2+
services:
3+
- docker
4+
- mysql
5+
6+
addons:
7+
apt:
8+
packages:
9+
- docker-ce
10+
411
cache:
512
apt: true
613
directories:
714
- $HOME/.npm
815
- vendor
916
- $HOME/.composer/cache
17+
1018
env:
1119
global:
12-
- WP_TRAVISCI=travis:phpunit
20+
- LOCAL_DIR=build
21+
1322
matrix:
1423
include:
15-
- php: 7.2
16-
env: WP_TRAVISCI=e2e
17-
- php: 7.2
18-
env: WP_TRAVISCI=travis:phpcs
19-
- php: 7.1
20-
env: WP_TRAVISCI=travis:js
21-
- php: 7.4snapshot
22-
- php: 7.3
24+
- env: WP_TRAVISCI=test:e2e
25+
- env: WP_TRAVISCI=travis:phpcs
26+
- env: WP_TRAVISCI=travis:js
27+
- env: LOCAL_PHP=7.3-fpm WP_TRAVISCI=test:php
2328
- php: 7.3
24-
env: WP_TRAVIS_OBJECT_CACHE=true
29+
dist: trusty
30+
env: WP_TRAVIS_OBJECT_CACHE=true WP_TRAVISCI=travis:phpunit
2531
services: memcached
26-
- php: 7.2
27-
- php: 7.1
28-
- php: 7.0
29-
env: WP_TEST_REPORTER=true
30-
- php: 5.6
32+
- env: LOCAL_PHP=7.2-fpm WP_TRAVISCI=test:php
33+
- env: LOCAL_PHP=7.1-fpm WP_TRAVISCI=test:php
34+
- env: LOCAL_PHP=7.0-fpm WP_TEST_REPORTER=true WP_TRAVISCI=test:php
35+
- env: LOCAL_PHP=5.6-fpm WP_TRAVISCI=test:php
36+
- php: 7.4snapshot
37+
dist: trusty
38+
env: WP_TRAVISCI=travis:phpunit
3139
- php: nightly
40+
dist: trusty
41+
env: WP_TRAVISCI=travis:phpunit
3242
allow_failures:
3343
- php: 7.4snapshot
3444
- php: nightly
3545
fast_finish: true
46+
3647
before_install:
3748
- |
3849
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
@@ -43,11 +54,26 @@ before_install:
4354
sed -i "s/yourpasswordhere//" wp-tests-config.php
4455
travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
4556
fi
57+
- |
58+
if [[ "$WP_TRAVISCI" == "test:php" ]]; then
59+
cp wp-tests-config-sample.php wp-tests-config.php
60+
sed -i "s/youremptytestdbnamehere/wordpress_develop_tests/" wp-tests-config.php
61+
sed -i "s/yourusernamehere/root/" wp-tests-config.php
62+
sed -i "s/yourpasswordhere/password/" wp-tests-config.php
63+
sed -i "s/localhost/mysql/" wp-tests-config.php
64+
travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
65+
fi
66+
- |
67+
sudo rm /usr/local/bin/docker-compose
68+
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose
69+
chmod +x docker-compose
70+
sudo mv docker-compose /usr/local/bin
4671
- |
4772
if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
4873
cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
4974
echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
5075
fi
76+
5177
before_script:
5278
- |
5379
# Remove Xdebug for a huge performance increase:
@@ -57,30 +83,14 @@ before_script:
5783
echo "xdebug.ini does not exist"
5884
fi
5985
- |
60-
# Export Composer's global bin dir to PATH, but not on PHP 5.2:
86+
# Export Composer's global bin dir to PATH:
6187
composer config --list --global
6288
export PATH=`composer config --list --global | grep '\[home\]' | { read a; echo "${a#* }/vendor/bin:$PATH"; }`
6389
- |
64-
# Install the specified version of PHPUnit depending on the PHP version:
90+
# Install PHPUnit for the tests that don't run in Docker.
6591
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
66-
case "$TRAVIS_PHP_VERSION" in
67-
7.4snapshot|7.3|7.2|7.1|nightly)
68-
echo "Using PHPUnit 7.x"
69-
travis_retry composer global require "phpunit/phpunit:^7"
70-
;;
71-
7.0)
72-
echo "Using PHPUnit 6.x"
73-
travis_retry composer global require "phpunit/phpunit:^6"
74-
;;
75-
5.6)
76-
echo "Using PHPUnit 4.x"
77-
travis_retry composer global require "phpunit/phpunit:^4"
78-
;;
79-
*)
80-
echo "No PHPUnit version handling for PHP version $TRAVIS_PHP_VERSION"
81-
exit 1
82-
;;
83-
esac
92+
echo "Using PHPUnit 7.x"
93+
travis_retry composer global require "phpunit/phpunit:^7"
8494
fi
8595
- |
8696
# We only need to run composer install on the PHP coding standards job.
@@ -93,6 +103,15 @@ before_script:
93103
- nvm install 10.13.0
94104
- npm install
95105
- npm prune
106+
- |
107+
if [[ "$WP_TRAVISCI" == "test:e2e" ]] || [[ "$WP_TRAVISCI" == "test:php" ]]; then
108+
npm run env:start
109+
npm run build
110+
fi
111+
- |
112+
if [[ "$WP_TRAVISCI" == "test:e2e" ]]; then
113+
npm run env:install
114+
fi
96115
- mysql --version
97116
- phpenv versions
98117
- php --version
@@ -105,15 +124,22 @@ before_script:
105124
- git --version
106125
- svn --version
107126
- locale -a
127+
108128
script:
109-
- |
110-
if [[ "$WP_TRAVISCI" == "e2e" ]]; then
111-
npm run env:start
112-
npm run env:reset-site
113-
npm run test:e2e
114-
else
115-
npm run grunt $WP_TRAVISCI
116-
fi
129+
- |
130+
if [[ "$WP_TRAVISCI" == "test:e2e" ]]; then
131+
npm run test:e2e
132+
elif [[ "$WP_TRAVISCI" == "test:php" ]]; then
133+
npm run test:php -- -- -- --verbose -c phpunit.xml.dist
134+
npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group ajax
135+
npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml
136+
npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml --group ms-files
137+
npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group external-http
138+
npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group restapi-jsclient
139+
else
140+
npm run grunt $WP_TRAVISCI
141+
fi
142+
117143
after_script:
118144
- |
119145
if [[ "$WP_TEST_REPORTER" == "true" ]]; then
@@ -122,6 +148,7 @@ after_script:
122148
export WPT_TEST_DIR=$(pwd)
123149
php test-runner/report.php
124150
fi
151+
125152
notifications:
126153
slack:
127154
rooms:

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# WordPress
2+
3+
[![Build Status](https://img.shields.io/travis/com/WordPress/wordpress-develop/master.svg)](https://travis-ci.com/WordPress/wordpress-develop)
4+
5+
Welcome to the WordPress development repository! Please check out our [contributor handbook](https://make.wordpress.org/core/handbook/) for information about how to open bug reports, contribute patches, test, documention, or get involved in any way you can.
6+
7+
## Getting Started
8+
9+
WordPress is a PHP/MySQL-based project. We have a basic development environment that you can quickly get up and running with a few commands. First off, you will need to download and install [Docker](https://www.docker.com/products/docker-desktop), if you don't have it already. After that, there are a few commands to run:
10+
11+
### Development Environment Commands
12+
13+
Running these commands will start the development environment:
14+
15+
```
16+
npm install
17+
npm run build:dev
18+
npm run env:start
19+
npm run env:install
20+
```
21+
22+
Additionally, `npm run env:stop` will stop the environment.
23+
24+
`npm run env:cli` runs the [WP-CLI tool](https://make.wordpress.org/cli/handbook/). WP-CLI has a lot of [useful commands](https://developer.wordpress.org/cli/commands/) you can use to work on your WordPress site. Where the documentation mentions running `wp`, run `npm run env:cli` instead. For example, `npm run env:cli help`.
25+
26+
`npm run test:php` and `npm run test:e2e` run the PHP and E2E test suites, respectively.

0 commit comments

Comments
 (0)