Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
JDGrimes committed Mar 5, 2015
2 parents c94689d + a2c765a commit c1fb0bf
Show file tree
Hide file tree
Showing 70 changed files with 2,087 additions and 1,800 deletions.
173 changes: 4 additions & 169 deletions .ci-env.sh
Original file line number Diff line number Diff line change
@@ -1,175 +1,10 @@
#!/bin/bash

# Use the develop branch for WPCS for compatibility with PHPCS 2.0
export WPCS_GIT_TREE=develop

# Set up for the PHPUnit pass.
setup-phpunit() {

if [[ $TRAVIS_PHP_VERSION == '5.2' ]]; then
mkdir -p vendor/jdgrimes/wp-plugin-uninstall-tester
curl -L https://github.com/JDGrimes/wp-plugin-uninstall-tester/archive/master.tar.gz \
| tar xvz --strip-components=1 -C vendor/jdgrimes/wp-plugin-uninstall-tester
elif [[ $TRAVIS_PHP_VERSION == hhvm ]]; then
composer require satooshi/php-coveralls:dev-master
mkdir -p build/logs
else
composer install
fi

wget -O /tmp/install-wp-tests.sh \
https://raw.githubusercontent.com/wp-cli/wp-cli/master/templates/install-wp-tests.sh

sed -i 's/$WP_VERSION == '"'"'latest'"'"'/$WP_VERSION == '"'"'stable'"'"'/' \
/tmp/install-wp-tests.sh

bash /tmp/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION

sed -i 's/do_action( '"'"'admin_init'"'"' )/if ( ! isset( $GLOBALS['"'"'_did_admin_init'"'"'] ) \&\& $GLOBALS['"'"'_did_admin_init'"'"'] = true ) do_action( '"'"'admin_init'"'"' )/' \
/tmp/wordpress-tests/includes/testcase-ajax.php

cd /tmp/wordpress/wp-content/plugins
ln -s $PLUGIN_DIR $PLUGIN_SLUG
cd $PLUGIN_DIR
}

# Set up for the codesniff pass.
setup-codesniff() {

mkdir -p $PHPCS_DIR && curl -L \
https://github.com/$PHPCS_GITHUB_SRC/archive/$PHPCS_GIT_TREE.tar.gz \
| tar xvz --strip-components=1 -C $PHPCS_DIR

mkdir -p $WPCS_DIR && curl -L \
https://github.com/$WPCS_GITHUB_SRC/archive/$WPCS_GIT_TREE.tar.gz \
| tar xvz --strip-components=1 -C $WPCS_DIR

$PHPCS_DIR/scripts/phpcs --config-set installed_paths $WPCS_DIR

npm install -g jshint

composer install
}

# Check php files for syntax errors.
codesniff-php-syntax() {
if [[ $TRAVISCI_RUN == codesniff ]] || [[ $TRAVISCI_RUN == phpunit && $WP_VERSION == stable && $TRAVIS_PHP_VERSION != '5.3' ]]; then
find . ! -path "./dev-lib/*" ! -path "./vendor/*" \( -name '*.php' -o -name '*.inc' \) \
-exec php -lf {} \;
else
echo 'Not running PHP syntax check.'
fi
}

# Check php files with PHPCodeSniffer.
codesniff-phpcs() {
if [[ $TRAVISCI_RUN == codesniff ]]; then
$PHPCS_DIR/scripts/phpcs -ns --standard=$WPCS_STANDARD \
$(if [ -n "$PHPCS_IGNORE" ]; then echo --ignore=$PHPCS_IGNORE; fi) \
$(find . -name '*.php')
else
echo 'Not running PHPCS.'
fi
}

# Check JS files with jshint.
codesniff-jshint() {
if [[ $TRAVISCI_RUN == codesniff ]]; then
jshint .
else
echo 'Not running jshint.'
fi
}

# Check PHP files for proper localization.
codesniff-l10n() {
if [[ $TRAVISCI_RUN == codesniff ]]; then
./vendor/jdgrimes/wp-l10n-validator/bin/wp-l10n-validator
else
echo 'Not running wp-l10n-validator.'
fi
}

# Check XML files for syntax errors.
codesniff-xmllint() {
if [[ $TRAVISCI_RUN == codesniff ]]; then
xmllint --noout $(find . ! -path "./dev-lib/*" ! -path "./vendor/*" \( -name '*.xml' -o -name '*.xml.dist' \))
else
echo 'Not running xmlint.'
fi
}

# Run basic PHPUnit tests.
phpunit-basic() {
if [[ $TRAVISCI_RUN != phpunit ]]; then
echo 'Not running PHPUnit.'
return
fi

local TEST_GROUP=${1-''}
local CLOVER_FILE=${2-basic}

local GROUP_OPTION=''
local COVERAGE_OPTION=''

if [[ $WP_VERSION == '3.8' && $TEST_GROUP == ajax && $WP_MULTISITE == 1 ]]; then
echo 'Not running multisite Ajax tests on 3.8, see https://github.com/WordPoints/wordpoints/issues/239.'
return
fi

if [[ $TEST_GROUP != '' ]]; then
GROUP_OPTION="--group=$TEST_GROUP"
CLOVER_FILE+="-$TEST_GROUP"

if [[ $TRAVIS_PHP_VERSION == '5.2' ]]; then
sed -i '' -e "s/<group>$TEST_GROUP<\/group>//" ./phpunit.xml.dist
fi
fi

if [[ $TRAVIS_PHP_VERSION == hhvm ]]; then
COVERAGE_OPTION="--coverage-clover build/logs/clover-$CLOVER_FILE.xml"
fi

phpunit $GROUP_OPTION $COVERAGE_OPTION
}

