From 65b5ad7af1d901da18631da58a4dbb8d03767ed7 Mon Sep 17 00:00:00 2001 From: Adrien Loison Date: Fri, 12 Nov 2021 14:35:26 +0100 Subject: [PATCH] Setup Github actions --- .github/workflows/ci.yml | 212 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 61 ----------- appveyor.yml | 35 ------- 3 files changed, 212 insertions(+), 96 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ac8a3b6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,212 @@ +name: Testing Spout +on: [push, pull_request] +jobs: + tests: + strategy: + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + php-versions: ['7.2', '7.3', '7.4', '8.0'] + runs-on: ${{ matrix.operating-system }} + name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} + env: + extensions: zip, xmlreader, dom + cache-key: cache-matrix-v1 # can be any string, change to clear the extension cache. + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ env.cache-key }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + + - 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@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Test with phpunit + run: vendor/bin/phpunit --no-coverage + + code-coverage: + name: Code coverage + runs-on: ubuntu-latest + env: + extensions: zip, xmlreader, dom + cache-key: cache-single-v1 # can be any string, change to clear the extension cache. + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: '7.4' + extensions: ${{ env.extensions }} + key: ${{ env.cache-key }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: ${{ env.extensions }} + + - 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@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Run Tests with Code Coverage + run: vendor/bin/phpunit --coverage-clover=build/logs/coverage.clover + + - name: Send to Scrutinizer + run: | + wget https://scrutinizer-ci.com/ocular.phar + php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.clover + + coding-style: + name: Coding Style + runs-on: ubuntu-latest + env: + extensions: zip, xmlreader, dom + cache-key: cache-single-v1 # can be any string, change to clear the extension cache. + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: '7.4' + extensions: ${{ env.extensions }} + key: ${{ env.cache-key }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: ${{ env.extensions }} + + - 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@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Run PHP-CS-Fixer + run: vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run --diff-format=udiff + + static-analysis: + name: Static Analysis + runs-on: ubuntu-latest + env: + extensions: zip, xmlreader, dom + cache-key: cache-single-v1 # can be any string, change to clear the extension cache. + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: '7.4' + extensions: ${{ env.extensions }} + key: ${{ env.cache-key }} + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: ${{ env.extensions }} + tools: phpstan + + - 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@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Static Analysis using PHPStan + run: phpstan analyse --no-progress src/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 365ee59..0000000 --- a/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -dist: bionic -sudo: false - -language: php - -matrix: - include: - - php: 7.2 - env: WITH_PHPUNIT=true - - php: 7.3 - env: WITH_PHPUNIT=true - - php: 7.3 - env: WITH_PHPUNIT=true WITH_COVERAGE=true - - php: 7.4 - env: WITH_PHPUNIT=true - - php: 8.0 - env: WITH_PHPUNIT=true - - -cache: - directories: - - $HOME/.composer/cache - - $HOME/.php-cs-fixer - -before_install: - - | - if [[ "$WITH_COVERAGE" != "true" ]]; then - phpenv config-rm xdebug.ini - fi - if [[ "$WITH_CS" != "true" ]]; then - composer remove friendsofphp/php-cs-fixer --dev --no-update - fi - - composer validate - -install: - - composer install --no-interaction --prefer-source - -before_script: - - mkdir -p "$HOME/.php-cs-fixer" - - mkdir -p build/logs - -script: - - | - if [[ "$WITH_CS" == "true" ]]; then - vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run --diff-format=udiff - fi - - | - if [[ "$WITH_PHPUNIT" == "true" ]]; then - if [[ "$WITH_COVERAGE" == "true" ]]; then - vendor/bin/phpunit --coverage-clover=build/logs/coverage.clover - else - vendor/bin/phpunit --no-coverage - fi - fi - -after_script: - - | - if [[ "$WITH_COVERAGE" == "true" ]]; then - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.clover - fi diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c5fe2ec..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,35 +0,0 @@ -build: false -clone_depth: 1 - -environment: - PHP_CHOCO_VERSION: 7.2.0 - PHP_CACHE_DIR: C:\tools\php - -cache: - - '%PHP_CACHE_DIR% -> appveyor.yml' - -init: - - SET PATH=%PHP_CACHE_DIR%;%PATH% - - SET COMPOSER_CACHE_DIR=%PHP_CACHE_DIR% - - SET COMPOSER_NO_INTERACTION=1 - - SET PHP=0 - - SET ANSICON=121x90 (121x90) - -install: - - IF EXIST %PHP_CACHE_DIR% (SET PHP=1) - - IF %PHP%==0 cinst php -y --version %PHP_CHOCO_VERSION% --params "/InstallDir:%PHP_CACHE_DIR%" - - IF %PHP%==0 cinst composer -y --ia "/DEV=%PHP_CACHE_DIR%" - - cd %PHP_CACHE_DIR% - - IF %PHP%==0 copy php.ini-production php.ini - - IF %PHP%==0 echo extension_dir=ext >> php.ini - - IF %PHP%==0 echo extension=php_fileinfo.dll >> php.ini - - IF %PHP%==0 echo extension=php_mbstring.dll >> php.ini - - IF %PHP%==0 echo extension=php_openssl.dll >> php.ini - - php -v - - IF %PHP%==0 (composer --version) ELSE (composer self-update) - - cd %APPVEYOR_BUILD_FOLDER% - - composer install --prefer-dist --no-progress - -test_script: - - cd %APPVEYOR_BUILD_FOLDER% - - vendor\bin\phpunit --colors=always