ソースを参照

Add github actions and reduce travis to prefer-lowest

Corey Taylor 5 年 前
コミット
7c4cbdb280
6 ファイル変更234 行追加165 行削除
  1. 0 96
      .appveyor.yml
  2. 7 0
      .github/codecov.yml
  3. 220 0
      .github/workflows/ci.yml
  4. 7 67
      .travis.yml
  5. 0 1
      phpstan.neon
  6. 0 1
      tests/TestCase/I18n/Formatter/IcuFormatterTest.php

+ 0 - 96
.appveyor.yml

@@ -1,96 +0,0 @@
-build: false
-platform: 'x64'
-clone_folder: C:\projects\cakephp
-clone_depth: 10
-
-cache:
-  - '%LOCALAPPDATA%\Composer\files'
-
-branches:
-  only:
-    - 3.x
-    - 3.next
-
-environment:
-  matrix:
-    - db: '2012'
-      db_dsn: 'sqlserver://sa:Password12!@.\SQL2012SP1/cakephp?MultipleActiveResultSets=false'
-
-services:
-  - mssql2012sp1
-
-init:
-  - SET PATH=C:\Program Files\OpenSSL;C:\php;%PATH%
-  - SET COMPOSER_NO_INTERACTION=1
-  - SET ANSICON=121x90 (121x90)
-
-install:
-  - curl -fsS https://windows.php.net/downloads/releases/latest/php-7.2-nts-Win32-VC15-x64-latest.zip -o php.zip
-  - 7z x php.zip -oC:\php\ -aoa > nul
-
-  - cd C:\php
-  - copy php.ini-production php.ini /Y
-  - echo date.timezone="UTC" >> php.ini
-  - echo extension_dir=ext >> php.ini
-  - echo extension=openssl >> php.ini
-  - echo extension=mbstring >> php.ini
-  - echo extension=intl >> php.ini
-  - echo extension=fileinfo >> php.ini
-  - php -v
-
-  - curl -fsS https://windows.php.net/downloads/pecl/releases/pdo_sqlsrv/5.6.1/php_pdo_sqlsrv-5.6.1-7.2-nts-vc15-x64.zip -o pdosqlsrv.zip
-  - 7z x pdosqlsrv.zip -oC:\php\ext php_pdo_sqlsrv.dll -aoa > nul
-  - curl -fsS https://windows.php.net/downloads/pecl/releases/sqlsrv/5.6.1/php_sqlsrv-5.6.1-7.2-nts-vc15-x64.zip -o sqlsrv.zip
-  - 7z x sqlsrv.zip -oC:\php\ext php_sqlsrv.dll -aoa > nul
-  - echo extension=pdo_sqlsrv >> php.ini
-  - echo extension=sqlsrv >> php.ini
-
-  - curl -fsS https://windows.php.net/downloads/pecl/releases/wincache/2.0.0.8/php_wincache-2.0.0.8-7.2-nts-vc15-x64.zip -o wincache.zip
-  - 7z x wincache.zip -oC:\php\ext php_wincache.dll -aoa > nul
-  - echo extension=wincache >> php.ini
-  - echo wincache.enablecli = 1 >> php.ini
-
-  - cd C:\projects\cakephp
-  - appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
-  - php composer.phar install --no-progress
-  - php -i | grep "ICU version"
-
-before_test:
-# This script solves the "Database 'model' is being recovered. Waiting until recovery is finished."
-# This solution comes from https://gist.github.com/jonathanhickford/1cb0d6665adab8b9c664
-# and is follow by http://help.appveyor.com/discussions/suggestions/264-database-mssqlsystemresource-is-being-recovered-waiting-for-sql-server-to-start
-- ps: >-
-    $tries = 5;
-
-    $pause = 10; # Seconds to wait between tries
-
-    While ($tries -gt 0) {
-      try {
-        $ServerConnectionString = "Data Source=(local)\SQL2012SP1;Initial Catalog=master;User Id=sa;PWD=Password12!";
-        $ServerConnection = new-object system.data.SqlClient.SqlConnection($ServerConnectionString);
-        $query = "exec sp_configure 'clr enabled', 1;`n"
-        $query = $query + "RECONFIGURE;`n"
-        $cmd = new-object system.data.sqlclient.sqlcommand($query, $ServerConnection);
-        $ServerConnection.Open();
-        "Running:"
-        $query
-        if ($cmd.ExecuteNonQuery() -ne -1) {
-          "SQL Error";
-        } else {
-          "Success"
-        }
-        $ServerConnection.Close();
-        $tries = 0;
-      } catch {
-        "Error:"
-        $_.Exception.Message
-        "Retry in $pause seconds.  Attempts left: $tries";
-        Start-Sleep -s $pause;
-      }
-      $tries = $tries -1;
-    }
-
-test_script:
-  - sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -Q "create database cakephp;"
-  - cd C:\projects\cakephp
-  - vendor\bin\phpunit.bat

