-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtravis.before_script.sh
executable file
·70 lines (60 loc) · 2.35 KB
/
travis.before_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -e
shopt -s expand_aliases
# TODO: These should not override any existing environment variables
export WP_CORE_DIR=/tmp/wordpress
export WP_TESTS_DIR=${WP_CORE_DIR}/tests/phpunit
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='tests/*,vendor/*,dev-lib/*'
export WPCS_DIR=/tmp/wpcs
export WPCS_GITHUB_SRC=WordPress-Coding-Standards/WordPress-Coding-Standards
export WPCS_GIT_TREE=master
export YUI_COMPRESSOR_CHECK=0
export DISALLOW_EXECUTE_BIT=0
export LIMIT_TRAVIS_PR_CHECK_SCOPE=files # when set to 'patches', limits reports to only lines changed; TRAVIS_PULL_REQUEST must not be 'false'
export PATH_INCLUDES=./
export WPCS_STANDARD=$(if [ -e phpcs.ruleset.xml ]; then echo phpcs.ruleset.xml; else echo WordPress-Core; fi)
if [ -e .jscsrc ]; then
export JSCS_CONFIG=.jscsrc
elif [ -e .jscs.json ]; then
export JSCS_CONFIG=.jscs.json
fi
# Load a .ci-env.sh to override the above environment variables
if [ -e .ci-env.sh ]; then
source .ci-env.sh
fi
# Install the WordPress Unit Tests
if [ -e phpunit.xml ] || [ -e phpunit.xml.dist ]; then
bash $DEV_LIB_PATH/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
cd ${WP_CORE_DIR}/src/wp-content/plugins
mv $PLUGIN_DIR $PLUGIN_SLUG
cd $PLUGIN_SLUG
ln -s $(pwd) $PLUGIN_DIR
echo "Plugin location: $(pwd)"
if ! command -v phpunit >/dev/null 2>&1; then
wget -O /tmp/phpunit.phar https://phar.phpunit.de/phpunit.phar
chmod +x /tmp/phpunit.phar
alias phpunit='/tmp/phpunit.phar'
fi
fi
# Install PHP_CodeSniffer and the WordPress Coding Standards
mkdir -p $PHPCS_DIR && curl -L https://github.com/$PHPCS_GITHUB_SRC/archive/$PHPCS_GIT_TREE.tar.gz | tar xz --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 xz --strip-components=1 -C $WPCS_DIR
$PHPCS_DIR/scripts/phpcs --config-set installed_paths $WPCS_DIR
# Install JSHint
if ! command -v jshint >/dev/null 2>&1; then
npm install -g jshint
fi
# Install jscs
if [ -n "$JSCS_CONFIG" ] && [ -e "$JSCS_CONFIG" ] && ! command -v jscs >/dev/null 2>&1; then
npm install -g jscs
fi
# Install Composer
if [ -e composer.json ]; then
wget http://getcomposer.org/composer.phar && php composer.phar install --dev
fi
set +e