Skip to content

Commit 5f68366

Browse files
authored
Merge pull request wpengine#192 from wpengine/phpcompatbility-8
Update to latest PHPCompatibility.
2 parents 5260d95 + 03b35d0 commit 5f68366

21 files changed

+2083
-56
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
composer.lock
21
vendor/
32
node_modules/
3+
build/
4+
phpcompat.zip

.travis.yml

+1-18
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,9 @@ before_script:
7171
else
7272
composer install
7373
fi
74-
- |
75-
if [[ "$WP_VERSION" == "latest" ]]; then
76-
curl -s http://api.wordpress.org/core/version-check/1.7/ > /tmp/wp-latest.json
77-
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
78-
WP_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
79-
fi
8074
- |
8175
if [[ "$NPM_TESTS" != "1" ]]; then
82-
PLUGIN_SLUG=$(basename $(pwd))
83-
export WP_DEVELOP_DIR=/tmp/wordpress/
84-
git clone --depth=50 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress
85-
cd ..
86-
cp -r "$PLUGIN_SLUG" "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
87-
cd /tmp/wordpress/
88-
cp wp-tests-config-sample.php wp-tests-config.php
89-
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
90-
sed -i "s/yourusernamehere/travis/" wp-tests-config.php
91-
sed -i "s/yourpasswordhere//" wp-tests-config.php
92-
mysql -e "CREATE DATABASE wordpress_tests;" -uroot
93-
cd "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
76+
tests/install-wp-tests.sh wordpress_tests travis "" localhost $WP_VERSION false
9477
phpenv rehash
9578
fi
9679
script:

Dockerfile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Start with the latest WordPress image.
2+
FROM wordpress:4.9.1-php7.0-apache
3+
4+
# Set up nodejs PPA
5+
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash
6+
7+
# Install server dependencies.
8+
RUN apt-get update && apt-get install -qq -y nodejs build-essential pkg-config libcairo2-dev libjpeg-dev libgif-dev git subversion mysql-client zip unzip vim libyaml-dev --fix-missing --no-install-recommends
9+
10+
# Setup phpunit dependencies (needed for coverage).
11+
RUN pecl install xdebug && \
12+
docker-php-ext-enable xdebug
13+
14+
COPY tests/install-wp-tests.sh /
15+
RUN /install-wp-tests.sh wordpress root password mysql 4.9.1 true
16+
17+
# Download wp-cli
18+
RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod 755 /usr/local/bin/wp
19+
20+
# Speed up phpcs https://stackoverflow.com/questions/37450185/php-code-sniffer-via-grunt-is-incredibly-slow
21+
RUN echo "default_socket_timeout = 5\nlog_errors = On\nerror_log = /dev/stderr" > /usr/local/etc/php/php.ini
22+
23+
# Disable PHP opcache (not great while developing)
24+
RUN rm -rf /usr/local/etc/php/conf.d/opcache-recommended.ini
25+
26+
# Install composer.
27+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
28+
29+
RUN composer global require "phpunit/phpunit:^6"
30+
31+
# Install global grunt task runner.
32+
RUN npm install grunt-cli -g
33+
34+
ENV PATH="/root/.composer/vendor/bin:${PATH}"
35+
ENV WP_VERSION="4.9.1"

Gruntfile.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
var phpPaths = ['wpengine-phpcompat.php', 'src/*.php'];
1+
var phpPaths = [
2+
'wpengine-phpcompat.php',
3+
'load-files.php',
4+
'src/*.php',
5+
];
26

37
module.exports = function(grunt) {
48

Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SHELL := /bin/bash
2+
3+
# WordPress management via docker-compose
4+
start:
5+
docker-compose -f docker-compose.yml up -d
6+
7+
stop:
8+
docker-compose -f docker-compose.yml stop
9+
10+
# One liner to get a shell inside the WordPress container.
11+
shell:
12+
docker-compose exec wordpress /bin/bash -c "cd /var/www/html/wp-content/plugins/phpcompat/; /bin/bash"

build.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
if [ ! -d "build" ]; then
3+
svn co https://plugins.svn.wordpress.org/php-compatibility-checker build
4+
else
5+
pushd build
6+
svn up
7+
popd
8+
fi
9+
10+
composer install --no-dev
11+
rsync \
12+
-avuP \
13+
--delete \
14+
--exclude="Tests" \
15+
--include='wpengine-phpcompat.php' \
16+
--include='uninstall.php' \
17+
--include='load-files.php' \
18+
--include='readme.txt' \
19+
--include='src' \
20+
--include="src/**" \
21+
--include='vendor' \
22+
--include='vendor/**' \
23+
--include='php52' \
24+
--include='php52/**' \
25+
--exclude="*" \
26+
./ ./build/trunk
27+
28+
pushd ./build/trunk
29+
zip -r phpcompat.zip .
30+
popd
31+
rm ./phpcompat.zip
32+
mv ./build/trunk/phpcompat.zip ./

composer.json

+6-19
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,19 @@
77
"email": "[email protected]"
88
}],
99
"require": {
10-
"squizlabs/php_codesniffer": "2.9.*",
11-
"wimg/php-compatibility": "^8",
12-
"simplyadmire/composer-plugins" : "@dev"
10+
"squizlabs/php_codesniffer": "^2.9.1",
11+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
12+
"phpcompatibility/phpcompatibility-wp": "^1"
1313
},
1414
"require-dev": {
15-
"wp-coding-standards/wpcs": "dev-master",
16-
"neronmoon/scriptsdev": "^0.1.0"
15+
"wp-coding-standards/wpcs": "dev-master"
1716
},
1817
"scripts": {
1918
"post-update-cmd": [
20-
"cd php52; composer update; cd ..",
21-
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility"
19+
"cd php52; composer update; cd .."
2220
],
2321
"post-install-cmd": [
24-
"cd php52; composer install; cd ..",
25-
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility"
26-
]
27-
},
28-
"scripts-dev": {
29-
"post-update-cmd": [
30-
"cd php52; composer update; cd ..",
31-
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility,../../wp-coding-standards/wpcs"
32-
],
33-
"post-install-cmd": [
34-
"cd php52; composer install; cd ..",
35-
"vendor/bin/phpcs --config-set installed_paths ../../wimg/php-compatibility,../../wp-coding-standards/wpcs"
22+
"cd php52; composer install; cd .."
3623
]
3724
}
3825
}

0 commit comments

Comments
 (0)