Switch to using CircleCI 2.0
We end up using Docker images for PHP 5.6 and MySQL, handle our own Composer and NPM caches.
This commit is contained in:
committed by
pavel-mailpoet
parent
b1425198b6
commit
1ac6dd8ccb
@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/ruby
|
|
||||||
path = "/tmp"
|
|
||||||
Dir.mkdir(path) if !File.exists?(path)
|
|
||||||
File.open("#{path}/mailpoet-#{Time.now.to_f}.txt", "w") do |f|
|
|
||||||
sleep 5
|
|
||||||
f.puts ARGV.inspect
|
|
||||||
$stdin.each_line { |line| f.puts line }
|
|
||||||
end
|
|
@ -1,3 +0,0 @@
|
|||||||
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
|
|
||||||
; http://php.net/sendmail-path
|
|
||||||
sendmail_path = /home/ubuntu/mailpoet/.circle_ci/fake-sendmail.rb
|
|
@ -3,11 +3,11 @@ Listen 8080
|
|||||||
<VirtualHost *:8080>
|
<VirtualHost *:8080>
|
||||||
UseCanonicalName Off
|
UseCanonicalName Off
|
||||||
ServerName mailpoet.loc
|
ServerName mailpoet.loc
|
||||||
DocumentRoot /home/ubuntu/mailpoet/wordpress
|
DocumentRoot /home/circleci/mailpoet/wordpress
|
||||||
DirectoryIndex index.php
|
DirectoryIndex index.php
|
||||||
LogLevel notice
|
LogLevel notice
|
||||||
|
|
||||||
<Directory /home/ubuntu/mailpoet/wordpress>
|
<Directory /home/circleci/mailpoet/wordpress>
|
||||||
Require all granted
|
Require all granted
|
||||||
</Directory>
|
</Directory>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
91
.circleci/config.yml
Normal file
91
.circleci/config.yml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
working_directory: ~/mailpoet
|
||||||
|
docker:
|
||||||
|
- image: circleci/php:5.6.30-apache-browsers
|
||||||
|
- image: circleci/mysql:5.7
|
||||||
|
environment:
|
||||||
|
TZ: /usr/share/zoneinfo/Etc/UTC
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: "Set up virtual host"
|
||||||
|
command: echo 127.0.0.1 mailpoet.loc | sudo tee -a /etc/hosts
|
||||||
|
- restore_cache:
|
||||||
|
key: composer-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
|
||||||
|
- restore_cache:
|
||||||
|
key: npm-{{ checksum "package.json" }}
|
||||||
|
- run:
|
||||||
|
name: "Set up test environment"
|
||||||
|
command: |
|
||||||
|
# install PHP dependencies for WordPress
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install mysql-client php5-mysql zlib1g-dev
|
||||||
|
sudo docker-php-ext-install mysql mysqli pdo pdo_mysql zip
|
||||||
|
# Add a fake sendmail mailer
|
||||||
|
sudo cp ./.circleci/fake-sendmail.php /usr/local/bin/
|
||||||
|
# configure Apache
|
||||||
|
sudo cp ./.circleci/mailpoet_php.ini /usr/local/etc/php/conf.d/
|
||||||
|
sudo cp ./.circleci/apache/mailpoet.loc.conf /etc/apache2/sites-available
|
||||||
|
sudo a2ensite mailpoet.loc
|
||||||
|
sudo a2enmod rewrite
|
||||||
|
sudo service apache2 restart
|
||||||
|
# Install NodeJS+NPM
|
||||||
|
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
|
||||||
|
sudo apt-get install nodejs build-essential
|
||||||
|
# install plugin dependencies
|
||||||
|
curl -sS https://getcomposer.org/installer | php
|
||||||
|
./composer.phar install
|
||||||
|
./do install
|
||||||
|
# Set up Wordpress
|
||||||
|
mysql -h 127.0.0.1 -u root -e "create database wordpress"
|
||||||
|
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||||
|
chmod +x wp-cli.phar
|
||||||
|
./wp-cli.phar core download --allow-root --path=wordpress
|
||||||
|
# Generate `wp-config.php` file with debugging enabled
|
||||||
|
echo "define(\"WP_DEBUG\", true);" | ./wp-cli.phar core config --allow-root --dbname=wordpress --dbuser=root --dbhost=127.0.0.1 --path=wordpress --extra-php
|
||||||
|
# Install WordPress
|
||||||
|
./wp-cli.phar core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@mailpoet.loc --url=http://mailpoet.loc:8080 --title=WordPress --path=wordpress
|
||||||
|
# Softlink plugin to plugin path
|
||||||
|
ln -s ../../.. wordpress/wp-content/plugins/mailpoet
|
||||||
|
./wp-cli.phar plugin activate mailpoet --path=wordpress
|
||||||
|
# Create .env file with correct path to WP installation
|
||||||
|
# TODO: Remove this line after PR gets merged and CircleCI env variables change
|
||||||
|
echo "WP_TEST_PATH=\"/home/circleci/mailpoet/wordpress\"" > .env
|
||||||
|
- save_cache:
|
||||||
|
key: composer-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}
|
||||||
|
paths:
|
||||||
|
- vendor
|
||||||
|
- save_cache:
|
||||||
|
key: npm-{{ checksum "package.json" }}
|
||||||
|
paths:
|
||||||
|
- node_modules
|
||||||
|
- run:
|
||||||
|
name: "QA Scripts"
|
||||||
|
command: ./do qa
|
||||||
|
- run:
|
||||||
|
name: "Preparing test results folder"
|
||||||
|
command: mkdir test-results
|
||||||
|
- run:
|
||||||
|
name: "JS tests"
|
||||||
|
command: |
|
||||||
|
mkdir test-results/mocha
|
||||||
|
./do t:j test-results/mocha/junit.xml
|
||||||
|
- run:
|
||||||
|
name: "PHP Unit tests"
|
||||||
|
command: |
|
||||||
|
WP_TEST_PATH="/home/circleci/mailpoet/wordpress" ./do t:u --xml
|
||||||
|
- store_test_results:
|
||||||
|
path: tests/_output
|
||||||
|
- store_artifacts:
|
||||||
|
path: tests/_output
|
||||||
|
destination: codeception
|
||||||
|
- store_test_results:
|
||||||
|
path: test-results/mocha
|
||||||
|
- store_artifacts:
|
||||||
|
path: test-results/mocha
|
||||||
|
destination: mocha
|
||||||
|
- store_artifacts:
|
||||||
|
path: /tmp/fake-mailer/
|
||||||
|
destination: fake-mailer
|
17
.circleci/fake-sendmail.php
Executable file
17
.circleci/fake-sendmail.php
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/local/bin/php
|
||||||
|
<?php
|
||||||
|
$path = "/tmp/fake-mailer";
|
||||||
|
if(!file_exists($path)) {
|
||||||
|
mkdir($path);
|
||||||
|
}
|
||||||
|
$filename = $path . '/mailpoet-' . microtime(true) . '.txt';
|
||||||
|
$file_handle = fopen($filename, "w");
|
||||||
|
|
||||||
|
$call_arguments = print_r($argv, true) . "\n";
|
||||||
|
fwrite($file_handle, $call_arguments);
|
||||||
|
|
||||||
|
while($line = fgets(STDIN)) {
|
||||||
|
fwrite($file_handle, $line);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($file_handle);
|
9
.circleci/mailpoet_php.ini
Normal file
9
.circleci/mailpoet_php.ini
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
|
||||||
|
; http://php.net/sendmail-path
|
||||||
|
sendmail_path = /usr/local/bin/fake-sendmail.php
|
||||||
|
|
||||||
|
[Date]
|
||||||
|
; Defines the default timezone used by the date functions
|
||||||
|
; http://php.net/date.timezone
|
||||||
|
date.timezone = UTC
|
||||||
|
|
71
circle.yml
71
circle.yml
@ -1,71 +0,0 @@
|
|||||||
machine:
|
|
||||||
timezone:
|
|
||||||
UTC
|
|
||||||
|
|
||||||
hosts:
|
|
||||||
mailpoet.loc: 127.0.0.1
|
|
||||||
|
|
||||||
## Customize dependencies
|
|
||||||
dependencies:
|
|
||||||
pre:
|
|
||||||
# install PHP dependencies for WordPress
|
|
||||||
- sudo apt-get update
|
|
||||||
- sudo apt-get --assume-yes install php5-mysql
|
|
||||||
# Add a fake sendmail mailer
|
|
||||||
- cp ./.circle_ci/mailpoet_php.ini /opt/circleci/php/$(phpenv global)/etc/conf.d/
|
|
||||||
# configure Apache
|
|
||||||
- sudo cp ./.circle_ci/apache/mailpoet.loc.conf /etc/apache2/sites-available
|
|
||||||
- sudo a2ensite mailpoet.loc
|
|
||||||
- sudo a2enmod rewrite
|
|
||||||
- sudo service apache2 restart
|
|
||||||
# install Phoenix dependencies
|
|
||||||
- curl -sS https://getcomposer.org/installer | php
|
|
||||||
- ./composer.phar install
|
|
||||||
- ./do install
|
|
||||||
# Set up Wordpress
|
|
||||||
# No password is required for the MySQL user `ubuntu`
|
|
||||||
- mysql -u ubuntu -e "create database wordpress"
|
|
||||||
# Use cURL to fetch WP-CLI
|
|
||||||
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
|
||||||
# Make sure WP-CLI is executable
|
|
||||||
- chmod +x wp-cli.phar
|
|
||||||
# Download WordPress into `wordpress` directory
|
|
||||||
- ./wp-cli.phar core download --allow-root --path=wordpress
|
|
||||||
# Generate `wp-config.php` file
|
|
||||||
- echo "define(\"WP_DEBUG\", true);" | ./wp-cli.phar core config --allow-root --dbname=wordpress --dbuser=ubuntu --dbhost=127.0.0.1:3306 --path=wordpress --extra-php
|
|
||||||
# Install WordPress
|
|
||||||
- ./wp-cli.phar core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@mailpoet.loc --url=http://mailpoet.loc:8080 --title=WordPress --path=wordpress
|
|
||||||
# Softlink MailPoet to plugin path
|
|
||||||
- ln -s ../../.. wordpress/wp-content/plugins/mailpoet
|
|
||||||
# Activate MailPoet
|
|
||||||
- ./wp-cli.phar plugin activate mailpoet --path=wordpress
|
|
||||||
# Create .env file with correct path to WP installation
|
|
||||||
- echo "WP_TEST_PATH=\"/home/ubuntu/mailpoet/wordpress\"" > .env
|
|
||||||
|
|
||||||
# Enable XDebug for coverage reports.
|
|
||||||
# Comment out if not running PHP coverage reports, for performance
|
|
||||||
#- sed -i 's/^;//' /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
|
|
||||||
|
|
||||||
## tests override
|
|
||||||
test:
|
|
||||||
override:
|
|
||||||
# Add default timezone to PHP's configuration (required for PHP >=5.4)
|
|
||||||
- echo "date.timezone = UTC" > /opt/circleci/php/$(phpenv global)/etc/conf.d/date.ini
|
|
||||||
# Run QA scripts
|
|
||||||
- ./do qa
|
|
||||||
# Run JS tests
|
|
||||||
- mkdir $CIRCLE_TEST_REPORTS/mocha
|
|
||||||
- ./do t:j $CIRCLE_TEST_REPORTS/mocha/junit.xml
|
|
||||||
|
|
||||||
# Run PHP tests
|
|
||||||
- ./do t:u --xml
|
|
||||||
# Uncomment to run coverage tests instead
|
|
||||||
#- ./do t:c --xml
|
|
||||||
# Copy the report
|
|
||||||
- mkdir $CIRCLE_TEST_REPORTS/codeception
|
|
||||||
- cp tests/_output/report.xml $CIRCLE_TEST_REPORTS/codeception/report.xml
|
|
||||||
# Uncomment to copy PHP coverage report
|
|
||||||
#- cp tests/_output/coverage.xml $CIRCLE_TEST_REPORTS/codeception/coverage.xml
|
|
||||||
# Store any email output, sent via sendmail during tests
|
|
||||||
- mkdir $CIRCLE_TEST_REPORTS/fake-mailer
|
|
||||||
- cp /tmp/mailpoet-* $CIRCLE_TEST_REPORTS/fake-mailer
|
|
Reference in New Issue
Block a user