Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 216 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Integration tests"

on:
pull_request:
push:
branches:
- "[0-9]+.[0-9]+.x"
- "renovate/*"

jobs:
postgres:
name: "Postgres"

runs-on: ${{ matrix.operating-system }}

services:
postgres:
# Docker Hub image
image: "postgres:${{ matrix.postgres-version }}"
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: event_store
options: >-
--health-cmd "pg_isready"
ports:
- "5432:5432"

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.5"
operating-system:
- "ubuntu-latest"
postgres-version:
- "14.20"
- "15.15"
- "16.11"
- "17.7"
- "18.1"

env:
DB_URL: 'pgsql://postgres:postgres@localhost:5432/event_store?charset=utf8'
DB_CONNECTION: 'pgsql'
DB_DATABASE: 'event_store'

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.0"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: pdo_pgsql

- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }}

- name: "Tests"
run: "vendor/bin/phpunit --testsuite=integration --no-coverage"

mariadb:
name: "mariadb"

runs-on: ${{ matrix.operating-system }}

services:
mariadb:
image: "mariadb:${{ matrix.mariadb-version }}"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: event_store

options: >-
--health-cmd "mariadb-admin ping --silent"
ports:
- "3306:3306"

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.5"
operating-system:
- "ubuntu-latest"
mariadb-version:
- "10.6"
- "10.11"
- "11.4"
- "11.8"
- "12.1"

env:
DB_URL: 'mysql://root@127.0.0.1:3306/event_store?charset=utf8'
DB_CONNECTION: 'mysql'
DB_DATABASE: 'event_store'

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.0"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: pdo_mysql

- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }}

- name: "Tests"
run: "vendor/bin/phpunit --testsuite=integration --no-coverage"

mysql:
name: "mysql"

runs-on: ${{ matrix.operating-system }}

services:
mysql:
image: "mysql:${{ matrix.mysql-version }}"

env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: "event_store"

options: >-
--health-cmd "mysqladmin ping --silent"
ports:
- "3306:3306"

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.5"
operating-system:
- "ubuntu-latest"
mysql-version:
- "8.0"
- "8.4"
- "9.5"

env:
DB_URL: 'mysql://root@127.0.0.1:3306/event_store?charset=utf8'
DB_CONNECTION: 'mysql'
DB_DATABASE: 'event_store'

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.0"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: pdo_mysql

- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }}

- name: "Tests"
run: "vendor/bin/phpunit --testsuite=integration --no-coverage"

sqlite:
name: "Sqlite"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.5"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: actions/checkout@v6

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.0"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: pdo_sqlite

- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.composer-options }}

- name: "Tests"
run: "vendor/bin/phpunit --testsuite=integration --no-coverage"
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
dependency-versions: ${{ matrix.dependencies }}

- name: "Tests"
run: "vendor/bin/phpunit --coverage-clover=clover.xml --coverage-text"
run: "vendor/bin/phpunit --testsuite=unit --coverage-clover=clover.xml --coverage-text"
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ phpstan-baseline: vendor

.PHONY: phpunit
phpunit: vendor ## run phpunit tests
XDEBUG_MODE=coverage vendor/bin/phpunit
XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=unit
XDEBUG_MODE=off vendor/bin/phpunit --testsuite=integration --no-coverage

.PHONY: infection
infection: vendor ## run infection
Expand Down
14 changes: 14 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: event_store
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d eventstore"]
interval: 5s
timeout: 5s
retries: 5
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require": {
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
"illuminate/contracts": "^11.0 || ^12.0 || ^13.0",
"patchlevel/event-sourcing": "^3.15.0"
"patchlevel/event-sourcing": "^3.16.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 18 additions & 16 deletions database/migrations/create_eventsourcing_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,40 @@
{
public function up(): void
{
Schema::create('eventstore', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('aggregate', 255);
$table->char('aggregate_id', 36);
$table->integer('playhead');
$table->string('event', 255);
$table->json('payload');
$table->dateTime('recorded_on');
$table->tinyInteger('new_stream_start')->default(0);
$table->tinyInteger('archived')->default(0);
Schema::create('event_store', function (Blueprint $table) {
$table->bigInteger('id', true);
$table->string('stream', 255);
$table->integer('playhead')->nullable();
$table->string('event_id', 255);
$table->string('event_name', 255);
$table->json('event_payload');
$table->dateTimeTz('recorded_on');
$table->boolean('archived')->default(false);
$table->json('custom_headers');
$table->unique(['aggregate', 'aggregate_id', 'playhead']);
$table->index(['aggregate', 'aggregate_id', 'playhead', 'archived']);

$table->unique('event_id');
$table->unique(['stream', 'playhead']);
$table->unique(['stream', 'playhead', 'archived']);
});

Schema::create('subscriptions', function (Blueprint $table) {
$table->string('id', 255);
$table->string('group_name', 32);
$table->string('run_mode', 16);
$table->integer('position');
$table->string('status', 32);
$table->integer('position');
$table->longText('error_message')->nullable();
$table->string('error_previous_status', 32)->nullable();
$table->json('error_context')->nullable();
$table->integer('retry_attempt');
$table->dateTime('last_saved_at');
$table->text('cleanup_tasks')->nullable();
$table->index('group_name');
$table->index('status');
$table->primary('id');
});

Schema::create('eventstore_cipher_keys', function (Blueprint $table) {
Schema::create('crypto_keys', function (Blueprint $table) {
$table->string('subject_id', 255);
$table->string('crypto_key', 255);
$table->string('crypto_method', 255);
Expand All @@ -50,8 +52,8 @@ public function up(): void

public function down(): void
{
Schema::dropIfExists('eventstore');
Schema::dropIfExists('event_store');
Schema::dropIfExists('subscriptions');
Schema::dropIfExists('eventstore_cipher_keys');
Schema::dropIfExists('crypto_keys');
}
};
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/Integration</directory>
</testsuite>
</testsuites>
<coverage>
<report>
Expand All @@ -22,6 +25,7 @@
<ini name="error_reporting" value="E_ALL"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_URL" value="sqlite3:///:memory:"/>
</php>
<source>
<include>
Expand Down
Loading
Loading