diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1e3d221 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + checks: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2', '8.3'] + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: gen_queue_test + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping -proot" + --health-interval=5s + --health-timeout=5s + --health-retries=20 + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mysqli + coverage: none + tools: composer:v2 + - name: Install + run: composer update --no-interaction --no-progress --prefer-dist + - name: Lint + run: find src tests examples gen-queue.php autoload.php uninstall.php -name '*.php' -print0 | xargs -0 -n1 php -l + - name: PHP_CodeSniffer + run: composer lint + - name: PHPStan + run: composer analyse + - name: Unit tests + run: vendor/bin/phpunit --testsuite unit + - name: Integration tests (MySQL 8.0) + env: + GEN_QUEUE_TEST_DB_HOST: 127.0.0.1 + GEN_QUEUE_TEST_DB_USER: root + GEN_QUEUE_TEST_DB_PASSWORD: root + GEN_QUEUE_TEST_DB_NAME: gen_queue_test + run: vendor/bin/phpunit --testsuite integration diff --git a/tests/Unit/RegistrationTest.php b/tests/Unit/RegistrationTest.php index 967c309..55fa76e 100644 --- a/tests/Unit/RegistrationTest.php +++ b/tests/Unit/RegistrationTest.php @@ -16,7 +16,7 @@ public function testRegisteringInsideTheActionWorks(): void { $plugin = Plugin::boot(new MemoryStore()); add_action('gen_queue_register_types', static function (): void { - gen_queue_register_type('demo.inside', static fn (): null => null); + gen_queue_register_type('demo.inside', static fn (): ?array => null); }); $plugin->openRegistration(); $this->assertTrue($plugin->registry->has('demo.inside')); @@ -28,7 +28,7 @@ public function testRegisteringBeforeTheActionThrows(): void { $plugin = Plugin::boot(new MemoryStore()); $this->expectException(RegistrationException::class); - $plugin->registry->register('demo.early', static fn (): null => null); + $plugin->registry->register('demo.early', static fn (): ?array => null); } /** Test 1, case 1. */ @@ -36,7 +36,7 @@ public function testRegisteringAfterTheActionLogsANotice(): void { $plugin = Plugin::boot(new MemoryStore()); $plugin->openRegistration(); - $plugin->registry->register('demo.late', static fn (): null => null); + $plugin->registry->register('demo.late', static fn (): ?array => null); $this->assertTrue($plugin->registry->has('demo.late')); $this->assertSame(1, $this->logged('"demo.late" was registered after')); } diff --git a/tests/Unit/RunnerTest.php b/tests/Unit/RunnerTest.php index 5d2ef45..1237fc0 100644 --- a/tests/Unit/RunnerTest.php +++ b/tests/Unit/RunnerTest.php @@ -310,7 +310,7 @@ public function testSuccessStoresResultClosesAttemptClearsCounterAndFires(): voi public function testArrayAndNullReturnsAreSuccess(): void { $this->type('demo.array', static fn (): array => ['a' => 1]); - $this->type('demo.null', static fn (): null => null); + $this->type('demo.null', static fn (): ?array => null); $a = gen_queue_enqueue('demo.array', []); $b = gen_queue_enqueue('demo.null', []); $this->drain();