Skip to content

Commit 0d5c202

Browse files
authored
Merge pull request #139 from Codeinwp/development
Improved UI of the builder. Added compatibility with the new options in the pro version. Added new travis stack. Added optin for tracking.
2 parents 65acbd7 + 6381363 commit 0d5c202

35 files changed

+2586
-1120
lines changed

.distignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ phpcs.xml
99
node_modules
1010
logs
1111
package.json
12-
npm-debug.log
12+
bin
13+
tests
14+
phpunit.xml
15+
npm-debug.log
16+
dist
17+
artifact
18+
composer

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.idea
22
node_modules
33
logs
4-
4+
dist
5+
artifact
6+
vendor
7+
composer.lock

.travis.yml

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
language: php
2-
3-
## PHP versions to test against
42
php:
53
- "7.0"
64
- "5.6"
@@ -9,37 +7,58 @@ php:
97
- "5.3"
108
- "5.2"
119
sudo: false
10+
branches:
11+
except:
12+
- "/^*-v[0-9]/"
1213
env:
13-
- WP_VERSION=master WP_MULTISITE=0
14+
matrix:
15+
- WP_VERSION=latest WP_MULTISITE=0
16+
global:
17+
- MASTER_BRANCH=production UPSTREAM_REPO=Codeinwp/visualizer STORE_URL=https://themeisle.com
1418
install:
15-
- . $HOME/.nvm/nvm.sh
16-
- nvm install stable
17-
- nvm use stable
18-
- npm install
19-
- npm install grunt-cli -g
20-
before_script:
21-
## Install the wordpress latest version
22-
- export WP_DEVELOP_DIR=/tmp/wordpress/
23-
- mkdir -p $WP_DEVELOP_DIR
24-
- git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ $WP_DEVELOP_DIR
25-
- plugin_slug=$(basename $(pwd))
26-
- plugin_dir=$WP_DEVELOP_DIR/src/wp-content/plugins/$plugin_slug
27-
- cd ..
28-
- mv $plugin_slug $plugin_dir
29-
- cd $WP_DEVELOP_DIR
30-
- cp wp-tests-config-sample.php wp-tests-config.php
31-
- sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php
32-
- sed -i "s/yourusernamehere/root/" wp-tests-config.php
33-
- sed -i "s/yourpasswordhere//" wp-tests-config.php
34-
- mysql -e 'CREATE DATABASE wordpress_test;' -uroot
35-
36-
## install PHPCS and Wordpress standards
37-
- pear install pear/PHP_CodeSniffer
38-
- mkdir wordpress-coding-standards && curl -L https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/master.tar.gz | tar xz --strip-components=1 -C wordpress-coding-standards
39-
- phpenv rehash
40-
- phpcs --config-set installed_paths $WP_DEVELOP_DIR/wordpress-coding-standards
41-
- phpenv rehash
42-
- cd $plugin_dir
43-
19+
- chmod +x bin/install-dependencies.sh
20+
- ". ./bin/install-dependencies.sh"
4421
script:
45-
grunt travis
22+
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then grunt travis; fi;
23+
before_deploy:
24+
- chmod +x bin/prepare-deploy.sh
25+
- ". ./bin/prepare-deploy.sh"
26+
deploy:
27+
- provider: s3
28+
access_key_id: "$AWS_ACCESS_KEY"
29+
secret_access_key: "$AWS_SECRET_KEY"
30+
bucket: "$AWS_BUCKET"
31+
skip_cleanup: true
32+
acl: public_read
33+
overwrite: true
34+
local-dir: artifact/
35+
upload-dir: "$AWS_PRODUCTS_FOLDER/$THEMEISLE_REPO/latest"
36+
on:
37+
branch: "$MASTER_BRANCH"
38+
repo: "$UPSTREAM_REPO"
39+
condition: $TRAVIS_PHP_VERSION = "7.0"
40+
- provider: s3
41+
access_key_id: "$AWS_ACCESS_KEY"
42+
secret_access_key: "$AWS_SECRET_KEY"
43+
bucket: "$AWS_BUCKET"
44+
skip_cleanup: true
45+
acl: public_read
46+
overwrite: true
47+
local-dir: artifact/
48+
upload-dir: "$AWS_PRODUCTS_FOLDER/$THEMEISLE_REPO/$THEMEISLE_VERSION"
49+
on:
50+
repo: "$UPSTREAM_REPO"
51+
branch: "$MASTER_BRANCH"
52+
condition: $TRAVIS_PHP_VERSION = "7.0"
53+
- provider: releases
54+
api_key: "$GITHUB_TOKEN"
55+
file: artifact/$THEMEISLE_REPO.zip
56+
skip_cleanup: true
57+
on:
58+
tags: false
59+
repo: "$UPSTREAM_REPO"
60+
branch: "$MASTER_BRANCH"
61+
condition: $TRAVIS_PHP_VERSION = "7.0"
62+
after_deploy:
63+
- chmod +x bin/deploy.sh
64+
- ". ./bin/deploy.sh"

