diff --git a/.circle_ci/fake-sendmail.rb b/.circle_ci/fake-sendmail.rb deleted file mode 100755 index 474548946a..0000000000 --- a/.circle_ci/fake-sendmail.rb +++ /dev/null @@ -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 diff --git a/.circle_ci/mailpoet_php.ini b/.circle_ci/mailpoet_php.ini deleted file mode 100644 index 86342ac424..0000000000 --- a/.circle_ci/mailpoet_php.ini +++ /dev/null @@ -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 diff --git a/.circle_ci/apache/mailpoet.loc.conf b/.circleci/apache/mailpoet.loc.conf similarity index 65% rename from .circle_ci/apache/mailpoet.loc.conf rename to .circleci/apache/mailpoet.loc.conf index 4d8fa3a37d..68b4ac95f3 100644 --- a/.circle_ci/apache/mailpoet.loc.conf +++ b/.circleci/apache/mailpoet.loc.conf @@ -3,11 +3,11 @@ Listen 8080 UseCanonicalName Off ServerName mailpoet.loc - DocumentRoot /home/ubuntu/mailpoet/wordpress + DocumentRoot /home/circleci/mailpoet/wordpress DirectoryIndex index.php LogLevel notice - + Require all granted diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..3aa320b390 --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/.circleci/fake-sendmail.php b/.circleci/fake-sendmail.php new file mode 100755 index 0000000000..663f2133c5 --- /dev/null +++ b/.circleci/fake-sendmail.php @@ -0,0 +1,17 @@ +#!/usr/local/bin/php + .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