Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feature/147
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Apr 29, 2024
2 parents 0c58080 + 4cb258a commit 7d6ea6d
Show file tree
Hide file tree
Showing 210 changed files with 8,034 additions and 1,630 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/docker-dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: v0.1

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand All @@ -38,5 +44,6 @@ jobs:
build-args: |
APP_VERSION=${{ steps.previoustag.outputs.tag }}
FRONTEND_IMAGE_TAG=dev
BRANCH=${{ steps.previoustag.outputs.tag }}
tags:
ghcr.io/${{ github.repository }}:dev, ghcr.io/${{ github.repository }}:${{ steps.previoustag.outputs.tag }}
1 change: 1 addition & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ jobs:
build-args:
APP_VERSION=${{ steps.previoustag.outputs.tag }}
FRONTEND_IMAGE_TAG=latest
BRANCH=${{ steps.previoustag.outputs.tag }}
tags:
${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:latest, ${{ secrets.DOCKER_HUB_USERNAME }}/buggregator:${{ steps.previoustag.outputs.tag }}
21 changes: 21 additions & 0 deletions .github/workflows/phpunit-database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request: null

name: phpunit

env:
PERSISTENCE_DRIVER: db
DB_DRIVER: sqlite

jobs:
phpunit-db:
uses: spiral/gh-actions/.github/workflows/phpunit.yml@master
with:
extensions: >-
['sockets', 'mongodb', 'pgsql', 'pdo_pgsql', 'pdo_mysql']
os: >-
['ubuntu-latest']
php: >-
['8.3']
stability: >-
['prefer-stable']
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ on:

name: phpunit

env:
PERSISTENCE_DRIVER: memory

jobs:
phpunit:
phpunit-memory:
uses: spiral/gh-actions/.github/workflows/phpunit.yml@master
with:
install_protoc: true
extensions: >-
['sockets', 'mongodb', 'pgsql', 'pdo_pgsql', 'pdo_mysql']
os: >-
['ubuntu-latest']
php: >-
['8.2', '8.3']
['8.3']
stability: >-
['prefer-stable']
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ protoc-gen-php-grpc*
.phpunit.result.cache
.php-cs-fixer.cache
.deptrac.cache
.phpunit.cache
build
9 changes: 7 additions & 2 deletions .rr-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rpc:
server:
command: 'php app.php'
relay: pipes
env:
- MODE: 'roadrunner'
on_init:
command: "php app.php configure"

Expand Down Expand Up @@ -42,10 +44,13 @@ tcp:
kv:
events:
driver: memory
config: {}
config: { }
local:
driver: memory
config: {}
config: { }

jobs:
consume: [ ]

service:
nginx:
Expand Down
5 changes: 5 additions & 0 deletions .rr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rpc:
server:
command: 'php app.php'
relay: pipes
env:
- MODE: 'roadrunner'
on_init:
command: "php app.php configure"

Expand Down Expand Up @@ -45,6 +47,9 @@ kv:
driver: memory
config: {}

jobs:
consume: []

service:
# frontend:
# service_name_in_log: true
Expand Down
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
build:
docker compose up --no-start;

start:
docker compose up --remove-orphans -d;

up: build start

stop:
docker compose stop;

down:
docker compose down;

restart:
docker compose restart;

list:
docker compose ps;

log-tail:
docker compose logs --tail=50 -f;

pull-latest:
docker compose pull;

# =========================

bash:
docker compose exec buggregator-server /bin/sh;

reset-server:
docker compose exec buggregator-server ./rr reset;

reset: reset-server
3 changes: 3 additions & 0 deletions app/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
'default' => env('CACHE_STORAGE', 'roadrunner'),
'aliases' => [
'events' => ['storage' => $defaultStorage, 'prefix' => 'events:'],
'projects' => ['storage' => $defaultStorage, 'prefix' => 'projects:'],
'webhooks' => ['storage' => $defaultStorage, 'prefix' => 'webhooks:'],
'local' => ['storage' => $defaultStorage, 'prefix' => 'local:'],
'smtp' => ['storage' => $defaultStorage, 'prefix' => 'smtp:'],
],
'storages' => [
'array' => [
Expand Down
19 changes: 0 additions & 19 deletions app/config/cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@
'factories' => ['doctrine' => new DoctrineCollectionFactory()],
],
'generators' => null,
// 'generators' => [
// \Cycle\Annotated\Embeddings::class,
// \Cycle\Annotated\Entities::class,
// \Cycle\Annotated\MergeColumns::class,
// \Cycle\Schema\Generator\ResetTables::class,
// \Cycle\Schema\Generator\GenerateRelations::class,
// \Cycle\Schema\Generator\ValidateEntities::class,
// \Cycle\Schema\Generator\RenderTables::class,
// \Cycle\Schema\Generator\RenderRelations::class,
// \Cycle\Annotated\TableInheritance::class,
// \Cycle\Annotated\MergeIndexes::class
// \Cycle\Schema\Generator\GenerateTypecast::class,
// ],
],
'warmup' => env('CYCLE_SCHEMA_WARMUP', false),
'customRelations' => [
// \Cycle\ORM\Relation::EMBEDDED => [
// \Cycle\ORM\Config\RelationConfig::LOADER => \Cycle\ORM\Select\Loader\EmbeddedLoader::class,
// \Cycle\ORM\Config\RelationConfig::RELATION => \Cycle\ORM\Relation\Embedded::class,
// ]
],
];
28 changes: 10 additions & 18 deletions app/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,14 @@
'drivers' => [],
],

/**
* Default database connection
*/
'default' => 'default',

/**
* The Spiral/Database module provides support to manage multiple databases
* in one application, use read/write connections and logically separate
* multiple databases within one connection using prefixes.
*
* To register a new database simply add a new one into
* "databases" section below.
*/
'databases' => [
'default' => [
'driver' => env('DB_DRIVER', 'pgsql'),
],
],

