-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
114 lines (101 loc) · 3.56 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
# https://www.theaveragedev.com/installing-and-setting-up-wordpress-and-nginx-for-travis-ci-tests/
language: php
notifications:
email: false
php:
- '7.2'
- nightly
matrix:
fast_finish: true
allow_failures:
- php: nightly
- env: WP_VERSION=nightly
services:
- mysql
cache:
apt: true
directories:
- vendor
- $HOME/.composer/cache/files
addons:
apt:
packages:
- libjpeg-dev
- libpng12-dev
- php7.0-fpm
- php7.0-mysql
- nginx
hosts:
- wp.localhost
env:
global:
- WP_FOLDER="/tmp/wordpress"
- WP_URL="http://wp.localhost"
- WP_DOMAIN="wp.localhost"
- DB_NAME="test"
- TEST_DB_NAME="wploader"
- WP_TABLE_PREFIX="wp_"
- WP_ADMIN_USERNAME="admin"
- WP_ADMIN_PASSWORD="admin"
matrix:
- WP_VERSION=latest
- WP_VERSION=nightly
before_install:
# create the databases that will be used in the tests
- mysql -e "create database IF NOT EXISTS $DB_NAME;" -uroot
- mysql -e "create database IF NOT EXISTS $TEST_DB_NAME;" -uroot
# set up folders
- mkdir -p $WP_FOLDER
- mkdir tools
# install wp-cli in the `tools` folder
- wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P $(pwd)/tools/
- chmod +x tools/wp-cli.phar && mv tools/wp-cli.phar tools/wp
# append the `tools` folder to the PATH
- export PATH=$PATH:$(pwd)/tools
# prepend the `vendor/bin` folder the PATH
- export PATH=vendor/bin:$PATH
install:
- composer install --prefer-dist --ignore-platform-reqs
# install WordPress
- cd $WP_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="Test" --admin_user="$WP_ADMIN_USERNAME" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="admin@$WP_DOMAIN" --skip-email
- wp rewrite structure '/%postname%/' --hard
# update WordPress database to avoid prompts
- wp core update-db
# copy the plugin in the WordPress plugin folder
- cp -r $TRAVIS_BUILD_DIR $WP_FOLDER/wp-content/plugins/settings
# show the plugins folder contents to make sure the plugin folder is there
- ls $WP_FOLDER/wp-content/plugins
# activate the plugin
- wp plugin activate settings
# make sure the plugin is active on the site
- wp plugin list --status=active
# export a dump of the just installed database to the _data folder
- wp db export $TRAVIS_BUILD_DIR/tests/_data/dump.sql
# get back to the build folder
- cd $TRAVIS_BUILD_DIR
# open up the site folder to allow the PHP application to read/write/execute on it
- sudo chmod -R 777 $WP_FOLDER
# copy the Nginx configuration file to the available sites
#- sudo cp build/travis-nginx-conf /etc/nginx/sites-available/$WP_DOMAIN
#- sudo sed -e "s?%WP_FOLDER%?$WP_FOLDER?g" --in-place /etc/nginx/sites-available/$WP_DOMAIN
#- sudo sed -e "s?%WP_DOMAIN%?$WP_DOMAIN?g" --in-place /etc/nginx/sites-available/$WP_DOMAIN
# enable the site
- sudo ln -s /etc/nginx/sites-available/$WP_DOMAIN /etc/nginx/sites-enabled/
before_script:
# restart Nnginx and PHP-FPM services
- sudo service php7.0-fpm restart
- sudo service nginx restart
# build Codeception modules
- codecept build
script:
- find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
- vendor/bin/phpcs --ignore=./tests/_support/* ./src/ ./tests/
- vendor/bin/phpstan analyze --level=4
# - codecept run acceptance
# - codecept run functional
# - codecept run integration
# - codecept run unit
- codecept run wpunit && codecept run unit