From d2884f06731880681a07111ba8789aa709cd0009 Mon Sep 17 00:00:00 2001 From: David Alger <david@classyllama.com> Date: Fri, 26 Feb 2016 15:38:44 -0600 Subject: [PATCH] Refactored travis scripts out of main travis config file --- .travis.yml | 46 ++++-------------------------------- dev/travis/before_install.sh | 15 ++++++++++++ dev/travis/before_script.sh | 34 ++++++++++++++++++++++++++ dev/travis/script.sh | 33 ++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 42 deletions(-) create mode 100755 dev/travis/before_install.sh create mode 100755 dev/travis/before_script.sh create mode 100755 dev/travis/script.sh diff --git a/.travis.yml b/.travis.yml index d69e0b99b8b..fc7dc03ee91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,46 +32,8 @@ matrix: env: TEST_SUITE=static_annotation - php: 7.0 env: TEST_SUITE=static_phpcs - - php: 7.0 + - php: env: TEST_SUITE=static_annotation -before_install: - - sh -c 'if [ "$CASHER_DIR" ]; then - if [ -x $HOME/.cache/bin/composer ]; then - $HOME/.cache/bin/composer self-update; echo ''; - else - mkdir -p $HOME/.cache/bin; - curl --connect-timeout 30 -sS https://getcomposer.org/installer - | php -- --install-dir $HOME/.cache/bin/ --filename composer; - fi - fi' - - export PATH="$HOME/.cache/bin:$PATH" -before_script: - # Mock mail - - sudo service postfix stop - - smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 & - - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini - # Disable xDebug - - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - # Create DB for integration tests - - > - sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ] || [ '$TEST_SUITE' = 'integration_part_2' ] || [ '$TEST_SUITE' = 'integration_integrity' ]; then - mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_integration_tests;'; - mv dev/tests/integration/etc/install-config-mysql.travis.php.dist dev/tests/integration/etc/install-config-mysql.php; - fi" - # Change memory_limit for travis - - echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - phpenv rehash; - - composer install --no-interaction --prefer-dist -script: - # Unit tests - - sh -c "if [ '$TEST_SUITE' = 'unit' ]; then ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist; fi" - # Integration tests - - sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ] || [ '$TEST_SUITE' = 'integration_part_2' ]; then cd dev/tests/integration/; bash IntegationTestsForTravis.sh 2; fi" - - sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ]; then cd dev/tests/integration/; ./../../../vendor/bin/phpunit -c phpunit.xml.travis1; fi" - - sh -c "if [ '$TEST_SUITE' = 'integration_part_2' ]; then cd dev/tests/integration/; ./../../../vendor/bin/phpunit -c phpunit.xml.travis2; fi" - # Integration integrity tests - - sh -c "if [ '$TEST_SUITE' = 'integration_integrity' ]; then cd dev/tests/integration/; ./../../../vendor/bin/phpunit -c phpunit.xml.dist testsuite/Magento/Test/Integrity; fi" - # Static tests [Code Style] - - sh -c "if [ '$TEST_SUITE' = 'static_phpcs' ]; then cd dev/tests/static; ./../../../vendor/bin/phpunit -c phpunit.xml.dist --filter 'Magento\\\\Test\\\\Php\\\\LiveCodeTest::testCodeStyle'; fi" - # Static tests [Code Style] - - sh -c "if [ '$TEST_SUITE' = 'static_annotation' ]; then cd dev/tests/static; ./../../../vendor/bin/phpunit -c phpunit.xml.dist --filter 'Magento\\\\Test\\\\Php\\\\LiveCodeTest::testAnnotationStandard'; fi" +before_install: ./dev/travis/before_install.sh +before_script: ./dev/travis/before_script.sh +script: ./dev/travis/script.sh diff --git a/dev/travis/before_install.sh b/dev/travis/before_install.sh new file mode 100755 index 00000000000..3eb77fa94d1 --- /dev/null +++ b/dev/travis/before_install.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Copyright © 2015 Magento. All rights reserved. +# See COPYING.txt for license details. + +# install or update composer in casher dir +if [ "$CASHER_DIR" ]; then + if [ -x $HOME/.cache/bin/composer ]; then + $HOME/.cache/bin/composer self-update + else + mkdir -p $HOME/.cache/bin + curl --connect-timeout 30 -sS https://getcomposer.org/installer \ + | php -- --install-dir $HOME/.cache/bin/ --filename composer + fi +fi diff --git a/dev/travis/before_script.sh b/dev/travis/before_script.sh new file mode 100755 index 00000000000..8f3b0c6fd17 --- /dev/null +++ b/dev/travis/before_script.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright © 2015 Magento. All rights reserved. +# See COPYING.txt for license details. + +# prefer our cached binaries +export PATH="$HOME/.cache/bin:$PATH" + +# mock mail +sudo service postfix stop +smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 & +echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/sendmail.ini + +# disable xDebug +echo > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini + +# create database for integration tests +case $TEST_SUITE in + integration_part_1|integration_part_2) + ./dev/tests/integration/IntegationTestsForTravis.sh 2 + ;& # intentional fallthrough + integration_integrity) + mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_integration_tests;' + mv dev/tests/integration/etc/install-config-mysql.travis.php.dist \ + dev/tests/integration/etc/install-config-mysql.php + ;; +esac + +# change memory_limit for travis +echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini +phpenv rehash; + +# install deps +composer install --no-interaction --prefer-dist diff --git a/dev/travis/script.sh b/dev/travis/script.sh new file mode 100755 index 00000000000..fad2f5cc2e8 --- /dev/null +++ b/dev/travis/script.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copyright © 2015 Magento. All rights reserved. +# See COPYING.txt for license details. + +PATH="./../../../vendor/bin:$PATH" + +case $TEST_SUITE in + unit) + cd dev/tests/unit + phpunit -c phpunit.xml.dist + ;; + integration_part_1) + cd dev/tests/integration + phpunit -c phpunit.xml.travis1 + ;; + integration_part_2) + cd dev/tests/integration + phpunit -c phpunit.xml.travis2 + ;; + integration_integrity) + cd dev/tests/integration + phpunit -c phpunit.xml.dist testsuite/Magento/Test/Integrity + ;; + static_phpcs) + cd dev/tests/static + phpunit -c phpunit.xml.dist --filter 'Magento\\Test\\Php\\LiveCodeTest::testCodeStyle' + ;; + static_annotation) + cd dev/tests/static + phpunit -c phpunit.xml.dist --filter 'Magento\\Test\\Php\\LiveCodeTest::testAnnotationStandard' + ;; +esac -- GitLab