Skip to content

Commit f7fbd3a

Browse files
committed
Working on build script and local dev.
1 parent 6f58f17 commit f7fbd3a

File tree

9 files changed

+181
-6
lines changed

9 files changed

+181
-6
lines changed

Diff for: Dockerfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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) and yaml (needed for contract tests).
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+
ENV PATH="/root/.composer/vendor/bin:${PATH}"
32+
ENV WP_VERSION="4.9.1"

Diff for: 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"

Diff for: 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 ./

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"require": {
1010
"squizlabs/php_codesniffer": "^2.9.1",
1111
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
12-
"phpcompatibility/php-compatibility": "^8"
12+
"phpcompatibility/phpcompatibility-wp": "^1"
1313
},
1414
"require-dev": {
1515
"wp-coding-standards/wpcs": "dev-master"

Diff for: composer.lock

+47-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docker-compose.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '2'
2+
services:
3+
wordpress:
4+
build: .
5+
image: phpcompat/plugin
6+
restart: always
7+
depends_on:
8+
- db
9+
links:
10+
- db:mysql
11+
ports:
12+
- 8081:80
13+
volumes:
14+
- ./:/var/www/html/wp-content/plugins/phpcompat
15+
environment:
16+
WORDPRESS_DB_PASSWORD: password
17+
db:
18+
image: mysql
19+
restart: always
20+
environment:
21+
- MYSQL_ROOT_PASSWORD=password
22+
- MYSQL_DATABASE=wordpress

Diff for: src/js/run.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ jQuery( document ).ready(function($) {
5858
});
5959

6060
});
61+
62+
function startTimer() {
63+
// Requeue the checkStatus call.
64+
timer = setTimeout(function() {
65+
checkStatus();
66+
}, 5000);
67+
}
68+
6169
/**
6270
* Check the scan status and display results if scan is done.
6371
*/
@@ -68,6 +76,10 @@ function checkStatus() {
6876

6977
var obj;
7078
jQuery.post( ajaxurl, data, function( obj ) {
79+
if ( !obj ) {
80+
startTimer();
81+
return;
82+
}
7183
/*
7284
* Status false: the test is not running and has not been run yet
7385
* Status 1: the test is currently running
@@ -101,10 +113,7 @@ function checkStatus() {
101113
// Display the object being scanned.
102114
jQuery( '#wpe-progress-active' ).html( '<strong>Now scanning:</strong> ' + obj.activeJob );
103115

104-
// Requeue the checkStatus call.
105-
timer = setTimeout(function() {
106-
checkStatus();
107-
}, 5000);
116+
startTimer();
108117
}
109118
}, 'json' ).fail(function ( xhr, status, error )
110119
{

Diff for: src/wpephpcompat.php

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class WPEPHPCompat {
9191
'*/give/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/148
9292
'*/woocommerce-pdf-invoices-packing-slips/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/160
9393
'*/iwp-client/*' => '7.0', // https://wordpress.org/support/topic/iwp-client-and-php-7-compatibility/
94+
'*/health-check/*' => '7.2', // https://github.com/wpengine/phpcompat/issues/179
9495
);
9596

9697
/**

Diff for: tests/qunit/test-run.js

+21
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,27 @@ QUnit.test( 'Test checkStatus done', function( assert ) {
148148
checkStatus();
149149
});
150150

151+
QUnit.test( 'Test checkStatus empty result', function( assert ) {
152+
var done = assert.async();
153+
var fixture = $( '#qunit-fixture' );
154+
fixture.append( '<div id="wpe-progress"><div id="wpe-pcc-progress-count"></div></div>' );
155+
156+
ajaxurl = '/checkStatus/empty/';
157+
158+
$.mockjax({
159+
url: ajaxurl,
160+
responseTime: 0,
161+
responseText: '',
162+
onAfterComplete: function() {
163+
assert.ok(true, 'Empty responseText does not throw an error.');
164+
clearTimeout( timer );
165+
done();
166+
}
167+
});
168+
169+
checkStatus();
170+
});
171+
151172
QUnit.test( 'Test checkStatus fail JSON.parse', function( assert ) {
152173
var done = assert.async();
153174
var fixture = $( '#qunit-fixture' );

0 commit comments

Comments
 (0)