From eb3774b91bcb68c95fc54074bdbc109a9957e19f Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 3 Nov 2021 20:11:18 +0545 Subject: [PATCH] Implement GitHub wokflow for CI --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 45 ------------------------------------- composer.json | 9 ++++++-- 3 files changed, 55 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..46d9c93 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: continuous-integration +on: + push: + branches: + - master + - release/* + pull_request: +jobs: + code-analysis: + name: Code Analysis (PHP ${{ matrix.php-versions }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, dom, fileinfo, mysql, redis, opcache + coverage: ${{ matrix.coverage }} + tools: composer + + - 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 composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Code Analysis (PHP CS-Fixer) + run: php vendor/bin/php-cs-fixer fix --dry-run --diff + + - name: Code Analysis (PHPStan) + run: composer phpstan diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0e18ecf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: php -dist: trusty -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - -env: - global: - - RUN_PHPSTAN="FALSE" - matrix: - - PREFER_LOWEST="" - - PREFER_LOWEST="--prefer-lowest" - -install: - - if [ $RUN_PHPSTAN == "TRUE" ]; then composer require --dev phpstan/phpstan:^0.12; fi - -matrix: - include: - - name: 'PHPStan' - php: 7.4 - env: - - RUN_PHPSTAN="TRUE" - fast_finish: true - -services: - - mysql - -sudo: false - -before_script: - # - mysql -e 'create database sabredav' - - rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - # - composer self-update - - composer update $PREFER_LOWEST - -script: - - if [ $RUN_PHPSTAN == "FALSE" ]; then find Core -name "*.php" | xargs -n1 php -l; fi - - if [ $RUN_PHPSTAN == "FALSE" ]; then php vendor/bin/php-cs-fixer fix --dry-run --diff; fi - - if [ $RUN_PHPSTAN == "TRUE" ]; then php vendor/bin/phpstan.phar analyse Core html; fi - -cache: - directories: - - $HOME/.composer/cache diff --git a/composer.json b/composer.json index 243dca8..929e6ae 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "symfony/yaml" : "^3.4" }, "require-dev" : { - "friendsofphp/php-cs-fixer": "2.18.0" + "friendsofphp/php-cs-fixer": "2.18.0", + "phpstan/phpstan": "^0.12" }, "replace" : { "jeromeschneider/baikal" : "self.version" @@ -38,8 +39,12 @@ "cs-fixer": [ "php-cs-fixer fix" ], + "phpstan": [ + "phpstan analyse Core html" + ], "test": [ - "composer cs-fixer" + "composer cs-fixer", + "composer phpstan" ] } }