Commit 903f29b9 authored by Erick Hitter's avatar Erick Hitter

Merge branch 'add/gitlab-ci' into 'master'

Add GitLab CI

Closes #2

See merge request !1
parents 7721e2cf 3794862a
Pipeline #116 passed with stage
in 11 minutes and 34 seconds
.DS_Store
phpcs.xml
phpunit.xml
Thumbs.db
wp-cli.local.yml
......
variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: wordpress_tests
MYSQL_ROOT_PASSWORD: mysql
cache:
paths:
- $HOME/.composer
before_script:
# Install dependencies
# update the docker
- apt-get clean
- apt-get -yqq update
# install the required packages for the running CI tests
- |
apt-get -yqqf install lsb-release zip unzip subversion mysql-client libicu-dev libpng-dev libbz2-dev --fix-missing
if [[ $(lsb_release -a) =~ "stretch" ]]; then
apt-get -yqqf install default-libmysqlclient-dev --fix-missing
else
apt-get -yqqf install libmysqlclient-dev --fix-missing
fi
# PHP extensions
- docker-php-ext-install mbstring mysqli intl gd zip bz2
- docker-php-ext-enable mbstring mysqli intl gd zip bz2
# Install Composer
- curl -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- export PATH="$HOME/.composer/vendor/bin:$PATH"
# Set up WordPress tests
- bash bin/install-wp-tests.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD mysql latest true
# PHPUnit
- |
if [[ $(php -v) =~ "PHP 7." ]]; then
composer global require "phpunit/phpunit=6.1.*"
else
composer global require "phpunit/phpunit=4.8.*"
fi
# Install PHPCS and WPCS
- composer global require automattic/vipwpcs
- phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs
PHPunit:PHP5.3:MySQL:
image: tetraweb/php:5.3
services:
- mysql:5.6
script:
- phpcs -n
- phpunit
allow_failure: true
PHPunit:PHP5.6:MySQL:
image: php:5.6-stretch
services:
- mysql:5.6
script:
- phpcs -n
- phpunit
PHPunit:PHP7.0:MySQL:
image: php:7.0-stretch
services:
- mysql:5.6
script:
- phpcs -n
- phpunit
PHPunit:PHP7.1:MySQL:
image: php:7.1-stretch
services:
- mysql:5.6
script:
- phpcs -n
- phpunit
PHPunit:PHP7.2:MySQL:
image: php:7.2-stretch
services:
- mysql:5.6
script:
- phpcs -n
- phpunit
......@@ -46,8 +46,8 @@ before_script:
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
composer global require automattic/vipwpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs
fi
script:
......
......@@ -95,7 +95,7 @@ install_wp() {
install_test_suite() {
# portable in-place argument for both GNU sed and Mac OSX sed
if [[ $(uname -s) == 'Darwin' ]]; then
local ioption='-i .bak'
local ioption='-i.bak'
else
local ioption='-i'
fi
......
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>
<!--
Pass some flags to PHPCS:
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
-->
<arg value="ps" />
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./" />
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8" />
<!-- Only check the PHP files. -->
<arg name="extensions" value="php" />
<!-- Check all files in this directory and the directories below it. -->
<file>.</file>
<!-- Exclude a few directories and autogenerated files. -->
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/</exclude-pattern>
<rule ref="WordPress" />
<rule ref="WordPressVIPMinimum" />
<!--<rule ref="WordPress-VIP-Go" />-->
<config name="minimum_supported_wp_version" value="4.9" />
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="camo" />
</properties>
</rule>
</ruleset>
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>
<rule ref="WordPress-Core" />
<rule ref="WordPress-Docs" />
<!-- Check all PHP files in directory tree by default. -->
<arg name="extensions" value="php"/>
<file>.</file>
<!-- Show progress and sniff codes in all reports -->
<arg value="ps"/>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
</ruleset>
......@@ -5,27 +5,27 @@
* @package Camo_Image_Proxy
*/
$_tests_dir = getenv( 'WP_TESTS_DIR' );
$camo_tests_dir = getenv( 'WP_TESTS_DIR' );
if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
if ( ! $camo_tests_dir ) {
$camo_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
}
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL;
if ( ! file_exists( $camo_tests_dir . '/includes/functions.php' ) ) {
echo "Could not find $camo_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit( 1 );
}
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
require_once $camo_tests_dir . '/includes/functions.php';
/**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
function camo_manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/camo-image-proxy.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
tests_add_filter( 'muplugins_loaded', 'camo_manually_load_plugin' );
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';
require $camo_tests_dir . '/includes/bootstrap.php';
......@@ -13,7 +13,7 @@ class SampleTest extends WP_UnitTestCase {
/**
* A single example test.
*/
function test_sample() {
public function test_sample() {
// Replace this with some actual testing code.
$this->assertTrue( true );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment