Skip to content

Commit

Permalink
Composer install flow (#10)
Browse files Browse the repository at this point in the history
* Add composer dep

* Update composer.json file and grunt build

* Restore default lib path

* Update BFAL include

* Update readme

* Build

* Alias unit test class

* Switch to dist: trusty

* Add test suite

* Build

* Update includes

* Fix travisf file

* Add missing script

* Remove phpunit

* Temp comment out PHPCS
  • Loading branch information
MickeyKay authored Jun 5, 2017
1 parent ac22fb9 commit 70dc964
Show file tree
Hide file tree
Showing 16 changed files with 1,264 additions and 109 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "lib/better-font-awesome-library"]
path = lib/better-font-awesome-library
url = https://github.com/MickeyKay/better-font-awesome-library.git
branch = master
65 changes: 58 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,61 @@
sudo: false

language: php

php:
- 7.0
- 5.6
- 5.5
- 5.4
- hhvm
notifications:
email:
on_success: never
on_failure: change

branches:
only:
- master

cache:
- composer
- $HOME/.composer/cache

matrix:
include:
- php: 7.1
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=4.4
- php: 5.6
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=trunk
# - php: 5.6
# env: WP_TRAVISCI=phpcs
- php: 5.3
env: WP_VERSION=latest

script: phpunit ./tests/test-base.php
before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- composer install
- |
if [[ ! -z "$WP_VERSION" ]] ; then
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
composer global require "phpunit/phpunit=5.7.*"
else
composer global require "phpunit/phpunit=4.8.*"
fi
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
fi
script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php')
fi
17 changes: 13 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ module.exports = function( grunt ) {
},
},
copy: {
composerDeps: {
src: [
'vendor/mickey-kay/**'
],
dest: 'svn/trunk/'
},
svnAssets: {
cwd: 'assets/',
src: ['**'],
Expand All @@ -96,21 +102,22 @@ module.exports = function( grunt ) {
src: [
'**',
'!node_modules/**',
'!vendor/**',
'!svn/**',
'!.git/**',
'!.gitignore',
'!.gitmodules',
'!.sass-cache/**',
'!bin/**',
'!tests/**',
'!css/src/**',
'!js/src/**',
'!img/src/**',
'!assets/**',
'!design/**',
'!Gruntfile.js',
'!package.json',
'!.gitignore',
'!.gitmodules',
'!composer*',
'!vendor/autoload.php',
'!vendor/composer/**'
],
dest: 'svn/trunk/',
},
Expand All @@ -131,5 +138,7 @@ module.exports = function( grunt ) {
'copy'
] );

grunt.registerTask( 'default', 'build' );

grunt.util.linefeed = '\n';
};
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Better Font Awesome #
**Contributors:** [McGuive7](https://profiles.wordpress.org/McGuive7), [MIGHTYminnow](https://profiles.wordpress.org/MIGHTYminnow)
**Contributors:** [McGuive7](https://profiles.wordpress.org/McGuive7)
**Tags:** better, font, awesome, icon, icons, bootstrap, fontstrap, cdn, shortcode
**Donate link:** http://mightyminnow.com
**Donate link:** http://mickeykay.me
**Requires at least:** 3.0
**Tested up to:** 4.6
**Stable tag:** 1.6.0
**Tested up to:** 4.9
**Stable tag:** 1.7.0
**License:** GPLv2+
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -111,6 +111,10 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,

## Changelog ##

### 1.7.0 ###
* Update fallback Font Awesome to v4.7.0.
* Switch from using git submodules to composer dependency management for core library inclusion.

### 1.6.0 ###
* Update fallback Font Awesome to v4.6.3.

Expand Down Expand Up @@ -231,6 +235,10 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,

## Upgrade Notice ##

### 1.7.0 ###
* Update fallback Font Awesome to v4.7.0.
* Switch from using git submodules to composer dependency management for core library inclusion.

### 1.6.0 ###
* Update fallback Font Awesome to v4.6.3.

Expand Down
29 changes: 21 additions & 8 deletions better-font-awesome.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
* Better Font Awesome
*
* @package Better Font Awesome
* @author Mickey Kay & MIGHTYminnow <[email protected]>
* @author Mickey Kay <mickeykay.me>
* @license GPL-2.0+
* @link http://wordpress.org/plugins/better-font-awesome
* @copyright 2014 MIGHTYminnow & Mickey Kay
* @copyright 2017 Mickey Kay
*
* @wordpress-plugin
* Plugin Name: Better Font Awesome
* Plugin URI: http://wordpress.org/plugins/better-font-awesome
* Description: The ultimate Font Awesome icon plugin for WordPress.
* Version: 1.6.0
* Author: MIGHTYminnow & Mickey Kay
* Author URI: mickey@mickeykaycreative.com
* Version: 1.7.0
* Author: Mickey Kay
* Author URI: mickeyskay@gmail.com
* License: GPLv2+
* Text Domain: better-font-awesome
* Domain Path: /languages
Expand Down Expand Up @@ -189,19 +189,32 @@ private function initialize() {
$this->option_name = self::SLUG . '_options';

// Set up main Better Font Awesome Library file path.
$this->bfa_lib_file_path = plugin_dir_path( __FILE__ ) . 'lib/better-font-awesome-library/better-font-awesome-library.php';
$this->bfa_lib_file_path = plugin_dir_path( __FILE__ ) . 'vendor/mickey-kay/better-font-awesome-library/better-font-awesome-library.php';

// Get plugin options, and populate defaults as needed.
$this->initialize_options( $this->option_name );

}

/**
* Get class prop.
*
* @since 1.7.0
*
* @param string $prop Prop to fetch.
*
* @return mixed Value of the prop.
*/
public function get( $prop ) {
return $this->$prop;
}

/**
* Check if the Better Font Awesome Library is included.
*
* @since 0.10.0
*/
private function bfal_exists() {
public function bfal_exists() {

if ( ! is_readable( $this->bfa_lib_file_path ) ) {
return false;
Expand All @@ -221,7 +234,7 @@ public function deactivate() {
deactivate_plugins( plugin_basename( __FILE__ ) );

$message = '<h2>' . __( 'Better Font Awesome', 'better-font-awesome' ) . '</h2>';
$message .= '<p>' . __( 'It appears that Better Font Awesome is missing it\'s <a href="https://github.com/MickeyKay/better-font-awesome-library" target="_blank">core library</a>, which typically occurs when cloning the Git repository and not updating all submodules. Please refer to the plugin\'s <a href="https://github.com/MickeyKay/better-font-awesome" target="_blank">installation instructions</a> for details on how to properly install Better Font Awesome via Git. If you installed from within WordPress, or via the wordpress.org repo, then chances are the install failed and you can try again. If the issue persists, please create a new topic on the plugin\'s <a href="http://wordpress.org/support/plugin/better-font-awesome" target="_blank">support forum</a> or file an issue on the <a href="https://github.com/MickeyKay/better-font-awesome/issues" target="_blank">Github repo</a>.' , 'better-font-awesome' ) . '</p>';
$message .= '<p>' . __( 'It appears that Better Font Awesome is missing it\'s <a href="https://github.com/MickeyKay/better-font-awesome-library" target="_blank">core library</a>, which typically occurs when cloning the Git repository and failing to run <code>composer install</code>. Please refer to the plugin\'s <a href="https://github.com/MickeyKay/better-font-awesome" target="_blank">installation instructions</a> for details on how to properly install Better Font Awesome via Git. If you installed from within WordPress, or via the wordpress.org repo, then chances are the install failed and you can try again. If the issue persists, please create a new topic on the plugin\'s <a href="http://wordpress.org/support/plugin/better-font-awesome" target="_blank">support forum</a> or file an issue on the <a href="https://github.com/MickeyKay/better-font-awesome/issues" target="_blank">Github repo</a>.' , 'better-font-awesome' ) . '</p>';
$message .= '<p><a href="' . get_admin_url( null, 'plugins.php' ) . '">' . __( 'Back to the plugins page &rarr;', 'better-font-awesome' ) . '</a></p>';

wp_die( $message );
Expand Down
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] [skip-database-creation]"
exit 1
fi

DB_NAME=$1
DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${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"
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
WP_TESTS_TAG="trunk"
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

set -ex

install_wp() {

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

mkdir -p $WP_CORE_DIR

if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
mkdir -p /tmp/wordpress-nightly
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
else
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
fi

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

install_test_suite() {
# 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

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
# remove all forward slashes in the end
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
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() {

if [ ${SKIP_DB_CREATE} = "true" ]; then
return 0
fi

# 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
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"require": {

}
}
"name": "mickey-kay/better-font-awesome",
"description": "Better Font Awesome",
"license": "GPL-2.0",
"require": {
"mickey-kay/better-font-awesome-library": "1.4.6"
}
}
Loading

0 comments on commit 70dc964

Please sign in to comment.