# Run uninstall PHPUnit tests.
phpunit-uninstall() {
phpunit-basic uninstall
}

# Run Ajax PHPUnit tests.
phpunit-ajax() {
phpunit-basic ajax
}

# Run the basic tests on multisite.
phpunit-ms() {
WP_MULTISITE=1 phpunit-basic '' ms
}

# Run the uninstall tests on multisite.
phpunit-ms-uninstall() {
WP_MULTISITE=1 phpunit-basic uninstall ms
}

# Run the ajax tests on multisite.
phpunit-ms-ajax() {
WP_MULTISITE=1 phpunit-basic ajax ms
}

# Run basic tests for multisite in network mode.
phpunit-ms-network() {
WORDPOINTS_NETWORK_ACTIVE=1 WP_MULTISITE=1 phpunit-basic '' ms-network
}

# Run uninstall tests in multisite in network mode.
phpunit-ms-network-uninstall() {
WORDPOINTS_NETWORK_ACTIVE=1 WP_MULTISITE=1 phpunit-basic uninstall ms-network
}

# Run Ajax tests in multisite in network mode.
phpunit-ms-network-ajax() {
WORDPOINTS_NETWORK_ACTIVE=1 WP_MULTISITE=1 phpunit-basic ajax ms-network
}
# Ignore the WordPress dev lib when codesniffing.
CODESNIFF_PATH+=('!' -path "./dev-lib/*")
export CODESNIFF_PATH

# EOF
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

1 change: 1 addition & 0 deletions .coveralls.yml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "dev-lib"]
path = dev-lib
url = https://github.com/xwp/wp-dev-lib.git
[submodule "dev-lib-wordpoints"]
path = dev-lib-wordpoints
url = https://github.com/WordPoints/dev-lib.git
35 changes: 8 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Travis CI configuration file.
# Travis CI configuration file for WordPoints.

language: php

Expand All @@ -12,19 +12,18 @@ php:

env:
- TRAVISCI_RUN=codesniff
- TRAVISCI_RUN=phpunit WP_VERSION=nightly
- TRAVISCI_RUN=phpunit WP_VERSION=latest
- TRAVISCI_RUN=phpunit WP_VERSION=stable
- TRAVISCI_RUN=phpunit WP_VERSION=4.0
- TRAVISCI_RUN=phpunit WP_VERSION=3.9
- TRAVISCI_RUN=phpunit WP_VERSION=3.8

sudo: false

matrix:
include:
# Only run HHVM against the latest for now.
- php: hhvm
env: TRAVISCI_RUN=phpunit WP_VERSION=stable
env: TRAVISCI_RUN=phpunit WP_VERSION=latest
exclude:
# The codesniff pass only needs to be run once, I chose PHP 5.3, since WPCS requires it.
- php: 5.2
Expand All @@ -39,36 +38,18 @@ matrix:
- php: hhvm
fast_finish: true

before_install:
- export WP_TESTS_DIR=/tmp/wordpress-tests/
- export PLUGIN_DIR=$(pwd)
- export PLUGIN_SLUG=$(basename $(pwd) | sed 's/^wp-//')
- export PHPCS_DIR=/tmp/phpcs
- export PHPCS_GITHUB_SRC=squizlabs/PHP_CodeSniffer
- export PHPCS_GIT_TREE=master
- export PHPCS_IGNORE='vendor/*,dev-lib/*'
- export WPCS_DIR=/tmp/wpcs
- export WPCS_GITHUB_SRC=WordPress-Coding-Standards/WordPress-Coding-Standards
- export WPCS_GIT_TREE=master
- export WPCS_STANDARD=$(if [ -e phpcs.ruleset.xml ]; then echo phpcs.ruleset.xml; else echo WordPress; fi)
- if [ -e .ci-env.sh ]; then source .ci-env.sh; fi

before_script:
- >
if [ $TRAVISCI_RUN == phpunit ]; then
setup-phpunit
fi
- >
if [ $TRAVISCI_RUN == codesniff ]; then
setup-codesniff
fi
- export WORDPOINTS_PROJECT_TYPE=wordpoints
- export DEV_LIB_PATH=dev-lib-wordpoints
- source $DEV_LIB_PATH/travis/before_script.sh

script:
- codesniff-php-syntax
- codesniff-phpcs
- codesniff-jshint
- codesniff-l10n
- codesniff-xmllint
- codesniff-bash
- phpunit-basic
- phpunit-ms
- phpunit-ms-network
Expand All @@ -80,4 +61,4 @@ script:
- phpunit-ms-network-ajax

after_script:
- if [[ $TRAVIS_PHP_VERSION == hhvm ]]; then php vendor/bin/coveralls; fi
- source $DEV_LIB_PATH/travis/after_script.sh
File renamed without changes
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"php": ">=5.2.0"
},
"require-dev": {
"jdgrimes/wp-plugin-uninstall-tester": "~0.4",
"jdgrimes/wp-l10n-validator": "dev-master",
"wordpoints/l10n-validator-config": "~1.0"
"jdgrimes/wp-plugin-uninstall-tester": "~0.4"
}
}
62 changes: 2 additions & 60 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dev-lib
Submodule dev-lib added at 4815f5
1 change: 1 addition & 0 deletions dev-lib-wordpoints
Submodule dev-lib-wordpoints added at f08bea
Loading

0 comments on commit c1fb0bf

Please sign in to comment.