+ 7 - 0
.github/codecov.yml

@@ -0,0 +1,7 @@
+codecov:
+  require_ci_to_pass: yes
+
+coverage:
+  range: "90...100"
+
+comment: false

+ 220 - 0
.github/workflows/ci.yml

@@ -0,0 +1,220 @@
+name: CakePHP CI
+
+on:
+  push:
+    branches:
+      - 3.x
+      - 3.next
+  pull_request:
+    branches:
+      - '*'
+
+jobs:
+  testsuite:
+    runs-on: ubuntu-18.04
+    strategy:
+      fail-fast: false
+      matrix:
+        php-version: ['5.6', '7.4']
+        db-type: [sqlite, mysql, pgsql]
+    name: PHP ${{ matrix.php-version }} & ${{ matrix.db-type }}
+
+    services:
+      redis:
+        image: redis
+        ports:
+          - 6379/tcp
+
+    steps:
+    - name: Setup MySQL latest
+      if: matrix.db-type == 'mysql' && matrix.php-version != '5.6'
+      run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin
+
+    - name: Setup MySQL 5.6
+      if: matrix.db-type == 'mysql' && matrix.php-version == '5.6'
+      run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.6 --character-set-server=utf8
+
+    - name: Setup PostgreSQL latest
+      if: matrix.db-type == 'pgsql' && matrix.php-version != '5.6'
+      run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres
+
+    - name: Setup PostgreSQL 9.4
+      if: matrix.db-type == 'pgsql' && matrix.php-version == '5.6'
+      run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres:9.4
+
+    - uses: actions/checkout@v1
+      with:
+        fetch-depth: 1
+
+    - name: Setup PHP
+      uses: shivammathur/setup-php@v2
+      with:
+        php-version: ${{ matrix.php-version }}
+        extensions: mbstring, intl, apcu, pdo_${{ matrix.db-type }}
+        ini-values: apc.enable_cli = 1
+        coverage: pcov
+
+    - name: Get composer cache directory
+      id: composer-cache
+      run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+    - name: Get date part for cache key
+      id: key-date
+      run: echo "::set-output name=date::$(date +'%Y-%m')"
+
+    - name: Cache composer dependencies
+      uses: actions/cache@v1
+      with:
+        path: ${{ steps.composer-cache.outputs.dir }}
+        key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
+
+    - name: Install packages
+      run: |
+        # memcached installation fails without updating packages.
+        sudo apt update
+        sudo apt install memcached
+
+        sudo locale-gen da_DK.UTF-8
+        sudo locale-gen de_DE.UTF-8
+
+    - name: composer install
+      run: |
+        if [[ ${{ matrix.php-version }} == '8.0' ]]; then
+          composer update --ignore-platform-reqs
+        else
+          composer update
+        fi
+
+        if [[ ${{ matrix.php-version }} == '7.4' ]]; then
+          composer require --dev pcov/clobber
+        fi
+
+    - name: Configure PHPUnit matcher
+      if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
+      uses: mheap/phpunit-matcher-action@master
+
+    - name: Run PHPUnit
+      env:
+        REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
+      run: |
+        if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export db_dsn='sqlite:///:memory:'; fi
+        if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} != '5.6' ]]; then export db_dsn='mysql://root:root@127.0.0.1/cakephp?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'; fi
+        if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} == '5.6' ]]; then export db_dsn='mysql://root:root@127.0.0.1/cakephp?encoding=utf8'; fi
+        if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export db_dsn='postgres://postgres:postgres@127.0.0.1/postgres'; fi
+
+        if [[ ${{ matrix.php-version }} == '7.4' ]]; then
+          export CODECOVERAGE=1 && vendor/bin/pcov clobber; vendor/bin/phpunit --coverage-clover=coverage.xml
+        else
+          vendor/bin/phpunit
+        fi
+
+    - name: Submit code coverage
+      if: success() && matrix.php-version == '7.4'
+      uses: codecov/codecov-action@v1
+
+  testsuite-windows:
+    runs-on: windows-2019
+    name: Windows - PHP 7.4 & SQL Server
+
+    env:
+      EXTENSIONS: mbstring, intl, apcu, pdo_sqlsrv
+      PHP_VERSION: '7.4'
+
+    steps:
+    - uses: actions/checkout@v1
+      with:
+        fetch-depth: 1
+
+    - name: Get date part for cache key
+      id: key-date
+      run: echo "::set-output name=date::$(date +'%Y-%m')"
+
+    - name: Setup PHP extensions cache
+      id: php-ext-cache
+      uses: shivammathur/cache-extensions@v1
+      with:
+        php-version: ${{ env.PHP_VERSION }}
+        extensions: ${{ env.EXTENSIONS }}
+        key: ${{ steps.key-date.outputs.date }}
+
+    - name: Cache PHP extensions
+      uses: actions/cache@v1
+      with:
+        path: ${{ steps.php-ext-cache.outputs.dir }}
+        key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
+        restore-keys: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }}
+
+    - name: Setup PHP
+      uses: shivammathur/setup-php@v2
+      with:
+        php-version: ${{ env.PHP_VERSION }}
+        extensions: ${{ env.EXTENSIONS }}
+        ini-values: apc.enable_cli = 1, extension = php_fileinfo.dll
+        coverage: none
+
+    - name: Setup SQLServer
+      run: |
+        # MSSQLLocalDB is the default SQL LocalDB instance
+        SqlLocalDB start MSSQLLocalDB
+        SqlLocalDB info MSSQLLocalDB
+        sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database cakephp;"
+
+    - 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-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
+
+    - name: composer install
+      run: composer update
+
+    - name: Run PHPUnit
+      env:
+        db_dsn: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp'
+      run: |
+          vendor/bin/phpunit --verbose
+
+  cs-stan:
+    name: Coding Standard & Static Analysis
+    runs-on: ubuntu-18.04
+
+    steps:
+    - uses: actions/checkout@v1
+      with:
+        fetch-depth: 1
+
+    - name: Setup PHP
+      uses: shivammathur/setup-php@v2
+      with:
+        php-version: '7.2'
+        extensions: mbstring, intl, apcu
+        coverage: none
+
+    - name: Get composer cache directory
+      id: composer-cache
+      run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+    - name: Get date part for cache key
+      id: key-date
+      run: echo "::set-output name=date::$(date +'%Y-%m')"
+
+    - name: Cache composer dependencies
+      uses: actions/cache@v1
+      with:
+        path: ${{ steps.composer-cache.outputs.dir }}
+        key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
+
+    - name: composer install
+      run: |
+        composer update
+        composer phpstan-setup
+
+    - name: Run PHP CodeSniffer
+      run: composer cs-check
+
+    - name: Run phpstan
+      run: composer phpstan

