From 78b30a91286e13678dbe56efabd596e2b5bcc1d4 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Sun, 17 Mar 2024 22:11:38 -0400 Subject: [PATCH] Laravel 11.x Compatibility (#402) * Bump dependencies for Laravel 11 * Update GitHub Actions for Laravel 11 * update actions * fix mem tests * L11 include options * update action versions * wip * rm refresh db --------- Co-authored-by: Chris Gmyr --- .github/workflows/php-cs-fixer.yml | 4 +- .github/workflows/run-tests-mysql.yml | 42 +++++----- .github/workflows/run-tests-postgres.yml | 49 ++++++------ .github/workflows/run-tests.yml | 99 ++++++++++++++---------- composer.json | 10 +-- tests/TestCase.php | 2 - 6 files changed, 112 insertions(+), 94 deletions(-) diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 27bc04e..6350ebe 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} @@ -18,6 +18,6 @@ jobs: args: --config=.php-cs-fixer.php --allow-risky=yes - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Fix styling \ No newline at end of file diff --git a/.github/workflows/run-tests-mysql.yml b/.github/workflows/run-tests-mysql.yml index 5916e99..fe815ee 100644 --- a/.github/workflows/run-tests-mysql.yml +++ b/.github/workflows/run-tests-mysql.yml @@ -1,23 +1,21 @@ name: MySQL Tests -on: [push, pull_request] +on: + - push + - pull_request jobs: laravel-tests: runs-on: ubuntu-latest - # Service container Mysql mysql + services: - # Label used to access the service container mysql: - # Docker Hub image (also with version) image: mysql:8.0 env: MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: db_test_laravel - ## map the "external" 33306 port with the "internal" 3306 + MYSQL_DATABASE: db_test_laravel ports: - 33306:3306 - # Set health checks to wait until mysql database has started (it takes some seconds to start) options: >- --health-cmd="mysqladmin ping" --health-interval=10s @@ -28,50 +26,54 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: [ '8.3', '8.2', '8.1' ] - dependency-stability: [ prefer-stable ] - - laravel: [ '10.*', '9.*' ] + php-versions: ['8.1', '8.2', '8.3'] + dependency-stability: [prefer-stable] + laravel: ['9.*', '10.*', '11.*'] include: + - laravel: 9.* + testbench: 7.* - laravel: 10.* testbench: 8.* - - laravel: 9.* - testbench: 7.* + - laravel: 11.* + testbench: 9.* exclude: - laravel: 10.* php-versions: 8.0 + - laravel: 11.* + php-versions: 8.1 name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Install PHP versions uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} + - name: Get Composer Cache Directory 2 id: composer-cache run: | echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + + - uses: actions/cache@v4 id: actions-cache with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- + - name: Install Laravel Dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev + composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction - # Code quality - name: Execute tests (Unit and Feature tests) via PHPUnit - # Set environment env: DB_CONNECTION: mysql DB_DATABASE: db_test_laravel DB_PORT: 33306 DB_USERNAME: root - run: vendor/bin/phpunit --testdox diff --git a/.github/workflows/run-tests-postgres.yml b/.github/workflows/run-tests-postgres.yml index 201cde3..a04b29e 100644 --- a/.github/workflows/run-tests-postgres.yml +++ b/.github/workflows/run-tests-postgres.yml @@ -1,24 +1,22 @@ -name: PostgreSQL Tests +name: PostgreSQL Tests -on: [push, pull_request] +on: + - push + - pull_request jobs: laravel-tests: runs-on: ubuntu-latest - # Service container Postgresql postgresql + services: - # Label used to access the service container postgres: - # Docker Hub image (also with version) image: postgres:latest env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - POSTGRES_DB: db_test_laravel - ## map the "external" 55432 port with the "internal" 5432 + POSTGRES_DB: db_test_laravel ports: - 55432:5432 - # Set health checks to wait until postgresql database has started (it takes some seconds to start) options: >- --health-cmd pg_isready --health-interval 10s @@ -29,63 +27,68 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: [ '8.3', '8.2', '8.1' ] - dependency-stability: [ prefer-stable ] - - laravel: [ '10.*', '9.*'] + php-versions: ['8.1', '8.2', '8.3'] + dependency-stability: [prefer-stable] + laravel: ['9.*', '10.*', '11.*'] include: + - laravel: 9.* + testbench: 7.* - laravel: 10.* testbench: 8.* - - laravel: 9.* - testbench: 7.* + - laravel: 11.* + testbench: 9.* exclude: - laravel: 10.* php-versions: 8.0 + - laravel: 11.* + php-versions: 8.1 name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Install PHP versions uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} + - name: Get Composer Cache Directory 2 id: composer-cache run: | echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + + - uses: actions/cache@v4 id: actions-cache with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- + - name: Cache PHP dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 id: vendor-cache with: path: vendor key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} + - name: Install Laravel Dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest - + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev + composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction - name: Show dir run: pwd + - name: PHP Version run: php --version - # Code quality - name: Execute tests (Unit and Feature tests) via PHPUnit - # Set environment env: DB_CONNECTION: pgsql DB_DATABASE: db_test_laravel DB_PORT: 55432 DB_USERNAME: postgres DB_PASSWORD: postgres - run: vendor/bin/phpunit --testdox diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fd1fa00..38c052d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,6 +1,8 @@ name: SQLite Tests -on: [push, pull_request] +on: + - push + - pull_request jobs: laravel-tests: @@ -10,34 +12,44 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: [ '8.3', '8.2', '8.1', '8.0', '7.4', '7.3', '7.2' ] - dependency-stability: [ prefer-stable ] - laravel: [ '10.*', '9.*', '8.*', '7.*', '6.*' ] - + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + dependency-stability: [prefer-stable] + laravel: ['6.*', '7.*', '8.*', '9.*', '10.*', '11.*'] include: + - laravel: 6.* + testbench: 4.* + dbal: ^2.6 + - laravel: 7.* + testbench: 5.* + dbal: ^2.6 + - laravel: 8.* + testbench: 6.* + dbal: ^3.1.2|^2.13.3 + - laravel: 9.* + testbench: 7.* + dbal: ^3.1.2 - laravel: 10.* testbench: 8.* dbal: ^3.1.2 - - laravel: 9.* - testbench: 7.* + - laravel: 11.* + testbench: 9.* dbal: ^3.1.2 - - laravel: 8.* - testbench: 6.* - dbal: ^3.1.2|^2.13.3 - - laravel: 7.* - testbench: 5.* - dbal: ^2.6 - - laravel: 6.* - testbench: 4.* - dbal: ^2.6 exclude: - - laravel: 10.* + - laravel: 6.* + php-versions: 8.1 + - laravel: 6.* + php-versions: 8.2 + - laravel: 6.* + php-versions: 8.3 + - laravel: 7.* + php-versions: 8.1 + - laravel: 7.* + php-versions: 8.2 + - laravel: 7.* + php-versions: 8.3 + - laravel: 7.* php-versions: 8.0 - - laravel: 10.* - php-versions: 7.4 - - laravel: 10.* - php-versions: 7.3 - - laravel: 10.* + - laravel: 8.* php-versions: 7.2 - laravel: 9.* php-versions: 7.2 @@ -45,52 +57,55 @@ jobs: php-versions: 7.3 - laravel: 9.* php-versions: 7.4 - - laravel: 8.* + - laravel: 10.* + php-versions: 8.0 + - laravel: 10.* php-versions: 7.2 - - laravel: 7.* - php-versions: 8.3 - - laravel: 7.* - php-versions: 8.2 - - laravel: 7.* - php-versions: 8.1 - - laravel: 7.* + - laravel: 10.* + php-versions: 7.3 + - laravel: 10.* + php-versions: 7.4 + - laravel: 11.* php-versions: 8.0 - - laravel: 6.* - php-versions: 8.3 - - laravel: 6.* - php-versions: 8.2 - - laravel: 6.* + - laravel: 11.* php-versions: 8.1 + - laravel: 11.* + php-versions: 7.2 + - laravel: 11.* + php-versions: 7.3 + - laravel: 11.* + php-versions: 7.4 name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Install PHP versions uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} + - name: Get Composer Cache Directory 2 id: composer-cache run: | echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + + - uses: actions/cache@v4 id: actions-cache with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- + - name: Install Laravel Dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "doctrine/dbal:${{ matrix.dbal }}" --no-interaction --no-update - composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "doctrine/dbal:${{ matrix.dbal }}" --no-interaction --no-update --dev + composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction - # Code quality - name: Execute tests (Unit and Feature tests) via PHPUnit - # Set environment env: DB_CONNECTION: sqlite DB_DATABASE: ":memory:" - run: vendor/bin/phpunit --testdox diff --git a/composer.json b/composer.json index d5bc01e..f4b6479 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,16 @@ ], "require": { "php": "^7.2|^8.0", - "illuminate/config": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/database": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0", - "illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0" + "illuminate/config": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/database": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0" }, "require-dev": { "doctrine/dbal": "^3.1.2|^2.13.3", "fakerphp/faker": "^1.16|^1.9.1", "friendsofphp/php-cs-fixer": "^3.2|^2.18", - "orchestra/testbench": "^3.0|^4.0|^5.0|^6.0|^7.0|^8.0", - "phpunit/phpunit": "^8.0|^9.3.3" + "orchestra/testbench": "^3.0|^4.0|^5.0|^6.0|^7.0|^8.0|^9.0", + "phpunit/phpunit": "^8.0|^9.3.3|^10.5" }, "autoload": { "psr-4": { diff --git a/tests/TestCase.php b/tests/TestCase.php index 233b406..10f051e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,13 +7,11 @@ use Cmgmyr\Messenger\Models\Participant; use Cmgmyr\Messenger\Models\Thread; use Illuminate\Database\Eloquent\Model as Eloquent; -use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Orchestra\Testbench\TestCase as OrchestraTestCase; class TestCase extends OrchestraTestCase { - use RefreshDatabase; use WithFaker; protected $loadEnvironmentVariables = true;