Skip to content

Commit

Permalink
Merge pull request #139 from Codeinwp/development
Browse files Browse the repository at this point in the history
Improved UI of the builder. 
Added compatibility with the new options in the pro version.
Added new travis stack. 
Added optin for tracking.
  • Loading branch information
selul authored Apr 13, 2017
2 parents 65acbd7 + 6381363 commit 0d5c202
Show file tree
Hide file tree
Showing 35 changed files with 2,586 additions and 1,120 deletions.
8 changes: 7 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ phpcs.xml
node_modules
logs
package.json
npm-debug.log
bin
tests
phpunit.xml
npm-debug.log
dist
artifact
composer
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.idea
node_modules
logs

dist
artifact
vendor
composer.lock
85 changes: 52 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
language: php

## PHP versions to test against
php:
- "7.0"
- "5.6"
Expand All @@ -9,37 +7,58 @@ php:
- "5.3"
- "5.2"
sudo: false
branches:
except:
- "/^*-v[0-9]/"
env:
- WP_VERSION=master WP_MULTISITE=0
matrix:
- WP_VERSION=latest WP_MULTISITE=0
global:
- MASTER_BRANCH=production UPSTREAM_REPO=Codeinwp/visualizer STORE_URL=https://themeisle.com
install:
- . $HOME/.nvm/nvm.sh
- nvm install stable
- nvm use stable
- npm install
- npm install grunt-cli -g
before_script:
## Install the wordpress latest version
- export WP_DEVELOP_DIR=/tmp/wordpress/
- mkdir -p $WP_DEVELOP_DIR
- git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ $WP_DEVELOP_DIR
- plugin_slug=$(basename $(pwd))
- plugin_dir=$WP_DEVELOP_DIR/src/wp-content/plugins/$plugin_slug
- cd ..
- mv $plugin_slug $plugin_dir
- cd $WP_DEVELOP_DIR
- cp wp-tests-config-sample.php wp-tests-config.php
- sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php
- sed -i "s/yourusernamehere/root/" wp-tests-config.php
- sed -i "s/yourpasswordhere//" wp-tests-config.php
- mysql -e 'CREATE DATABASE wordpress_test;' -uroot

## install PHPCS and Wordpress standards
- pear install pear/PHP_CodeSniffer
- 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
- phpenv rehash
- phpcs --config-set installed_paths $WP_DEVELOP_DIR/wordpress-coding-standards
- phpenv rehash
- cd $plugin_dir

- chmod +x bin/install-dependencies.sh
- ". ./bin/install-dependencies.sh"
script:
grunt travis
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then grunt travis; fi;
before_deploy:
- chmod +x bin/prepare-deploy.sh
- ". ./bin/prepare-deploy.sh"
deploy:
- provider: s3
access_key_id: "$AWS_ACCESS_KEY"
secret_access_key: "$AWS_SECRET_KEY"
bucket: "$AWS_BUCKET"
skip_cleanup: true
acl: public_read
overwrite: true
local-dir: artifact/
upload-dir: "$AWS_PRODUCTS_FOLDER/$THEMEISLE_REPO/latest"
on:
branch: "$MASTER_BRANCH"
repo: "$UPSTREAM_REPO"
condition: $TRAVIS_PHP_VERSION = "7.0"
- provider: s3
access_key_id: "$AWS_ACCESS_KEY"
secret_access_key: "$AWS_SECRET_KEY"
bucket: "$AWS_BUCKET"
skip_cleanup: true
acl: public_read
overwrite: true
local-dir: artifact/
upload-dir: "$AWS_PRODUCTS_FOLDER/$THEMEISLE_REPO/$THEMEISLE_VERSION"
on:
repo: "$UPSTREAM_REPO"
branch: "$MASTER_BRANCH"
condition: $TRAVIS_PHP_VERSION = "7.0"
- provider: releases
api_key: "$GITHUB_TOKEN"
file: artifact/$THEMEISLE_REPO.zip
skip_cleanup: true
on:
tags: false
repo: "$UPSTREAM_REPO"
branch: "$MASTER_BRANCH"
condition: $TRAVIS_PHP_VERSION = "7.0"
after_deploy:
- chmod +x bin/deploy.sh
- ". ./bin/deploy.sh"
65 changes: 65 additions & 0 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