+ 7 - 67
.travis.yml

@@ -2,25 +2,9 @@ language: php
 
 dist: xenial
 
-php:
-  - 5.6
-  - 7.4
-
-env:
-  matrix:
-    - DB=sqlite db_dsn='sqlite:///:memory:'
-    - DB=mysql db_dsn='mysql://root@127.0.0.1/cakephp_test?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'
-    - DB=pgsql db_dsn='postgres://postgres@127.0.0.1/cakephp_test'
-  global:
-    - DEFAULT=1
-    - CODECOVERAGE=0
-    - CHECKS=0
-
 services:
   - memcached
   - redis-server
-  - postgresql
-  - mysql
 
 cache:
   directories:
@@ -28,74 +12,30 @@ cache:
     - $HOME/.composer/cache
 
 matrix:
-  fast_finish: true
-
   include:
     - php: 5.6
-      env: PREFER_LOWEST=1
-
-    - php: 7.3
-      env: CHECKS=1 DEFAULT=0
-
-    - php: 7.3
-      env: CODECOVERAGE=1 DEFAULT=0
+      env: PREFER_LOWEST=1 DB=sqlite db_dsn='sqlite:///:memory:'
 
 before_install:
   - echo cakephp version && tail -1 VERSION.txt
   - phpenv config-rm xdebug.ini
 
