diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 575d73a..e2740a4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,7 +14,7 @@ Fixes # (issue) - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I wrote unit tests for my code +- [ ] I wrote unit tests for my code _(if tests is required for my changes)_ - [ ] I have made changes in [CHANGELOG.md](https://github.com/avto-dev/data-migrations-laravel/blob/master/CHANGELOG.md) file > About your changes in `CHANGELOG.md`: diff --git a/.github/workflows/execute-tests.yml b/.github/workflows/execute-tests.yml new file mode 100644 index 0000000..2eb717a --- /dev/null +++ b/.github/workflows/execute-tests.yml @@ -0,0 +1,46 @@ +name: Execute tests + +on: + push: + branches: + - master + tags-ignore: + - '**' + pull_request: + +jobs: # Docs: + tests: + name: PHP ${{ matrix.php }}, ${{ matrix.setup }} setup + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + setup: ['basic', 'lowest'] + php: ['7.1', '7.2', '7.3'] + steps: + - name: Check out code + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@master # Action page: + with: + php-version: ${{ matrix.php }} + + - name: Install Composer 'hirak/prestissimo' package + run: composer global require hirak/prestissimo --update-no-dev + + - name: Install lowest Composer dependencies + if: matrix.setup == 'lowest' + run: composer update --prefer-dist --no-interaction --no-suggest --prefer-lowest + + - name: Install basic Composer dependencies + if: matrix.setup == 'basic' + run: composer update --prefer-dist --no-interaction --no-suggest + + - name: Show most important packages versions + run: composer info | grep -e laravel/laravel -e phpunit/phpunit -e phpstan/phpstan + + - name: Execute tests + run: composer test diff --git a/.travis.yml b/.travis.yml index 018e19f..309825d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ env: - setup=basic - coverage=false - laravel=default + - phpunit=default sudo: false @@ -25,6 +26,7 @@ install: - if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable; fi - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-lowest; fi - if [[ $laravel != 'default' ]]; then travis_retry composer require --dev --update-with-dependencies --prefer-dist --no-interaction --no-suggest laravel/laravel "$laravel"; fi + - if [[ $phpunit != 'default' ]]; then travis_retry composer require --dev --update-with-dependencies --prefer-dist --no-interaction --no-suggest phpunit/phpunit "$phpunit"; fi - composer info | grep -e laravel/laravel -e phpunit/phpunit -e phpstan/phpstan script: @@ -35,35 +37,34 @@ after_success: matrix: include: - - php: 7.1.3 - php: 7.1.3 env: setup=lowest - php: 7.1.3 - env: laravel=5.6 + env: laravel=5.5 phpunit=~6.4 - php: 7.1.3 - env: laravel=5.7 + env: laravel=5.6 - php: 7.1.3 env: coverage=true - - php: 7.2 - php: 7.2 env: setup=lowest - php: 7.2 - env: laravel=5.6 + env: laravel=5.8 - php: 7.2 - env: laravel=5.7 - - php: 7.2 - env: coverage=true + env: coverage=true laravel=6.* - - php: 7.3 - php: 7.3 env: setup=lowest + - php: 7.3 + env: laravel=5.5 phpunit=~6.4 - php: 7.3 env: laravel=5.6 - php: 7.3 env: laravel=5.7 - php: 7.3 - env: coverage=true + env: laravel=5.8 + - php: 7.3 + env: coverage=true laravel=6.* - php: nightly diff --git a/CHANGELOG.md b/CHANGELOG.md index 16a366b..22b1f7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver]. +## v2.1.0 + +### Changed + +- Maximal `illuminate/*` packages version now is `6.*` + +### Added + +- GitHub actions for a tests running + ## v2.0.0 ### Added diff --git a/Dockerfile b/Dockerfile index 4c0079f..50a4af5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM composer:1.8.6 AS composer -FROM php:7.1.3-alpine +FROM php:7.2.0-alpine ENV \ COMPOSER_ALLOW_SUPERUSER="1" \ diff --git a/composer.json b/composer.json index 04c7f5a..dc3999f 100644 --- a/composer.json +++ b/composer.json @@ -17,18 +17,18 @@ "require": { "php": "^7.1.3", "ext-pdo": "*", - "illuminate/support": ">=5.5.0 <5.9.0", - "illuminate/config": ">=5.5.0 <5.9.0", - "illuminate/database": ">=5.5.0 <5.9.0", - "illuminate/filesystem": ">=5.5.0 <5.9.0", - "illuminate/console": ">=5.5.0 <5.9.0", - "illuminate/contracts": ">=5.5.0 <5.9.0" + "illuminate/support": ">=5.5.0 <5.9.0 || ~6.0", + "illuminate/config": ">=5.5.0 <5.9.0 || ~6.0", + "illuminate/database": ">=5.5.0 <5.9.0 || ~6.0", + "illuminate/filesystem": ">=5.5.0 <5.9.0 || ~6.0", + "illuminate/console": ">=5.5.0 <5.9.0 || ~6.0", + "illuminate/contracts": ">=5.5.0 <5.9.0 || ~6.0" }, "require-dev": { "ext-pdo_sqlite": "*", "ext-sqlite3": "*", "ext-zlib": "*", - "laravel/laravel": ">=5.5.0 <5.9.0", + "laravel/laravel": ">=5.5.0 <5.9.0 || ~6.0", "mockery/mockery": "^1.0", "phpstan/phpstan": "^0.11.3", "phpunit/phpunit": "^6.4 || ~7.5" diff --git a/src/Commands/MigrateCommand.php b/src/Commands/MigrateCommand.php index 90d4f33..87cd288 100644 --- a/src/Commands/MigrateCommand.php +++ b/src/Commands/MigrateCommand.php @@ -4,6 +4,7 @@ namespace AvtoDev\DataMigrationsLaravel\Commands; +use Illuminate\Support\Arr; use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; use AvtoDev\DataMigrationsLaravel\Migrator; @@ -47,7 +48,7 @@ public function handle(MigratorContract $migrator): void $this->call('data-migrate:install'); } - if (! empty($need_to_migrate = array_flatten($migrator->needToMigrateList()))) { + if (! empty($need_to_migrate = Arr::flatten($migrator->needToMigrateList()))) { /** @var ProgressBar|null $progress */ $progress = null; diff --git a/src/Commands/StatusCommand.php b/src/Commands/StatusCommand.php index 1170b0d..8c557e8 100644 --- a/src/Commands/StatusCommand.php +++ b/src/Commands/StatusCommand.php @@ -4,6 +4,7 @@ namespace AvtoDev\DataMigrationsLaravel\Commands; +use Illuminate\Support\Arr; use Illuminate\Console\Command; use AvtoDev\DataMigrationsLaravel\Contracts\SourceContract; use AvtoDev\DataMigrationsLaravel\Contracts\RepositoryContract; @@ -40,7 +41,7 @@ public function handle(RepositoryContract $repository, SourceContract $source): return; } - $summary = array_unique(array_merge($migrated = $repository->migrations(), array_flatten($source->all()))); + $summary = array_unique(array_merge($migrated = $repository->migrations(), Arr::flatten($source->all()))); if (\count($summary) > 0) { $table_rows = array_map(function ($migration_name) use (&$migrated) { diff --git a/src/Migrator.php b/src/Migrator.php index c0e7220..b57a283 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -74,7 +74,7 @@ public function migrate(?string $connection_name = null, ?Closure $migrating_clo { $migrated = []; - if (! empty($all_migrations = array_flatten($not_migrated = $this->needToMigrateList()))) { + if (! empty($all_migrations = Arr::flatten($not_migrated = $this->needToMigrateList()))) { // Leave only passed connection name, if passed if ($connection_name !== null) { $not_migrated = array_filter($not_migrated, function ($not_migrated_connection) use ($connection_name) { diff --git a/tests/Commands/MigrateCommandTest.php b/tests/Commands/MigrateCommandTest.php index d2f4667..e82e634 100644 --- a/tests/Commands/MigrateCommandTest.php +++ b/tests/Commands/MigrateCommandTest.php @@ -3,6 +3,7 @@ namespace AvtoDev\DataMigrationsLaravel\Tests\Commands; use Mockery as m; +use Illuminate\Support\Arr; use Illuminate\Contracts\Console\Kernel; use AvtoDev\DataMigrationsLaravel\Commands\MigrateCommand; use AvtoDev\DataMigrationsLaravel\Contracts\MigratorContract; @@ -48,7 +49,7 @@ public function testRepositoryAutoCreation(): void public function testCommandExecution(): void { $not_migrated = ['2000_01_01_000020_simple_sql_data.sql']; - $all = array_flatten($this->migrator->source()->all()); + $all = Arr::flatten($this->migrator->source()->all()); $filtered = array_filter($all, function ($migration_name) use (&$not_migrated) { return ! in_array($migration_name, $not_migrated, true); }); diff --git a/tests/Commands/StatusCommandTest.php b/tests/Commands/StatusCommandTest.php index 2a89e97..9511c0c 100644 --- a/tests/Commands/StatusCommandTest.php +++ b/tests/Commands/StatusCommandTest.php @@ -2,6 +2,7 @@ namespace AvtoDev\DataMigrationsLaravel\Tests\Commands; +use Illuminate\Support\Arr; use AvtoDev\DataMigrationsLaravel\Contracts\MigratorContract; use AvtoDev\DataMigrationsLaravel\DataMigrationsServiceProvider; @@ -33,7 +34,7 @@ public function setUp(): void public function testCommandExecution(): void { $not_migrated = ['2000_01_01_000020_simple_sql_data.sql']; - $all = array_flatten($this->migrator->source()->all()); + $all = Arr::flatten($this->migrator->source()->all()); $filtered = array_filter($all, function ($migration_name) use (&$not_migrated) { return ! in_array($migration_name, $not_migrated, true); }); diff --git a/tests/MigratorTest.php b/tests/MigratorTest.php index 37dfed3..3bc5770 100644 --- a/tests/MigratorTest.php +++ b/tests/MigratorTest.php @@ -2,6 +2,7 @@ namespace AvtoDev\DataMigrationsLaravel\Tests; +use Illuminate\Support\Arr; use AvtoDev\DataMigrationsLaravel\Migrator; use AvtoDev\DataMigrationsLaravel\Sources\Files; use AvtoDev\DataMigrationsLaravel\Contracts\SourceContract; @@ -224,7 +225,7 @@ protected function assertRepositoryHasNotMigrations(array $migrations_names) */ protected function initRepositoryExcepts(array $migrations_names) { - $all = array_flatten($this->migrator->source()->all()); + $all = Arr::flatten($this->migrator->source()->all()); $filtered = array_filter($all, function ($migration_name) use (&$migrations_names) { return ! in_array($migration_name, $migrations_names, true); });