# We run this just one time, for a first job from the buid and just at once after_deploy hook.
if ! [ $AFTER_DEPLOY_RUN ] && [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then

# Flag the run in order to not be trigged again on the next after_deploy.
export AFTER_DEPLOY_RUN=1;
echo " Started deploy script. ";

# Setup git username and email.

git config user.name "selul"
git config user.email ${GITHUB_EMAIL}

# Send changelog changes to git.
git checkout $MASTER_BRANCH
git add -v .

# We use [skip ci] in message to prevent this commit to trigger the build.
git commit -a -m "[AUTO][skip ci] Updating changelog for v"$THEMEISLE_VERSION
git push --quiet "https://${GITHUB_TOKEN}@github.com/$UPSTREAM_REPO.git" HEAD:$MASTER_BRANCH

# Tag the new release.
git tag -a "v$THEMEISLE_VERSION" -m "[AUTO] Release of $THEMEISLE_VERSION ";
git push --quiet "https://${GITHUB_TOKEN}@github.com/$UPSTREAM_REPO.git" --tags ;
sleep 5;

# Sends the api call for creating the release.
# We use this as the travis release provider does not offer any way
# to set the body of the release.
API_JSON='{"tag_name": "v'$THEMEISLE_VERSION'","target_commitish": "'$MASTER_BRANCH'","name": "v'$THEMEISLE_VERSION'","body": "'$CHANGES'","draft": false,"prerelease": false}';
curl -s --data "$API_JSON" "https://api.github.com/repos/$UPSTREAM_REPO/releases?access_token="$GITHUB_TOKEN > /dev/null;

# Send update to the store
STORE_JSON='{"version": "'$THEMEISLE_VERSION'","id": "'$THEMEISLE_ID'","body": "'$CHANGES'"}';
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

# Send data to demo server.
grunt sftp

# Upload to Wordpress SVN
if [ ! -z "$WP_ORG_PASSWORD" ]; then

svn co -q "http://svn.wp-plugins.org/$THEMEISLE_REPO" svn

# Copy new content to svn trunk.
rsync -r -p dist/* svn/trunk

# Create new SVN tag.
mkdir -p svn/tags/$THEMEISLE_VERSION
rsync -r -p dist/* svn/tags/$THEMEISLE_VERSION

# Add new files to SVN
svn stat svn | grep '^?' | awk '{print $2}' | xargs -I x svn add x@
# Remove deleted files from SVN
svn stat svn | grep '^!' | awk '{print $2}' | xargs -I x svn rm --force x@

svn stat svn

# Commit to SVN
svn ci --no-auth-cache --username $WPORG_USER --password $WPORG_PASS svn -m "Release v$THEMEISLE_VERSION"

fi

fi;
40 changes: 40 additions & 0 deletions bin/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# We run this on PR or on push to MASTER_BRANCH.
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || ( [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$TRAVIS_REPO_SLUG" == "$UPSTREAM_REPO" ] && [ "$TRAVIS_BRANCH" == "$MASTER_BRANCH" ] ) ; then

. $HOME/.nvm/nvm.sh
nvm install stable
nvm use stable

npm install
npm install grunt-cli -g

phpenv local 5.6

composer selfupdate 1.0.0 --no-interaction
composer install --no-interaction
phpenv local --unset

fi;
# We dont install PHPCS if is not a PR.
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then

# Install PHPCS.
pear install pear/PHP_CodeSniffer

# Install WPCS standards.
git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $HOME/wordpress-coding-standards
phpenv rehash
phpcs --config-set installed_paths $HOME/wordpress-coding-standards
phpenv rehash

# Install wordpress for testing.
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
export PATH="$HOME/.composer/vendor/bin:$PATH"

# Use phpunit 5.7 as WP dont support 6.
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
composer global require "phpunit/phpunit=5.7.*" ;
fi;
fi;
127 changes: 127 additions & 0 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env bash


if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [force download]"
exit 1
fi

DB_NAME=$1
DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
FORCE=${6-false}

WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}

download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
}

if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
WP_TESTS_TAG="tags/$WP_VERSION"
else
# http serves a single offer, whereas https serves multiple. we only want one
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
if [[ -z "$LATEST_VERSION" ]]; then
echo "Latest WordPress version could not be found"
exit 1
fi
WP_TESTS_TAG="tags/$LATEST_VERSION"
fi

if [[ $WP_TESTS_TAG == *"beta"* ]]
then
WP_TESTS_TAG="trunk"
fi

set -ex

install_wp() {
if [ $FORCE == 'true' ]; then
rm -Rf $WP_CORE_DIR
fi

if [ -d $WP_CORE_DIR ]; then
return;
fi

mkdir -p $WP_CORE_DIR

if [ $WP_VERSION == 'latest' ]; then
local ARCHIVE_NAME='latest'
else
local ARCHIVE_NAME="wordpress-$WP_VERSION"
fi

download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR

download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
}

install_test_suite() {
if [ $FORCE == 'true' ]; then
rm -Rf $WP_TESTS_DIR
fi

# portable in-place argument for both GNU sed and Mac OSX sed
if [[ $(uname -s) == 'Darwin' ]]; then
local ioption='-i .bak'
else
local ioption='-i'
fi

# set up testing suite if it doesn't yet exist
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi

cd $WP_TESTS_DIR

if [ ! -f wp-tests-config.php ]; then
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
fi

}

install_db() {
# parse DB_HOST for port or socket references
local PARTS=(${DB_HOST//\:/ })
local DB_HOSTNAME=${PARTS[0]};
local DB_SOCK_OR_PORT=${PARTS[1]};
local EXTRA=""

if ! [ -z $DB_HOSTNAME ] ; then
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
EXTRA=" --socket=$DB_SOCK_OR_PORT"
elif ! [ -z $DB_HOSTNAME ] ; then
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
fi
fi

# create database
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}

install_wp
install_test_suite
install_db
Loading

0 comments on commit 0d5c202

Please sign in to comment.