bin/deploy.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
# We run this just one time, for a first job from the buid and just at once after_deploy hook.
4+
if ! [ $AFTER_DEPLOY_RUN ] && [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then
5+
6+
# Flag the run in order to not be trigged again on the next after_deploy.
7+
export AFTER_DEPLOY_RUN=1;
8+
echo " Started deploy script. ";
9+
10+
# Setup git username and email.
11+
12+
git config user.name "selul"
13+
git config user.email ${GITHUB_EMAIL}
14+
15+
# Send changelog changes to git.
16+
git checkout $MASTER_BRANCH
17+
git add -v .
18+
19+
# We use [skip ci] in message to prevent this commit to trigger the build.
20+
git commit -a -m "[AUTO][skip ci] Updating changelog for v"$THEMEISLE_VERSION
21+
git push --quiet "https://${GITHUB_TOKEN}@github.com/$UPSTREAM_REPO.git" HEAD:$MASTER_BRANCH
22+
23+
# Tag the new release.
24+
git tag -a "v$THEMEISLE_VERSION" -m "[AUTO] Release of $THEMEISLE_VERSION ";
25+
git push --quiet "https://${GITHUB_TOKEN}@github.com/$UPSTREAM_REPO.git" --tags ;
26+
sleep 5;
27+
28+
# Sends the api call for creating the release.
29+
# We use this as the travis release provider does not offer any way
30+
# to set the body of the release.
31+
API_JSON='{"tag_name": "v'$THEMEISLE_VERSION'","target_commitish": "'$MASTER_BRANCH'","name": "v'$THEMEISLE_VERSION'","body": "'$CHANGES'","draft": false,"prerelease": false}';
32+
curl -s --data "$API_JSON" "https://api.github.com/repos/$UPSTREAM_REPO/releases?access_token="$GITHUB_TOKEN > /dev/null;
33+
34+
# Send update to the store
35+
STORE_JSON='{"version": "'$THEMEISLE_VERSION'","id": "'$THEMEISLE_ID'","body": "'$CHANGES'"}';
36+
curl -s -H "Content-Type: application/json" -H "x-themeisle-auth: $THEMEISLE_AUTH" --data "$STORE_JSON" "$STORE_URL/wp-json/ti-endpoint/v1/update_changelog_new/" > /dev/null
37+
38+
# Send data to demo server.
39+
grunt sftp
40+
41+
# Upload to Wordpress SVN
42+
if [ ! -z "$WP_ORG_PASSWORD" ]; then
43+
44+
svn co -q "http://svn.wp-plugins.org/$THEMEISLE_REPO" svn
45+
46+
# Copy new content to svn trunk.
47+
rsync -r -p dist/* svn/trunk
48+
49+
# Create new SVN tag.
50+
mkdir -p svn/tags/$THEMEISLE_VERSION
51+
rsync -r -p dist/* svn/tags/$THEMEISLE_VERSION
52+
53+
# Add new files to SVN
54+
svn stat svn | grep '^?' | awk '{print $2}' | xargs -I x svn add x@
55+
# Remove deleted files from SVN
56+
svn stat svn | grep '^!' | awk '{print $2}' | xargs -I x svn rm --force x@
57+
58+
svn stat svn
59+
60+
# Commit to SVN
61+
svn ci --no-auth-cache --username $WPORG_USER --password $WPORG_PASS svn -m "Release v$THEMEISLE_VERSION"
62+
63+
fi
64+
65+
fi;

bin/install-dependencies.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# We run this on PR or on push to MASTER_BRANCH.
4+
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || ( [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$TRAVIS_REPO_SLUG" == "$UPSTREAM_REPO" ] && [ "$TRAVIS_BRANCH" == "$MASTER_BRANCH" ] ) ; then
5+
6+
. $HOME/.nvm/nvm.sh
7+
nvm install stable
8+
nvm use stable
9+
10+
npm install
11+
npm install grunt-cli -g
12+
13+
phpenv local 5.6
14+
15+
composer selfupdate 1.0.0 --no-interaction
16+
composer install --no-interaction
17+
phpenv local --unset
18+
19+
fi;
20+
# We dont install PHPCS if is not a PR.
21+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
22+
23+
# Install PHPCS.
24+
pear install pear/PHP_CodeSniffer
25+
26+
# Install WPCS standards.
27+
git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $HOME/wordpress-coding-standards
28+
phpenv rehash
29+
phpcs --config-set installed_paths $HOME/wordpress-coding-standards
30+
phpenv rehash
31+
32+
# Install wordpress for testing.
33+
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
34+
export PATH="$HOME/.composer/vendor/bin:$PATH"
35+
36+
# Use phpunit 5.7 as WP dont support 6.
37+
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
38+
composer global require "phpunit/phpunit=5.7.*" ;
39+
fi;
40+
fi;

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+
4+
if [ $# -lt 3 ]; then
5+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [force download]"
6+
exit 1
7+
fi
8+
9+
DB_NAME=$1
10+
DB_USER=$2
11+
DB_PASS=$3
12+
DB_HOST=${4-localhost}
13+
WP_VERSION=${5-latest}
14+
FORCE=${6-false}
15+
16+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
17+
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
18+
19+
download() {
20+
if [ `which curl` ]; then
21+
curl -s "$1" > "$2";
22+
elif [ `which wget` ]; then
23+
wget -nv -O "$2" "$1"
24+
fi
25+
}
26+
27+
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
28+
WP_TESTS_TAG="tags/$WP_VERSION"
29+
else
30+
# http serves a single offer, whereas https serves multiple. we only want one
31+
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
32+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
33+
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
34+
if [[ -z "$LATEST_VERSION" ]]; then
35+
echo "Latest WordPress version could not be found"
36+
exit 1
37+
fi
38+
WP_TESTS_TAG="tags/$LATEST_VERSION"
39+
fi
40+
41+
if [[ $WP_TESTS_TAG == *"beta"* ]]
42+
then
43+
WP_TESTS_TAG="trunk"
44+
fi
45+
46+
set -ex
47+
48+
install_wp() {
49+
if [ $FORCE == 'true' ]; then
50+
rm -Rf $WP_CORE_DIR
51+
fi
52+
53+
if [ -d $WP_CORE_DIR ]; then
54+
return;
55+
fi
56+
57+
mkdir -p $WP_CORE_DIR
58+
59+
if [ $WP_VERSION == 'latest' ]; then
60+
local ARCHIVE_NAME='latest'
61+
else
62+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
63+
fi
64+
65+
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
66+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
67+
68+
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
69+
}
70+
71+
install_test_suite() {
72+
if [ $FORCE == 'true' ]; then
73+
rm -Rf $WP_TESTS_DIR
74+
fi
75+
76+
# portable in-place argument for both GNU sed and Mac OSX sed
77+
if [[ $(uname -s) == 'Darwin' ]]; then
78+
local ioption='-i .bak'
79+
else
80+
local ioption='-i'
81+
fi
82+
83+
# set up testing suite if it doesn't yet exist
84+
if [ ! -d $WP_TESTS_DIR ]; then
85+
# set up testing suite
86+
mkdir -p $WP_TESTS_DIR
87+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
88+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
89+
fi
90+
91+
cd $WP_TESTS_DIR
92+
93+
if [ ! -f wp-tests-config.php ]; then
94+
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
95+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
96+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
97+
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
98+
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
99+
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
100+
fi
101+
102+
}
103+
104+
install_db() {
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)