Skip to content

Commit

Permalink
Codeception configuration heavily refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Jul 25, 2019
1 parent 0865b03 commit b8c7b10
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 321 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
.github_changelog_generator
.travis.yml
21 changes: 14 additions & 7 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ DB_PASSWORD=wordpress
WP_TABLE_PREFIX=wp_
WP_URL=http://localhost
WP_DOMAIN=localhost
ADMIN_EMAIL=admin@localhost
ADMIN_EMAIL=admin@example.com
ADMIN_USERNAME=admin
ADMIN_PASSWORD=password
ADMIN_PATH=/wp-admin

SKIP_DB_CREATE=false
TEST_WP_ROOT_FOLDER=/tmp/wordpress
TEST_DB_NAME=wpgraphql_woocommerce_test
TEST_DB_NAME=woographql_tests
TEST_DB_HOST=127.0.0.1
TEST_DB_USER=root
TEST_DB_PASSWORD=
TEST_DB_USER=wordpress
TEST_DB_PASSWORD=wordpress
TEST_WP_TABLE_PREFIX=wp_
TEST_SITE_ADMIN_EMAIL=admin@wp.test

SKIP_DB_CREATE=false
TEST_WP_ROOT_FOLDER=/tmp/wordpress
TEST_ADMIN_EMAIL=admin@wp.test

