Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] CI Improvements #52851

Merged
merged 21 commits into from
Sep 24, 2024
94 changes: 48 additions & 46 deletions .github/workflows/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ jobs:

mssql_2019:
runs-on: ubuntu-22.04
timeout-minutes: 5

services:
sqlsrv:
Expand Down Expand Up @@ -292,52 +293,53 @@ jobs:
DB_USERNAME: SA
DB_PASSWORD: Forge123

# mssql_2017:
# runs-on: ubuntu-22.04

# services:
# sqlsrv:
# image: mcr.microsoft.com/mssql/server:2017-latest
# env:
# ACCEPT_EULA: Y
# SA_PASSWORD: Forge123
# ports:
# - 1433:1433

# strategy:
# fail-fast: true

# name: SQL Server 2017

# steps:
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: 8.2
# extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlsrv, pdo, pdo_sqlsrv, odbc, pdo_odbc, :php-psr
# tools: composer:v2
# coverage: none

# - name: Set Framework version
# run: composer config version "11.x-dev"

# - name: Install dependencies
# uses: nick-fields/retry@v3
# with:
# timeout_minutes: 5
# max_attempts: 5
# command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

# - name: Execute tests
# run: vendor/bin/phpunit tests/Integration/Database
# env:
# DB_CONNECTION: sqlsrv
# DB_DATABASE: master
# DB_USERNAME: SA
# DB_PASSWORD: Forge123
mssql_2017:
runs-on: ubuntu-20.04
timeout-minutes: 5

services:
sqlsrv:
image: mcr.microsoft.com/mssql/server:2017-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: Forge123
ports:
- 1433:1433

strategy:
fail-fast: true

name: SQL Server 2017

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, sqlsrv, pdo, pdo_sqlsrv, odbc, pdo_odbc, :php-psr
tools: composer:v2
coverage: none

- name: Set Framework version
run: composer config version "11.x-dev"

- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Database
env:
DB_CONNECTION: sqlsrv
DB_DATABASE: master
DB_USERNAME: SA
DB_PASSWORD: Forge123

sqlite:
runs-on: ubuntu-24.04
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/queues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ jobs:
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Setup SQLite Database
run: php vendor/bin/testbench package:create-sqlite-db

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Queue
env:
DB_CONNECTION: testing
DB_CONNECTION: sqlite
QUEUE_CONNECTION: database

redis:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"league/flysystem-sftp-v3": "^3.0",
"mockery/mockery": "^1.6",
"nyholm/psr7": "^1.2",
"orchestra/testbench-core": "^9.4.0",
"orchestra/testbench-core": "^9.5",
"pda/pheanstalk": "^5.0",
"phpstan/phpstan": "^1.11.5",
"phpunit/phpunit": "^10.5|^11.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Illuminate\Tests\Integration\Database;
namespace Illuminate\Tests\Database;

use Brick\Math\BigNumber;
use GMP;
Expand Down
9 changes: 3 additions & 6 deletions tests/Integration/Database/MariaDb/MariaDbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
namespace Illuminate\Tests\Integration\Database\MariaDb;

use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\RequiresDatabase;

#[RequiresDatabase('mariadb')]
abstract class MariaDbTestCase extends DatabaseTestCase
{
protected function defineDatabaseMigrations()
{
if ($this->driver !== 'mariadb') {
$this->markTestSkipped('Test requires a MariaDB connection.');
}
}
//
}
9 changes: 3 additions & 6 deletions tests/Integration/Database/MySql/MySqlTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
namespace Illuminate\Tests\Integration\Database\MySql;

use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\RequiresDatabase;

#[RequiresDatabase('mysql')]
abstract class MySqlTestCase extends DatabaseTestCase
{
protected function defineDatabaseMigrations()
{
if ($this->driver !== 'mysql') {
$this->markTestSkipped('Test requires a MySQL connection.');
}
}
//
}
6 changes: 2 additions & 4 deletions tests/Integration/Database/Postgres/FulltextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\RequiresDatabase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;

Expand Down Expand Up @@ -50,12 +51,9 @@ public function testWhereFulltext()
$this->assertSame('PostgreSQL vs. YourSQL', $articles[1]->title);
}

#[RequiresDatabase('pgsql', '>=11.0')]
public function testWhereFulltextWithWebsearch()
{
if (version_compare($this->getConnection()->getServerVersion(), '11.0', '<')) {
$this->markTestSkipped('Test requires a PostgreSQL connection >= 11.0');
}

$articles = DB::table('articles')->whereFulltext(['title', 'body'], '+PostgreSQL -YourSQL', ['mode' => 'websearch'])->get();

$this->assertCount(5, $articles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\RequiresDatabase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;

Expand Down Expand Up @@ -165,12 +166,9 @@ public function testGetViews()
}));
}

