Skip to content

Commit d12a011

Browse files
authored
Merge pull request #16 from alleyinteractive/release-v7
Release v7
2 parents 3ae92ef + bbc81c2 commit d12a011

13 files changed

+1808
-749
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
.sass-cache
2+
.DS_Store
3+
.thumbsdb
14
.svn
5+
npm-debug.log
6+
node_modules
7+
npm-debug.log
8+
bower_components
9+
.idea
10+
11+
/vendor

.travis.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Travis CI (MIT License) configuration file for Options Importer
2+
# @link https://travis-ci.org/
3+
4+
# Declare project language.
5+
# @link http://about.travis-ci.org/docs/user/languages/php/
6+
language: php
7+
8+
# Specify when Travis should build.
9+
branches:
10+
only:
11+
- master
12+
- /^release-v.*$/
13+
14+
services:
15+
- mysql
16+
17+
cache:
18+
directories:
19+
- $HOME/.composer/cache
20+
- ./vendor
21+
22+
matrix:
23+
include:
24+
- php: '5.3'
25+
env: WP_VERSION=3.8
26+
dist: precise
27+
- php: '5.6'
28+
env: WP_VERSION=3.8
29+
- php: '7.0'
30+
env: WP_VERSION=latest
31+
- php: '7.3'
32+
env: WP_VERSION=latest WP_TRAVISCI=phpcs PHP_LINT=1 WP_PHPCS=1
33+
- php: '7.4'
34+
env: WP_VERSION=nightly
35+
fast_finish: true
36+
allow_failures:
37+
- php: '7.4'
38+
39+
# Prepare your build for testing.
40+
# Failures in this section will result in build status 'errored'.
41+
before_script:
42+
# Turn off Xdebug. See https://core.trac.wordpress.org/changeset/40138.
43+
- phpenv config-rm xdebug.ini || echo "Xdebug not available"
44+
- export OG_DIR="$(pwd)"
45+
46+
- export PATH="$HOME/.composer/vendor/bin:$PATH"
47+
48+
# Couple the PHPUnit version to the PHP version.
49+
- |
50+
case "$TRAVIS_PHP_VERSION" in
51+
7.*)
52+
echo "Using PHPUnit 6.1"
53+
composer global require "phpunit/phpunit=6.1.*"
54+
;;
55+
*)
56+
echo "Using PHPUnit 4.8"
57+
composer global require "phpunit/phpunit=4.8.*"
58+
;;
59+
esac
60+
61+
- |
62+
if [[ ! -z "$WP_VERSION" ]] ; then
63+
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
64+
fi
65+
66+
- |
67+
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
68+
# Composer Install
69+
travis_retry composer install
70+
export PATH=$PATH:`pwd`/vendor/bin/
71+
fi
72+
73+
- phpenv rehash
74+
75+
# For debugging.
76+
- pwd
77+
- which phpunit
78+
- phpunit --version
79+
- echo $PATH
80+
81+
# Run test script commands.
82+
# Default is specific to project language.
83+
# All commands must exit with code 0 on success. Anything else is considered failure.
84+
script:
85+
# Search for PHP syntax errors.
86+
#
87+
# Only need to run this once per PHP version.
88+
- |
89+
if [[ "$PHP_LINT" == "1" ]] ; then
90+
find . -type "f" -iname "*.php" -not -path "./vendor/*" | xargs -L "1" php -l
91+
fi
92+
93+
# WordPress Coding Standards.
94+
#
95+
# These are the same across PHP and WordPress, so we need to run them only once.
96+
#
97+
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
98+
# @link http://pear.php.net/package/PHP_CodeSniffer/
99+
- |
100+
if [[ "$WP_PHPCS" == "1" ]] ; then
101+
phpcs -n
102+
fi
103+
104+
# Run the plugins's unit tests, both in single and multisite.
105+
- |
106+
if [[ ! -z "$WP_VERSION" ]] ; then
107+
phpunit --version
108+
phpunit
109+
phpunit -c multisite.xml
110+
fi
111+
112+
# Receive notifications for build results.
113+
# @link http://docs.travis-ci.com/user/notifications/#Email-notifications
114+
notifications:
115+
email: false

bin/install-wp-tests.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/usr/bin/env bash
2+
3+
if [ $# -lt 3 ]; then
4+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
5+
exit 1
6+
fi
7+
8+
DB_NAME=$1
9+
DB_USER=$2
10+
DB_PASS=$3
11+
DB_HOST=${4-localhost}
12+
WP_VERSION=${5-latest}
13+
SKIP_DB_CREATE=${6-false}
14+
15+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
16+
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
17+
18+
download() {
19+
if [ `which curl` ]; then
20+
curl -s "$1" > "$2";
21+
elif [ `which wget` ]; then
22+
wget -nv -O "$2" "$1"
23+
fi
24+
}
25+
26+
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
27+
WP_TESTS_TAG="tags/$WP_VERSION"
28+
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
29+
WP_TESTS_TAG="trunk"
30+
else
31+
# http serves a single offer, whereas https serves multiple. we only want one
32+
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
33+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
34+
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
35+
if [[ -z "$LATEST_VERSION" ]]; then
36+
echo "Latest WordPress version could not be found"
37+
exit 1
38+
fi
39+
WP_TESTS_TAG="tags/$LATEST_VERSION"
40+
fi
41+
42+
set -ex
43+
44+
install_wp() {
45+
46+
if [ -d $WP_CORE_DIR ]; then
47+
return;
48+
fi
49+
50+
mkdir -p $WP_CORE_DIR
51+
52+
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
53+
mkdir -p /tmp/wordpress-nightly
54+
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
55+
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
56+
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
57+
else
58+
if [ $WP_VERSION == 'latest' ]; then
59+
local ARCHIVE_NAME='latest'
60+
else
61+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
62+
fi
63+
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
64+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
65+
fi
66+
67+
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
68+
}
69+
70+
install_test_suite() {
71+
# portable in-place argument for both GNU sed and Mac OSX sed
72+
if [[ $(uname -s) == 'Darwin' ]]; then
73+
local ioption='-i .bak'
74+
else
75+
local ioption='-i'
76+
fi
77+
78+
# set up testing suite if it doesn't yet exist
79+
if [ ! -d $WP_TESTS_DIR ]; then
80+
# set up testing suite
81+
mkdir -p $WP_TESTS_DIR
82+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
83+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
84+
fi
85+
86+
if [ ! -f wp-tests-config.php ]; then
87+
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
88+
# remove all forward slashes in the end
89+
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
90+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
91+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
92+
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
93+
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
94+
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
95+
fi
96+
97+
}
98+
99+
install_db() {
100+
101+
if [ ${SKIP_DB_CREATE} = "true" ]; then
102+
return 0
103+
fi
104+
105+
# parse DB_HOST for port or socket references
106+
local PARTS=(${DB_HOST//\:/ })
107+
local DB_HOSTNAME=${PARTS[0]};
108+
local DB_SOCK_OR_PORT=${PARTS[1]};
109+
local EXTRA=""
110+
111+
if ! [ -z $DB_HOSTNAME ] ; then
112+
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
113+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
114+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
115+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
116+
elif ! [ -z $DB_HOSTNAME ] ; then
117+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
118+
fi
119+
fi
120+
121+
# create database
122+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
123+
}
124+
125+
install_wp
126+
install_test_suite
127+
install_db

0 commit comments

Comments
 (0)