├── .build-increment ├── .travis.yml ├── .travis └── travis-ci-apache └── README.md /.build-increment: -------------------------------------------------------------------------------- 1 | 714 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | env: 2 | #global environmental variables control magento install parameters 3 | #see also hosts in addons. 4 | global: 5 | - PULSESTORM_MAGE2_FAKE_URL=http://magento-2-travis.dev 6 | - PULSESTORM_MAGE2_ADMIN_EMAIL=robert.hoffner@example.com 7 | - PULSESTORM_MAGE2_ADMIN_FIRST_NAME=Robert 8 | - PULSESTORM_MAGE2_ADMIN_LAST_NAME=Hoffner 9 | - PULSESTORM_MAGE2_ADMIN_USERNAME=admin 10 | - PULSESTORM_MAGE2_ADMIN_PASSWORD=ih3artmagento 11 | - PULSESTORM_MAGE2_ADMIN_DBNAME=magento_2_travis 12 | - PULSESTORM_PESTLE_URL=http://pestle.pulsestorm.net 13 | - PULSESTORM_COMPOSER_REPOSITORY_TO_TEST=https://github.com/astorm/pestle.git 14 | - PULSESTORM_COMPOSER_PACKAGE_TO_TEST=pulsestorm/pestle 15 | addons: 16 | hosts: 17 | # should match PULSESTORM_MAGE2_FAKE_URL above 18 | - magento-2-travis.dev 19 | language: php 20 | sudo: required 21 | dist: trusty 22 | php: 23 | - 7.3 24 | services: 25 | - elasticsearch 26 | before_script: 27 | # some useful debugging stuff for travis 28 | #- curl http://magento-2-travis.dev/index.php 29 | #- curl http://magento-2-travis.dev/ 30 | #- sudo find /var/log/apache2 -exec cat '{}' \; 31 | #- sudo cat /etc/apache2/sites-available/000-default.conf 32 | #- sudo cat /etc/apache2/sites-enabled/000-default.conf 33 | #- sudo apachectl -V 34 | #- sudo apache2ctl -V 35 | #- ls -lh $TRAVIS_BUILD_DIR 36 | #- sudo ls /etc/apache2/sites-available 37 | #- sudo ls /etc/apache2/sites-enabled 38 | #- pwd 39 | # 40 | # get latest composer 41 | - composer selfupdate 42 | # disable xdebug for perf 43 | - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini 44 | # add multiverse support to get MySQL 5.6 update apt 45 | - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse" && sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-updates multiverse" 46 | - sudo apt-get update -qq 47 | # add mysql 5.6 48 | - sudo apt-get remove -y -qq --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5 49 | - sudo apt-get -y -qq autoremove; 50 | - sudo apt-get -y -qq autoclean; 51 | - sudo apt-get install -y -qq mysql-server-5.6 mysql-client-5.6; 52 | - mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_2_travis;'; 53 | # add apache 54 | - sudo apt-get install -y -qq apache2 libapache2-mod-fastcgi 55 | # add elasticsearch 7.6 56 | - curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-amd64.deb -o elasticsearch.deb 57 | - sudo dpkg -i --force-confnew elasticsearch.deb 58 | - sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch 59 | - sudo service elasticsearch restart 60 | # enable php-fpm -- www.conf.default is PHP 7 only, so we dev/null any copy problems 61 | - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf 2>/dev/null || true 62 | - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf 63 | - sudo a2enmod rewrite actions fastcgi alias 64 | - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini 65 | - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm 66 | # awful hack used during travis debugging that I swear I'm going to remove 67 | # but then again you're reading this so I didn't remove it and **sigh** 68 | - sudo chmod 777 /home /home/travis /home/travis/build 69 | 70 | # configure apache virtual hosts, assumes 000-default.conf is there 71 | - sudo cp -f .travis/travis-ci-apache /etc/apache2/sites-available/000-default.conf 72 | - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf 73 | # restart apache 74 | - sudo service apache2 restart 75 | 76 | # clone main magento github repository 77 | - git clone https://github.com/magento/magento2 78 | # download latest pestle phar and install 79 | - curl -LO "$PULSESTORM_PESTLE_URL/pestle.phar" 80 | - sudo mv pestle.phar /usr/local/bin 81 | - sudo chmod +x /usr/local/bin/pestle.phar 82 | # install Magento 83 | - cd magento2 84 | - composer install --prefer-dist 85 | # switch to specific branch in you like 86 | #- git checkout 2.0;git checkout tags/2.0.2 87 | 88 | # Use a github token 89 | - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi; 90 | 91 | # add composer package under test, composer require will trigger update/install 92 | 93 | - composer config repositories.travis_to_test git $PULSESTORM_COMPOSER_REPOSITORY_TO_TEST 94 | - composer require --prefer-dist $PULSESTORM_COMPOSER_PACKAGE_TO_TEST dev-master 95 | 96 | # run installation command using evn variables set above 97 | - php bin/magento setup:install --admin-email "$PULSESTORM_MAGE2_ADMIN_EMAIL" --admin-firstname "$PULSESTORM_MAGE2_ADMIN_FIRST_NAME" --admin-lastname "$PULSESTORM_MAGE2_ADMIN_LAST_NAME" --admin-password "$PULSESTORM_MAGE2_ADMIN_PASSWORD" --admin-user "$PULSESTORM_MAGE2_ADMIN_USERNAME" --backend-frontname admin --base-url "$PULSESTORM_MAGE2_FAKE_URL" --db-host 127.0.0.1 --db-name magento_2_travis --db-user root --session-save files --use-rewrites 1 --use-secure 0 -vvv 98 | # test that magento is installed 99 | - curl "$PULSESTORM_MAGE2_FAKE_URL/index.php" > /tmp/output.txt 100 | # test that pestle is working 101 | - pestle.phar hello_world 102 | script: test 'grep -Fx "magento-2-travis.dev" /tmp/output.txt' 103 | -------------------------------------------------------------------------------- /.travis/travis-ci-apache: -------------------------------------------------------------------------------- 1 | 2 | # [...] 3 | 4 | 5 | Options FollowSymLinks MultiViews ExecCGI 6 | AllowOverride All 7 | Order deny,allow 8 | Allow from all 9 | Require all granted 10 | 11 | 12 | # Wire up Apache to use Travis CI's php-fpm. 13 | 14 | 15 | Require all granted 16 | 17 | AddHandler php5-fcgi .php 18 | Action php5-fcgi /php5-fcgi 19 | Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi 20 | FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization 21 | 22 | 23 | ServerName magento-2-travis.dev 24 | ServerAlias www.magento-2-travis.dev 25 | DocumentRoot %TRAVIS_BUILD_DIR%/magento2/pub 26 | 27 | 28 | # [...] 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | magento2-travis 2 | -------------------------------------------------- 3 | This is a slightly modified version of the travis build script I created [for pestle](https://github.com/astorm/pestle), my Magento 2 code generate tool/module base PHP command line framework. 4 | 5 | This script will get you 6 | 7 | 1. A working PHP 5.6 and PHP 7.0 build enviornment 8 | 2. A php-fpm webserver 9 | 3. A MySQL server 10 | 4. An installed Magento with configurable install parameters 11 | 5. An extra installed composer package of your choice 12 | 13 | Assuming your module is [setup in a git repository somewhere as a composer package](http://magento-quickies.alanstorm.com/post/138242522550/magento-2-minimum-composer-file), you should be able to change 14 | 15 | - PULSESTORM_COMPOSER_REPOSITORY_TO_TEST=git@github.com:astorm/pestle.git 16 | - PULSESTORM_COMPOSER_PACKAGE_TO_TEST=pulsestorm/pestle 17 | 18 | to point to your repository. The travis script will checkout magento's develop branch, add your github repository as a composer repository, require in your named composer package, and then install Magento 2. At the end of the process you'll have a built out Magento enviornment that's suitable for running integration/acceptance tests against. 19 | 20 | If you're hitting GitHub API limits when [importing your own](https://github.com/astorm/magento2-travis/blob/0.0.1/.travis.yml#L85) packages, [you can set a](https://github.com/astorm/magento2-travis/blob/0.0.1/.travis.yml#L83) `GH_TOKEN` [environmental variable in travis](https://blog.wyrihaximus.net/2015/09/github-auth-token-on-travis/) 21 | 22 | The rest should be self explanatory via the comments. If you're confused by something, or something doesn't work, please open a GitHub issue here. 23 | --------------------------------------------------------------------------------