#[RequiresDatabase('pgsql', '>=11.0')]
public function testDropPartitionedTables()
{
if (version_compare($this->getConnection()->getServerVersion(), '11.0', '<')) {
$this->markTestSkipped('Test requires a PostgreSQL connection >= 11.0');
}

DB::statement('create table groups (id bigserial, tenant_id bigint, name varchar, primary key (id, tenant_id)) partition by hash (tenant_id)');
DB::statement('create table groups_1 partition of groups for values with (modulus 2, remainder 0)');
DB::statement('create table groups_2 partition of groups for values with (modulus 2, remainder 1)');
Expand Down
9 changes: 3 additions & 6 deletions tests/Integration/Database/Postgres/PostgresTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
namespace Illuminate\Tests\Integration\Database\Postgres;

use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\RequiresDatabase;

#[RequiresDatabase('pgsql')]
abstract class PostgresTestCase extends DatabaseTestCase
{
protected function defineDatabaseMigrations()
{
if ($this->driver !== 'pgsql') {
$this->markTestSkipped('Test requires a PostgreSQL connection.');
}
}
//
}
12 changes: 5 additions & 7 deletions tests/Integration/Database/Queue/BatchableTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\DB;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Process\Exception\ProcessSignaledException;
Expand All @@ -15,21 +16,18 @@

#[RequiresPhpExtension('pcntl')]
#[WithMigration('laravel', 'queue')]
#[WithConfig('queue.default', 'database')]
class BatchableTransactionTest extends DatabaseTestCase
{
use DatabaseMigrations;

protected function defineEnvironment($app)
protected function setUp(): void
{
parent::defineEnvironment($app);
parent::setUp();

$config = $app['config'];

if ($config->get('database.default') === 'testing') {
if ($this->usesSqliteInMemoryDatabaseConnection()) {
$this->markTestSkipped('Test does not support using :memory: database connection');
}

$config->set(['queue.default' => 'database']);
}

public function testItCanHandleTimeoutJob()
Expand Down
12 changes: 5 additions & 7 deletions tests/Integration/Database/Queue/QueueTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\DB;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Process\Exception\ProcessSignaledException;
Expand All @@ -14,21 +15,18 @@

#[RequiresPhpExtension('pcntl')]
#[WithMigration('laravel', 'queue')]
#[WithConfig('queue.default', 'database')]
class QueueTransactionTest extends DatabaseTestCase
{
use DatabaseMigrations;

protected function defineEnvironment($app)
protected function setUp(): void
{
parent::defineEnvironment($app);
parent::setUp();

$config = $app['config'];

if ($config->get('database.default') === 'testing') {
if ($this->usesSqliteInMemoryDatabaseConnection()) {
$this->markTestSkipped('Test does not support using :memory: database connection');
}

$config->set(['queue.default' => 'database']);
}

public function testItCanHandleTimeoutJob()
Expand Down
21 changes: 5 additions & 16 deletions tests/Integration/Database/SchemaBuilderSchemaNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\RequiresDatabase;
use PHPUnit\Framework\Attributes\DataProvider;

#[RequiresDatabase(['pgsql', 'sqlsrv'])]
class SchemaBuilderSchemaNameTest extends DatabaseTestCase
{
protected function defineDatabaseMigrations()
{
if (! in_array($this->driver, ['pgsql', 'sqlsrv'])) {
$this->markTestSkipped('Test requires a PostgreSQL or SQL Server connection.');
}

if ($this->driver === 'pgsql') {
DB::connection('without-prefix')->statement('create schema if not exists my_schema');
DB::connection('with-prefix')->statement('create schema if not exists my_schema');
Expand Down Expand Up @@ -372,12 +370,9 @@ public function testHasView($connection)
}

#[DataProvider('connectionProvider')]
#[RequiresDatabase('pgsql')]
public function testComment($connection)
{
if ($this->driver !== 'pgsql') {
$this->markTestSkipped('Test requires a PostgreSQL connection.');
}

$schema = Schema::connection($connection);

$schema->create('my_schema.table', function (Blueprint $table) {
Expand Down Expand Up @@ -407,12 +402,9 @@ public function testComment($connection)
}

#[DataProvider('connectionProvider')]
#[RequiresDatabase('pgsql')]
public function testAutoIncrementStartingValue($connection)
{
if ($this->driver !== 'pgsql') {
$this->markTestSkipped('Test requires a PostgreSQL connection.');
}

$this->expectNotToPerformAssertions();

$schema = Schema::connection($connection);
Expand All @@ -426,12 +418,9 @@ public function testAutoIncrementStartingValue($connection)
}

#[DataProvider('connectionProvider')]
#[RequiresDatabase('sqlsrv')]
public function testHasTable($connection)
{
if ($this->driver !== 'sqlsrv') {
$this->markTestSkipped('Test requires a SQL Server connection.');
}

$db = DB::connection($connection);
$schema = $db->getSchemaBuilder();

Expand Down
Loading