TESTS_DIR=tests
TESTS_OUTPUT=tests/_output
TESTS_DATA=tests/_data
TESTS_SUPPORT=tests/_support
TESTS_ENVS=tests/_envs
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ node_modules/
*.tar.gz
*.zip
.env
.env.*
!.env.dist
.idea
.vscode
.github_changelog_generator
Expand All @@ -17,13 +19,13 @@ vendor/*
!vendor/composer
vendor/composer/installed.json
vendor/composer/*/
!/tests
/tests/*.suite.yml
!tests
tests/*.suite.yml
build/
coverage/*
schema.graphql
phpunit.xml
docker-output
composer.lock
c3.php
.log/
.log/
22 changes: 16 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ env:
- PHP_VERSION=7.1 WP_VERSION=5.2.2
- PHP_VERSION=7.0 WP_VERSION=5.2.2
- PHP_VERSION=5.6 WP_VERSION=4.9
- PHP_VERSION=5.6 WP_VERSION=5.2.2 DEBUG=1
- PHP_VERSION=5.6 WP_VERSION=5.0.2 DEBUG=1

before_install:
- sudo rm /usr/local/bin/docker-compose
Expand Down Expand Up @@ -78,7 +78,10 @@ before_script:
# Install PHP CodeSniffer and WPCS.
- |
if [ "$PHPCS" == "1" ]; then
COMPOSER_MEMORY_LIMIT=-1 travis_retry composer require squizlabs/php_codesniffer phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer
COMPOSER_MEMORY_LIMIT=-1 travis_retry composer require \
squizlabs/php_codesniffer \
phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs \
dealerdirect/phpcodesniffer-composer-installer
COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --no-dev
ls -al
fi
Expand All @@ -87,13 +90,20 @@ script:
# Execute unit tests with coverage if specified, otherwise without coverage
- |
if [ ! -z "$WP_VERSION" ]; then
docker-compose run -e SUITE=functional -e COVERAGE=${COVERAGE:-0} testing --rm testing --scale app=0
docker-compose run -e SUITE=acceptance -e COVERAGE=${COVERAGE:-0} testing --rm testing --scale app=0
docker-compose run -e SUITE=wpunit -e COVERAGE=${COVERAGE:-0} testing --rm testing --scale app=0
declare -a suites=( 'acceptance', 'functional', 'wpunit' )
for i in "${suites[@]}"; do
docker-compose run \
-e SUITE=${i} -e COVERAGE=${COVERAGE:-0} -e DEBUG=${DEBUG:-0} testing \
--rm testing --scale app=0
done
fi
- |
if [ "$PHPCS" == "1" ]; then
vendor/bin/phpcs wp-graphql-woocommerce.php access-functions.php class-inflect.php includes/*.php --standard=WordPress
vendor/bin/phpcs \
wp-graphql-woocommerce.php \
access-functions.php \
class-inflect.php \
includes/*.php --standard=WordPress
fi
after_success:
# Runs Coveralls.io client
Expand Down
69 changes: 26 additions & 43 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,42 @@
###############################################################################
# Pre-configured WordPress Installation w/ WooCommerce, WPGraphQL, WooGraphQL #
# For testing only, use in production not recommended. #
###############################################################################
############################################################################
# Container for running Codeception tests on a WooGraphQL Docker instance. #
############################################################################

# Using the 'DESIRED_' prefix to avoid confusion with environment variables of the same name.
ARG DESIRED_WP_VERSION
ARG DESIRED_PHP_VERSION

FROM wordpress:${DESIRED_WP_VERSION}-php${DESIRED_PHP_VERSION}-apache
FROM kidunot89/woographql-app:wp${DESIRED_WP_VERSION:-5.2.2}-php${DESIRED_PHP_VERSION:-7.3}

LABEL author=kidunot89
LABEL author_uri=https://github.com/kidunot89

SHELL [ "/bin/bash", "-c" ]

# Install system packages
RUN apt-get update && \
apt-get -y install \
# CircleCI depedencies
git \
ssh \
tar \
gzip \
wget \
mariadb-client

# Install Dockerize
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

# Install WP-CLI
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x wp-cli.phar \
&& mv wp-cli.phar /usr/local/bin/wp

# Set project environmental variables
ENV WP_ROOT_FOLDER="/var/www/html"
ENV WORDPRESS_DB_HOST=${DB_HOST}
ENV WORDPRESS_DB_USER=${DB_USER}
ENV WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
ENV WORDPRESS_DB_NAME=${DB_NAME}
ENV PLUGINS_DIR="${WP_ROOT_FOLDER}/wp-content/plugins"
ENV PROJECT_DIR="${PLUGINS_DIR}/wp-graphql-woocommerce"
# Install php extensions
RUN docker-php-ext-install pdo_mysql

# Remove exec statement from base entrypoint script.
RUN sed -i '$d' /usr/local/bin/docker-entrypoint.sh
# Install Xdebug
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini

# Install composer
ENV COMPOSER_ALLOW_SUPERUSER=1

RUN curl -sS https://getcomposer.org/installer | php -- \
--filename=composer \
--install-dir=/usr/local/bin

# Set up Apache
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf
# Add composer global binaries to PATH
ENV PATH "$PATH:~/.composer/vendor/bin"

# Remove exec statement from base entrypoint script.
RUN sed -i '$d' /usr/local/bin/app-entrypoint.sh

# Set up entrypoint
WORKDIR /var/www/html
COPY bin/entrypoint.sh /usr/local/bin/app-entrypoint.sh
RUN chmod 755 /usr/local/bin/app-entrypoint.sh
ENTRYPOINT ["app-entrypoint.sh"]
CMD ["apache2-foreground"]
COPY bin/testing-entrypoint.sh /usr/local/bin/testing-entrypoint.sh
RUN chmod 755 /usr/local/bin/testing-entrypoint.sh
ENTRYPOINT ["testing-entrypoint.sh"]
55 changes: 0 additions & 55 deletions Dockerfile.tester

This file was deleted.

70 changes: 0 additions & 70 deletions bin/entrypoint.sh

This file was deleted.

20 changes: 4 additions & 16 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

export $(cat .env | xargs)
source .env

print_usage_instruction() {
echo "Ensure that .env file exist in project root directory exists."
Expand Down Expand Up @@ -40,7 +40,7 @@ TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
PLUGIN_DIR=$(pwd)
DB_SERVE_NAME=${DB_SERVE_NAME-wpgraphql_serve}
DB_SERVE_NAME=${DB_SERVE_NAME-woographql_serve}

download() {
if [ `which curl` ]; then
Expand Down Expand Up @@ -198,26 +198,14 @@ setup_woocommerce() {
setup_wpgraphql() {
if [ ! -d $WP_CORE_DIR/wp-content/plugins/wp-graphql ]; then
echo "Cloning WPGraphQL"
git clone https://github.com/wp-graphql/wp-graphql.git $WP_CORE_DIR/wp-content/plugins/wp-graphql
wp plugin install https://github.com/wp-graphql/wp-graphql/archive/master.zip
fi

cd $WP_CORE_DIR/wp-content/plugins/wp-graphql
git checkout develop
git pull origin develop

if [ ! -z "$WP_GRAPHQL_BRANCH" ]; then
echo "Checking out WPGraphQL branch - $WP_GRAPHQL_BRANCH"
git checkout --track origin/$WP_GRAPHQL_BRANCH
fi


cd $WP_CORE_DIR
echo "Activating WPGraphQL"
wp plugin activate wp-graphql

if [ ! -d $WP_CORE_DIR/wp-content/plugins/wp-graphql-jwt-authentication ]; then
echo "Cloning WPGraphQL-JWT-Authentication"
git clone https://github.com/wp-graphql/wp-graphql-jwt-authentication.git $WP_CORE_DIR/wp-content/plugins/wp-graphql-jwt-authentication
wp plugin install https://github.com/wp-graphql/wp-graphql-jwt-authentication/archive/master.zip
fi
echo "Activating WPGraphQL-JWT-Authentication"
wp plugin activate wp-graphql-jwt-authentication
Expand Down
Loading

0 comments on commit b8c7b10

Please sign in to comment.