/**
* Each database instance must have an associated connection object.
* Connections used to provide low-level functionality and wrap different
* database drivers. To register a new connection you have to specify
* the driver class and its connection options.
*/
'drivers' => [
'pgsql' => new Config\PostgresDriverConfig(
connection: new Config\Postgres\TcpConnectionConfig(
Expand All @@ -56,7 +39,7 @@
database: env('DB_DATABASE', 'buggregator'),
host: env('DB_HOST', '127.0.0.1'),
port: env('DB_PORT', 3306),
user: env('DB_USERNAME', 'postgres'),
user: env('DB_USERNAME', 'root'),
password: env('DB_PASSWORD'),
),
queryCache: true,
Expand All @@ -65,5 +48,14 @@
'logQueryParameters' => env('DB_LOG_QUERY_PARAMETERS', false),
],
),

// Only for testing purposes
// SQLite does not support multiple connections in the same time
'sqlite' => new Config\SQLiteDriverConfig(
connection: new Config\SQLite\MemoryConnectionConfig(),
options: [
'logQueryParameters' => env('DB_LOG_QUERY_PARAMETERS', false),
],
),
],
];
3 changes: 2 additions & 1 deletion app/config/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

return [
'interceptors' => [
\App\Application\Broadcasting\BroadcastEventInterceptor::class
\Modules\Webhooks\Application\Broadcasting\WebhookEventInterceptor::class,
\App\Application\Broadcasting\BroadcastEventInterceptor::class,
]
];
2 changes: 1 addition & 1 deletion app/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Directory to store migration files
*/
'directory' => directory('app') . 'migrations/',
'directory' => directory('app') . 'database/Migrations/',

/**
* Table name to store information about migrations status (per database)
Expand Down
18 changes: 12 additions & 6 deletions app/config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

declare(strict_types=1);

use Modules\Webhooks\Interfaces\Job\WebhookHandler;
use Spiral\Queue\Driver\SyncDriver;
use Spiral\RoadRunner\Jobs\Queue\MemoryCreateInfo;
use Spiral\RoadRunner\Jobs\Queue\AMQPCreateInfo;
use Spiral\RoadRunner\Jobs\Queue\BeanstalkCreateInfo;
use Spiral\RoadRunner\Jobs\Queue\SQSCreateInfo;
use Spiral\RoadRunnerBridge\Queue\Queue;

$defaultConnection = env('QUEUE_DEFAULT_CONNECTION', 'roadrunner');

return [
'default' => env('QUEUE_CONNECTION', 'sync'),
'aliases' => [],
'default' => env('QUEUE_CONNECTION', 'memory'),
'aliases' => [
'webhook' => $defaultConnection,
'events' => $defaultConnection,
],
'pipelines' => [
'memory' => [
'connector' => new MemoryCreateInfo('local'),
'consume' => true,
]
],
],
'connections' => [
'sync' => [
Expand All @@ -33,5 +36,8 @@
],
'registry' => [
'handlers' => [],
'serializers' => [
WebhookHandler::class => 'symfony-json',
],
],
];
2 changes: 2 additions & 0 deletions app/config/swagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@
directory('app') . 'src/Application/HTTP/Response',
directory('app') . 'src/Interfaces/Http',
directory('app') . 'modules/Events/Interfaces/Http',
directory('app') . 'modules/Projects/Interfaces/Http',
directory('app') . 'modules/Webhooks/Interfaces/Http',
],
];
76 changes: 76 additions & 0 deletions app/database/Factory/EventFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

declare(strict_types=1);

namespace Database\Factory;

use App\Application\Domain\Entity\Json;
use App\Application\Domain\ValueObjects\Uuid;
use Database\Factory\Partials\InspectorType;
use Database\Factory\Partials\MonologType;
use Database\Factory\Partials\ProfilerType;
use Database\Factory\Partials\RayType;
use Database\Factory\Partials\SentryType;
use Database\Factory\Partials\SmtpType;
use Database\Factory\Partials\VarDumperType;
use Modules\Events\Domain\Event;
use Modules\Events\Domain\ValueObject\Timestamp;
use Modules\Projects\Domain\ValueObject\Key;
use Spiral\DatabaseSeeder\Factory\AbstractFactory;

/**
* @implements AbstractFactory<Event>
*/
final class EventFactory extends AbstractFactory
{
use SmtpType,
ProfilerType,
SentryType,
MonologType,
InspectorType,
VarDumperType,
RayType;

public function entity(): string
{
return Event::class;
}

public function definition(): array
{
return [
'uuid' => Uuid::generate(),
'type' => $this->faker->randomElement(['sentry', 'monolog', 'var-dump', 'inspector', 'ray', 'profiler']),
'timestamp' => Timestamp::create(),
'project' => null,
];
}


public function makeEntity(array $definition): object
{
return new Event(
uuid: $definition['uuid'],
type: $definition['type'],
payload: new Json($this->getPayload($definition['type'])),
timestamp: $definition['timestamp'],
project: $definition['project']
? ($definition['project'] instanceof Key ? $definition['project'] : Key::create($definition['project']))
: null,
);
}

public function getPayload(string $type): array
{
return match ($type) {
'sentry' => self::getSentryPayload(),
'monolog' => self::getMonologPayload(),
'var-dump' => self::getVarDumperPayload(),
'inspector' => self::getInspectorPayload(),
'ray' => self::getRayPayload(),
'profiler' => self::getProfilerPayload(),
'smtp' => self::getSmtpPayload(),
default => ['foo' => 'bar'],
};
}
}
Loading

0 comments on commit 7d6ea6d

Please sign in to comment.