From a777c2e8f69dc753f8a945b1dd54bbaaa1e9e66c Mon Sep 17 00:00:00 2001 From: simialbi Date: Wed, 29 Jan 2020 13:13:26 +0100 Subject: [PATCH] Use GitHub to run tests (#17822) --- .github/workflows/tests.yml | 119 +++++++++++++++++++++++ .gitignore | 1 + .travis.yml | 226 -------------------------------------------- .travis.yml.bak | 226 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 346 insertions(+), 226 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml create mode 100644 .travis.yml.bak diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..1630d04 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,119 @@ +name: Tests + +on: [push, pull_request] + +env: + DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader" + PHPUNIT_EXCLUDE_GROUP: mssql,oci,wincache,xcache,zenddata,cubrid + +jobs: + phpunit: + name: PHP ${{ matrix.php }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} +# services: +# mysql: +# image: mysql +# env: +# MYSQL_ALLOW_EMPTY_PASSWORD: false +# MYSQL_ROOT_PASSWORD: root +# MYSQL_DATABASE: yiitest +# ports: +# - 3306/tcp +# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 +# postgres: +# image: postgres:9.6 +# env: +# POSTGRES_USER: postgres +# POSTGRES_PASSWORD: +# POSTGRES_DB: yiitest +# ports: +# - 5432/tcp +# options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + + steps: + - name: Generate french locale + run: sudo locale-gen fr_FR.UTF-8 + - name: Checkout + uses: actions/checkout@v2 + - name: Install PHP + uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php }} + extensions: apc, curl, mbstring, dom, intl, mysql, pgsql, memcached, pdo, pdo_sqlite, imagick + ini-values: date.timezone='UTC' + - name: Install Memcached + uses: niden/actions-memcached@v7 + - name: Install Postgres + uses: harmon758/postgresql-action@v1 + with: + postgresql version: 9.6 + postgresql db: yiitest + postgresql user: postgres + - name: Create mysql db + run: mysql -uroot -proot -e 'CREATE DATABASE `yiitest`;' + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies + run: composer update $DEFAULT_COMPOSER_FLAGS + - name: PHP Unit tests + run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --exclude-group oci,wincache,xcache,zenddata,cubrid + if: matrix.php == '7.1' + - name: PHP Unit tests + run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP + env: + PHPUNIT_EXCLUDE_GROUP: oci,wincache,xcache,zenddata,cubrid + if: matrix.php == '7.4' || matrix.php == '7.3' || matrix.php == '7.2' + - name: PHP Unit tests + run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP + if: matrix.php == '7.0' || matrix.php == '5.6' + - name: Code coverage + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover + if: matrix.php == '7.1' + continue-on-error: true # if is fork + + npm: + name: NPM 6 on ubuntu-latest + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install PHP + uses: shivammathur/setup-php@v1 + with: + php-version: 7.2 + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies + run: composer update $DEFAULT_COMPOSER_FLAGS + - name: Install node.js + uses: actions/setup-node@v1 + with: + node-version: 6 + - name: Tests + run: | + npm install + npm test +# env: +# CI: true diff --git a/.gitignore b/.gitignore index f941e24..769d405 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # phpstorm project files .idea +*.iml # netbeans project files nbproject diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d1975b7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,226 +0,0 @@ -dist: xenial - -# faster builds on new travis setup not using sudo -# temporary disable, see https://github.com/travis-ci/travis-ci/issues/6842 -#sudo: false -sudo: required -group: edge - -# build only on master branches -# commented as this prevents people from running builds on their forks: -# https://github.com/yiisoft/yii2/commit/bd87be990fa238c6d5e326d0a171f38d02dc253a -#branches: -# only: -# - master -# - 2.1 - - -# -# Test Matrix -# - -language: php - -env: - global: - - DEFAULT_COMPOSER_FLAGS="--prefer-dist --no-interaction --no-progress --optimize-autoloader" - - TASK_TESTS_PHP=1 - - TASK_TESTS_JS=0 - - TASK_TESTS_COVERAGE=0 - - TRAVIS_SECOND_USER=travis_two - - PHPUNIT_EXCLUDE_GROUP=mssql,oci,wincache,xcache,zenddata,cubrid - - -services: - - memcached - - postgresql - - docker - -# cache vendor dirs -cache: - directories: - - vendor - - $HOME/.composer/cache - - $HOME/.npm - -# try running against postgres 9.6 -addons: - postgresql: "9.6" - code_climate: - repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b - -matrix: - fast_finish: true - include: - - php: "7.4" - env: PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid - - - php: "7.3" - env: PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid - - - php: "7.2" - env: PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid - - # run tests coverage on PHP 7.1 - - php: "7.1" - env: - - TASK_TESTS_COVERAGE=1 - - PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid - - - php: "7.0" - - - php: "5.6" - - - php: "5.5" - dist: trusty - - - php: "5.4" - dist: trusty - - # Test against HHVM 3.21 LTS version by using trusty - - php: hhvm-3.21 - sudo: true - addons: - code_climate: - repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b - postgresql: "9.6" - services: - - mysql - - postgresql - - # test against the latest pre 3.26 HHVM version by using a newer image. - # @see https://github.com/facebook/hhvm/issues/8192 - - php: hhvm-3.24 - sudo: true - addons: - code_climate: - repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b - postgresql: "9.6" - services: - - mysql - - postgresql - - - php: nightly - services: - - mysql - - postgresql - - # have a separate branch for javascript tests - - language: node_js - node_js: "6" - env: TASK_TESTS_PHP=0 TASK_TESTS_JS=1 - # overwrite services used for PHP tests - services: - - allow_failures: - - php: nightly - - php: hhvm-3.21 - - php: hhvm-3.24 - -install: - - | - if [[ $TASK_TESTS_COVERAGE != 1 && $TRAVIS_PHP_VERSION != hhv* ]]; then - # disable xdebug for performance reasons when code coverage is not needed. note: xdebug on hhvm is disabled by default - phpenv config-rm xdebug.ini || echo "xdebug is not installed" - fi - - # install composer dependencies - - travis_retry composer self-update - - export PATH="$HOME/.composer/vendor/bin:$PATH" - - travis_retry composer update $DEFAULT_COMPOSER_FLAGS - - # setup PHP extension - - | - if [[ $TASK_TESTS_PHP == 1 && $TRAVIS_PHP_VERSION != nightly ]]; then - tests/data/travis/apc-setup.sh - tests/data/travis/memcache-setup.sh - tests/data/travis/imagick-setup.sh - source tests/data/travis/mysql-setup.sh - source tests/data/travis/mssql-setup.sh - fi - - # setup JS test - - | - if [ $TASK_TESTS_JS == 1 ]; then - travis_retry npm install - fi - - # Needed for FileCacheTest - - sudo useradd $TRAVIS_SECOND_USER --gid $(id -g) -M - -before_script: - # - # Disable: - # 1) the HHVM JIT for faster testing; - # 2) the session GC for testing stability. - # - # The second allows to avoid accidental unpredictable failings with message: - # `ps_files_cleanup_dir: opendir(/var/lib/hhvm/sessions) failed: Permission denied (13)` - # - - if [[ $TRAVIS_PHP_VERSION = hhv* ]]; then - echo 'hhvm.jit = 0' >> /etc/hhvm/php.ini; - echo 'session.gc_probability = 0' >> /etc/hhvm/php.ini; - fi - - # show some versions and env information - - php --version - - composer --version - - | - if [ $TASK_TESTS_PHP == 1 ]; then - php -r "echo INTL_ICU_VERSION . \"\n\";" - php -r "echo INTL_ICU_DATA_VERSION . \"\n\";" - psql --version - mysql --version - sudo mysql_upgrade || echo "MySQL is already up to date" - fi - - | - if [ $TASK_TESTS_JS == 1 ]; then - node --version - npm --version - fi - - # initialize databases - - | - if [ $TASK_TESTS_PHP == 1 ]; then - travis_retry mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE `yiitest`;'; - mysql -h 127.0.0.1 -u root -proot -e "SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';"; - mysql -h 127.0.0.1 -u root -proot -e "CREATE USER 'travis'@'localhost' IDENTIFIED WITH mysql_native_password;"; - mysql -h 127.0.0.1 -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'localhost' WITH GRANT OPTION;"; - psql -U postgres -c 'CREATE DATABASE yiitest;'; - fi - - # enable code coverage - - | - if [ $TASK_TESTS_COVERAGE == 1 ]; then - PHPUNIT_FLAGS="--coverage-clover=coverage.clover" - fi - - # Disable DEPRECATE messages during PHPUnit initialization on PHP 7.2. To fix them, PHPUnit should be updated to 6.* - # For Yii2 tests, messages will be enabled by tests/bootstrap.php - - | - if [[ $TRAVIS_PHP_VERSION == 7.2 || $TRAVIS_PHP_VERSION == 7.3 || $TRAVIS_PHP_VERSION == 7.4 || $TRAVIS_PHP_VERSION = nightly ]]; then - echo 'Disabled DEPRECATED notifications for PHP >= 7.2'; - echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> /tmp/php-config.ini; - phpenv config-add /tmp/php-config.ini; - fi - - -script: - # PHP tests - - | - if [ $TASK_TESTS_PHP == 1 ]; then - vendor/bin/phpunit --verbose $PHPUNIT_FLAGS --exclude-group $PHPUNIT_EXCLUDE_GROUP - fi - - # JS tests - - | - if [ $TASK_TESTS_JS == 1 ]; then - npm test - fi - -after_script: - - | - if [ $TASK_TESTS_COVERAGE == 1 ]; then - travis_retry wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - fi diff --git a/.travis.yml.bak b/.travis.yml.bak new file mode 100644 index 0000000..d1975b7 --- /dev/null +++ b/.travis.yml.bak @@ -0,0 +1,226 @@ +dist: xenial + +# faster builds on new travis setup not using sudo +# temporary disable, see https://github.com/travis-ci/travis-ci/issues/6842 +#sudo: false +sudo: required +group: edge + +# build only on master branches +# commented as this prevents people from running builds on their forks: +# https://github.com/yiisoft/yii2/commit/bd87be990fa238c6d5e326d0a171f38d02dc253a +#branches: +# only: +# - master +# - 2.1 + + +# +# Test Matrix +# + +language: php + +env: + global: + - DEFAULT_COMPOSER_FLAGS="--prefer-dist --no-interaction --no-progress --optimize-autoloader" + - TASK_TESTS_PHP=1 + - TASK_TESTS_JS=0 + - TASK_TESTS_COVERAGE=0 + - TRAVIS_SECOND_USER=travis_two + - PHPUNIT_EXCLUDE_GROUP=mssql,oci,wincache,xcache,zenddata,cubrid + + +services: + - memcached + - postgresql + - docker + +# cache vendor dirs +cache: + directories: + - vendor + - $HOME/.composer/cache + - $HOME/.npm + +# try running against postgres 9.6 +addons: + postgresql: "9.6" + code_climate: + repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b + +matrix: + fast_finish: true + include: + - php: "7.4" + env: PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid + + - php: "7.3" + env: PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid + + - php: "7.2" + env: PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid + + # run tests coverage on PHP 7.1 + - php: "7.1" + env: + - TASK_TESTS_COVERAGE=1 + - PHPUNIT_EXCLUDE_GROUP=oci,wincache,xcache,zenddata,cubrid + + - php: "7.0" + + - php: "5.6" + + - php: "5.5" + dist: trusty + + - php: "5.4" + dist: trusty + + # Test against HHVM 3.21 LTS version by using trusty + - php: hhvm-3.21 + sudo: true + addons: + code_climate: + repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b + postgresql: "9.6" + services: + - mysql + - postgresql + + # test against the latest pre 3.26 HHVM version by using a newer image. + # @see https://github.com/facebook/hhvm/issues/8192 + - php: hhvm-3.24 + sudo: true + addons: + code_climate: + repo_token: 2935307212620b0e2228ab67eadd92c9f5501ddb60549d0d86007a354d56915b + postgresql: "9.6" + services: + - mysql + - postgresql + + - php: nightly + services: + - mysql + - postgresql + + # have a separate branch for javascript tests + - language: node_js + node_js: "6" + env: TASK_TESTS_PHP=0 TASK_TESTS_JS=1 + # overwrite services used for PHP tests + services: + + allow_failures: + - php: nightly + - php: hhvm-3.21 + - php: hhvm-3.24 + +install: + - | + if [[ $TASK_TESTS_COVERAGE != 1 && $TRAVIS_PHP_VERSION != hhv* ]]; then + # disable xdebug for performance reasons when code coverage is not needed. note: xdebug on hhvm is disabled by default + phpenv config-rm xdebug.ini || echo "xdebug is not installed" + fi + + # install composer dependencies + - travis_retry composer self-update + - export PATH="$HOME/.composer/vendor/bin:$PATH" + - travis_retry composer update $DEFAULT_COMPOSER_FLAGS + + # setup PHP extension + - | + if [[ $TASK_TESTS_PHP == 1 && $TRAVIS_PHP_VERSION != nightly ]]; then + tests/data/travis/apc-setup.sh + tests/data/travis/memcache-setup.sh + tests/data/travis/imagick-setup.sh + source tests/data/travis/mysql-setup.sh + source tests/data/travis/mssql-setup.sh + fi + + # setup JS test + - | + if [ $TASK_TESTS_JS == 1 ]; then + travis_retry npm install + fi + + # Needed for FileCacheTest + - sudo useradd $TRAVIS_SECOND_USER --gid $(id -g) -M + +before_script: + # + # Disable: + # 1) the HHVM JIT for faster testing; + # 2) the session GC for testing stability. + # + # The second allows to avoid accidental unpredictable failings with message: + # `ps_files_cleanup_dir: opendir(/var/lib/hhvm/sessions) failed: Permission denied (13)` + # + - if [[ $TRAVIS_PHP_VERSION = hhv* ]]; then + echo 'hhvm.jit = 0' >> /etc/hhvm/php.ini; + echo 'session.gc_probability = 0' >> /etc/hhvm/php.ini; + fi + + # show some versions and env information + - php --version + - composer --version + - | + if [ $TASK_TESTS_PHP == 1 ]; then + php -r "echo INTL_ICU_VERSION . \"\n\";" + php -r "echo INTL_ICU_DATA_VERSION . \"\n\";" + psql --version + mysql --version + sudo mysql_upgrade || echo "MySQL is already up to date" + fi + - | + if [ $TASK_TESTS_JS == 1 ]; then + node --version + npm --version + fi + + # initialize databases + - | + if [ $TASK_TESTS_PHP == 1 ]; then + travis_retry mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE `yiitest`;'; + mysql -h 127.0.0.1 -u root -proot -e "SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';"; + mysql -h 127.0.0.1 -u root -proot -e "CREATE USER 'travis'@'localhost' IDENTIFIED WITH mysql_native_password;"; + mysql -h 127.0.0.1 -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'localhost' WITH GRANT OPTION;"; + psql -U postgres -c 'CREATE DATABASE yiitest;'; + fi + + # enable code coverage + - | + if [ $TASK_TESTS_COVERAGE == 1 ]; then + PHPUNIT_FLAGS="--coverage-clover=coverage.clover" + fi + + # Disable DEPRECATE messages during PHPUnit initialization on PHP 7.2. To fix them, PHPUnit should be updated to 6.* + # For Yii2 tests, messages will be enabled by tests/bootstrap.php + - | + if [[ $TRAVIS_PHP_VERSION == 7.2 || $TRAVIS_PHP_VERSION == 7.3 || $TRAVIS_PHP_VERSION == 7.4 || $TRAVIS_PHP_VERSION = nightly ]]; then + echo 'Disabled DEPRECATED notifications for PHP >= 7.2'; + echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> /tmp/php-config.ini; + phpenv config-add /tmp/php-config.ini; + fi + + +script: + # PHP tests + - | + if [ $TASK_TESTS_PHP == 1 ]; then + vendor/bin/phpunit --verbose $PHPUNIT_FLAGS --exclude-group $PHPUNIT_EXCLUDE_GROUP + fi + + # JS tests + - | + if [ $TASK_TESTS_JS == 1 ]; then + npm test + fi + +after_script: + - | + if [ $TASK_TESTS_COVERAGE == 1 ]; then + travis_retry wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover coverage.clover + fi