-
Notifications
You must be signed in to change notification settings - Fork 35
/
.travis.yml
130 lines (105 loc) · 4.67 KB
/
.travis.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
sudo: required
dist: xenial
language: php
notifications:
email: false
php:
- '7.0'
services:
- mysql
addons:
apt:
packages:
- libjpeg-dev
- libpng12-dev
- php-mysql
# disable the default submodule logic
git:
submodules: false
cache:
directories:
- vendor
- $HOME/.composer/cache
env:
global:
- WP_VERSION="latest"
- WP_ROOT_FOLDER="/tmp/wordpress"
- WP_URL="http://localhost:9000"
- WP_DOMAIN="localhost:9000"
- WP_TABLE_PREFIX="wp_"
- DB_NAME="wp"
- TEST_DB_NAME="test"
- WP_ADMIN_USERNAME="admin"
- WP_ADMIN_PASSWORD="password"
before_install:
# create the databases needed for the tests
- mysql -e "create database IF NOT EXISTS $DB_NAME;" -uroot
- mysql -e "create database IF NOT EXISTS $TEST_DB_NAME;" -uroot
# tweak git to correctly work with submodules
- sed -i 's/[email protected]:/git:\/\/github.com\//' .gitmodules
- git submodule update --init
- git submodule foreach --recursive "[ -f .gitmodules ] && sed -i 's/[email protected]:/git:\/\/github.com\//' .gitmodules; git submodule update --init;"
install:
# disable XDebug to speed up the tests
- phpenv config-rm xdebug.ini
before_script:
# set up folders
- mkdir -p /tmp/tools $WP_ROOT_FOLDER
# get the current branch name from Travis
- export CURRENT_BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) && echo "Current branch is $CURRENT_BRANCH"
# install wp-cli
- wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P /tmp/tools/
- chmod +x /tmp/tools/wp-cli.phar && mv /tmp/tools/wp-cli.phar /tmp/tools/wp
- export PATH=$PATH:/tmp/tools:vendor/bin
# install WordPress in the `wordpress` folder
- cd $WP_ROOT_FOLDER
- wp core download --version=$WP_VERSION
- wp config create --dbname="$DB_NAME" --dbuser="root" --dbpass="" --dbhost="127.0.0.1" --dbprefix="$WP_TABLE_PREFIX"
- wp core install --url="$WP_URL" --title="TEC Tests" --admin_user="$WP_ADMIN_USERNAME" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="[email protected]" --skip-email
# clone The Events Calendar in the plugins folder
- cd ${WP_ROOT_FOLDER}/wp-content/plugins
- git clone --branch=master https://github.com/the-events-calendar/the-events-calendar.git the-events-calendar
- cd the-events-calendar
- git fetch
# if the plugin has the current branch as a remote use that
- export HAS_BRANCH=0 && if [ $CURRENT_BRANCH ]; then export HAS_BRANCH=$(git branch -r | grep -c ${CURRENT_BRANCH}); fi
- if [ ${HAS_BRANCH} -eq 1 ]; then export TEC_BRANCH=${CURRENT_BRANCH} && echo "Current branch exists in repository - ${CURRENT_BRANCH}"; fi
- export HAS_TRAVIS_BRANCH=0 && if [ $TRAVIS_BRANCH ]; then export HAS_TRAVIS_BRANCH=$(git branch -r | grep -c ${TRAVIS_BRANCH}); fi
- if [ ${HAS_TRAVIS_BRANCH} -eq 1 ]; then export TEC_BRANCH=${TRAVIS_BRANCH} && echo "Travis branch exists in repository - $TRAVIS_BRANCH"; fi
# allow a TEC build branch to override the branch
- if [ ${TEC_BUILD_BRANCH} ]; then export TEC_BRANCH=${TEC_BUILD_BRANCH} && echo "Found TEC branch - ${TEC_BRANCH}" ; fi
- if [ ${TEC_BRANCH} ]; then git checkout ${TEC_BRANCH}; fi
- git branch -l
- sed -i 's/[email protected]:/git:\/\/github.com\//' .gitmodules
- git submodule update --init
- git submodule foreach --recursive "[ -f .gitmodules ] && sed -i 's/[email protected]:/git:\/\/github.com\//' .gitmodules; git submodule update --init;"
- composer dump-autoload --no-dev -a
# Copy the Dependency Test plugin in the plugins folder.
- cp -r ${TRAVIS_BUILD_DIR}/tests/_data/dependency/dependency-test ${WP_ROOT_FOLDER}/wp-content/plugins
- ls -la ${WP_ROOT_FOLDER}/wp-content/plugins/dependency-test
# get back to the build folder
- cd $TRAVIS_BUILD_DIR
# spin up the PHP server in background
- nohup php -S ${WP_DOMAIN} -t ${WP_ROOT_FOLDER} > phpd.log 2>&1 &
# Setup the dependency test dump
- cd $WP_ROOT_FOLDER
- wp rewrite structure '/%postname%/' --hard
- wp core update-db
- wp plugin deactivate --all
# Pull the correct common branch we are testing.
- export PLUGIN_DIR="$WP_ROOT_FOLDER/wp-content/plugins/the-events-calendar/common"
- cd $PLUGIN_DIR
# Reset HARD first to avoid changes we might have done while updating TEC stopping the checkout.
- git reset HEAD --hard && git checkout origin/$CURRENT_BRANCH
- composer install
# get to the common dir
- cd $PLUGIN_DIR
# Generate a dependency-test dedicated dump
- wp db export ${PLUGIN_DIR}/tests/_data/dependency-dump.sql
script:
- codecept run unit
- codecept run integration
- codecept run wpunit
- codecept run muwpunit
- codecept run dependency
- codecept run snapshots