diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ae12412 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,100 @@ +name: Build + +on: + push: + branches: + - master + - release/* + - issue-* + pull_request: + branches: + - master + schedule: + - cron: 0 7 * * 1 + +jobs: + analysis: + runs-on: ubuntu-latest + strategy: + matrix: + php: [7.4] + steps: + - uses: actions/checkout@v1 + - name: Cache composer dependencies + uses: actions/cache@v2 + env: + cache-name: laravel-varnishable-composer-cache + with: + path: ~/.composer + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + - name: Install composer dependencies + run: composer install --prefer-dist + - name: Run phpstan analysis + run: composer phpstan-analysis + - name: Run phpmd analysis + run: composer phpmd-analysis + - name: Run phpcpd analysis + run: vendor/bin/phpcpd --min-lines=3 --min-tokens=36 src/ + phpunit: + needs: [analysis] + runs-on: ubuntu-latest + strategy: + matrix: + php: [7.3, 7.4, 8.0] + steps: + - uses: actions/checkout@v1 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + - name: Remove some dev dependencies + run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update + - name: Install composer dependencies + run: composer install --prefer-dist + - name: Run the test suite + run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit + phpunit-cov: + needs: [ analysis ] + runs-on: ubuntu-latest + strategy: + matrix: + php: [ 7.4 ] + steps: + - uses: actions/checkout@v1 + - name: Cache composer dependencies + uses: actions/cache@v2 + env: + cache-name: laravel-varnishable-composer-cache + with: + path: ~/.composer + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + - name: Install composer dependencies + run: composer install --prefer-dist + - name: Run the Coverage test suite + run: phpdbg -qrr -dmemory_limit=3G vendor/bin/phpunit --coverage-clover=clover.xml + - name: Upload test coverage report to codecov.io + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: bash <(curl -s https://codecov.io/bash) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ea96717..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: php -os: linux -dist: bionic - -matrix: - fast_finish: true - include: - - php: 7.3 - env: LARAVEL=^8.0 ORCHESTRA=^6.0 - - php: 7.4 - env: LARAVEL=^8.0 ORCHESTRA=^6.0 COVERAGE=1 - - allow_failures: - - env: COVERAGE=1 - -before_install: - - phpenv config-rm xdebug.ini - - travis_retry composer self-update - -before_script: - - if [[ -v LARAVEL ]]; then composer require laravel/framework:$LARAVEL --no-update; fi - - if [[ -v ORCHESTRA ]]; then composer require orchestra/testbench:$ORCHESTRA --no-update; fi - - - travis_retry composer install --no-interaction --prefer-source - - phpenv rehash - - set +H - -script: - - composer analyse - - if [[ $COVERAGE != '1' ]]; then vendor/bin/phpunit; fi - - if [[ $COVERAGE = '1' ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=clover.xml; fi - -after_script: - - if [[ $COVERAGE = '1' ]]; then bash <(curl -s https://codecov.io/bash); fi - -notifications: - email: false diff --git a/composer.json b/composer.json index 9be77a8..ff872b6 100644 --- a/composer.json +++ b/composer.json @@ -21,21 +21,21 @@ "source": "https://github.com/richan-fongdasen/laravel-varnishable" }, "require": { - "php": "^7.3", - "guzzlehttp/guzzle": "~7.0", + "php": "^7.3||^8.0", + "guzzlehttp/guzzle": "^7.3", "illuminate/database": "^8.0", "illuminate/support": "^8.0" }, "require-dev": { - "ekino/phpstan-banned-code": "^0.3.1", - "mockery/mockery": "~1.3", + "ekino/phpstan-banned-code": "^0.4", + "mockery/mockery": "^1.4", "orchestra/database": "^6.0", "orchestra/testbench": "^6.0", - "phpmd/phpmd": "^2.9", + "phpmd/phpmd": "^2.10", "phpstan/phpstan": "^0.12", "phpstan/phpstan-deprecation-rules": "^0.12", "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^9.5", "sebastian/phpcpd": "^6.0" }, "config": { diff --git a/src/Events/ModelHasUpdated.php b/src/Events/ModelHasUpdated.php index 36839f5..5a7b703 100644 --- a/src/Events/ModelHasUpdated.php +++ b/src/Events/ModelHasUpdated.php @@ -73,7 +73,7 @@ protected function getQuery(Model $model): Builder { $query = $model->newQuery(); - $traits = class_uses($model); + $traits = collect(class_uses($model))->toArray(); if (in_array(SoftDeletes::class, $traits, true)) { $query->withTrashed();