-  - if [ $DB = 'mysql' ]; then mysql -u root -e 'CREATE DATABASE cakephp_test;'; fi
-  - if [ $DB = 'mysql' ]; then mysql -u root -e 'CREATE DATABASE cakephp_test2;'; fi
-  - if [ $DB = 'mysql' ]; then mysql -u root -e 'CREATE DATABASE cakephp_test3;'; fi
-
-  - if [ $DB = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi
-  - if [ $DB = 'pgsql' ]; then psql -c 'CREATE SCHEMA test2;' -U postgres -d cakephp_test; fi
-  - if [ $DB = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -U postgres -d cakephp_test; fi
-
-  - pecl channel-update pecl.php.net
-  - if [[ $CODECOVERAGE == 1 ]]; then pecl install pcov; fi
-  - |
-      if [[ ${TRAVIS_PHP_VERSION} != "5.6" ]]; then
-        echo 'extension = memcached.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
-      fi
   - echo 'extension = redis.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
   - echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
   - echo 'apc.enable_cli = 1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
 
-  - if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]] ; then echo "yes" | pecl install channel://pecl.php.net/apcu-5.1.17 || true; fi
-  - if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]] ; then echo "yes" | pecl install apcu-4.0.11 || true; fi
-  - |
-      if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" && $DB = 'mysql' ]]; then
-        wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/xcache/3.2.0-1build1/xcache_3.2.0.orig.tar.gz
-        tar xf xcache_3.2.0.orig.tar.gz
-        pushd xcache-3.2.0
-        phpize; ./configure
-        make
-        NO_INTERACTION=1 make test
-        make install
-        popd
-        printf "extension=xcache.so\nxcache.size=64M\nxcache.var_size=16M\nxcache.test=On" > ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-      fi
+  - echo "yes" | pecl install apcu-4.0.11 || true
+
   - sudo locale-gen da_DK
   - sudo locale-gen de_DE
 
 before_script:
-  - if [[ $CODECOVERAGE == 1 ]]; then composer require --dev pcov/clobber; fi
-  - if [[ $CODECOVERAGE == 0 && $PREFER_LOWEST != 1 ]]; then composer install --no-interaction; fi
-  - if [[ $PREFER_LOWEST == 1 ]]; then composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction; fi
-  - if [[ $PREFER_LOWEST == 1 ]]; then composer require --dev dereuromark/composer-prefer-lowest; fi
+  - composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction
+  - composer require --dev dereuromark/composer-prefer-lowest
 
 script:
-  - if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi
-  - if [[ $PREFER_LOWEST == 1 ]]; then vendor/bin/validate-prefer-lowest; fi
-
-  - if [[ $CODECOVERAGE == 1 ]]; then vendor/bin/pcov clobber; vendor/bin/phpunit --coverage-clover=clover.xml; fi
-
-  - if [[ $CHECKS == 1 ]]; then composer phpstan-setup && composer phpstan; fi
-  - if [[ $CHECKS == 1 ]]; then composer cs-check; fi
-
-after_success:
-  - if [[ $CODECOVERAGE == 1 ]]; then bash <(curl -s https://codecov.io/bash); fi
+  - vendor/bin/phpunit
+  - vendor/bin/validate-prefer-lowest
 
 notifications:
   email: false

+ 0 - 1
phpstan.neon

@@ -28,7 +28,6 @@ parameters:
         - '#Binary operation "\+" between array|false and array results in an error#'
         - '#Call to an undefined method DateTimeInterface::setTimezone\(\)#'
         - '#Access to undefined constant NumberFormatter::CURRENCY_ACCOUNTING#'
-        - '#Class APCuIterator referenced with incorrect case: APCUIterator#'
     earlyTerminatingMethodCalls:
         Cake\Console\Shell:
             - abort

+ 0 - 1
tests/TestCase/I18n/Formatter/IcuFormatterTest.php

@@ -104,7 +104,6 @@ class IcuFormatterTest extends TestCase
     public function testBadMessageFormatPHP7()
     {
         $this->expectException(\Exception::class);
-        $this->expectExceptionMessage('Constructor failed');
         $this->skipIf(version_compare(PHP_VERSION, '7', '<'));
 
         $formatter = new IcuFormatter();