Skip to content

Commit 37710ef

Browse files
committed
add CI pipeline
add github action fix add migration try fix elk fix ci fix ci fix ci fix ci fix ci fix ci fix ci fix ci
1 parent 4942ec1 commit 37710ef

File tree

6 files changed

+94
-12
lines changed

6 files changed

+94
-12
lines changed

.env

-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ PYTHONWARNINGS="ignore:Unverified HTTPS request"
1515
###< synchro scripts ###
1616

1717
ELASTIC_PASSWORD=admin
18-
ELASTICSEARCH_HOST=http://elasticsearch:9200
1918
ELASTICSEARCH_IRI=https://elastic:admin@elasticsearch:9200

.github/workflow/github-actions.yaml .github/workflows/github-actions.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,30 @@ jobs:
1818
MYSQL_ROOT_PASSWORD: symfony
1919
MYSQL_DATABASE: symfony
2020
ports:
21-
- 3306/tcp
21+
- 3306:3306
2222
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 --name=mysql
2323
elasticsearch:
2424
image: elasticsearch:8.16.0
2525
ports:
26-
- 9200/tcp
26+
- 9200:9200
2727
env:
2828
ELASTIC_PASSWORD: admin
29+
discovery.type: single-node
30+
xpack.security.enabled: true
31+
bootstrap.memory_lock: true
32+
ES_JAVA_OPTS: -Xms512m -Xmx512m
33+
options: --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=3
2934
steps:
3035
- name: Setup PHP
3136
uses: shivammathur/setup-php@v2
3237
with:
3338
php-version: "8.3"
3439
tools: phpunit-bridge
35-
extensions: mbstring, xml, ctype, intl, iconv, json, redis, mysql
40+
extensions: mbstring, xml, ctype, intl, iconv, json, mysql
3641
ini-values: date.timezone=Europe/Paris
3742
- uses: actions/checkout@v4
3843
- name: Create .env.test.local
39-
# TODO remove LOCK_DSN on Symfony update
40-
run: echo -e "DB_NAME_SUFFIX=\\ELASTICSEARCH_IRI=https://elastic:admin@elasticsearch:${{ job.services.elasticsearch.ports['9200'] }}" > .env.test.local
44+
run: echo -e "DB_NAME_SUFFIX=\\nELASTICSEARCH_IRI=http://elastic:[email protected]:${{ job.services.elasticsearch.ports['9200'] }}" > .env.test.local
4145
- name: Get composer cache directory
4246
id: composer-cache
4347
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
@@ -49,8 +53,6 @@ jobs:
4953
restore-keys: ${{ runner.os }}-composer-
5054
- name: Install Dependencies
5155
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
52-
- name: Generate SSL Key for JWT
53-
run: php bin/console lexik:jwt:generate-keypair
5456
- name: Run migrations
5557
run: |
5658
php bin/console doctrine:migrations:migrate --no-interaction || echo "No migrations found or migration failed"
@@ -69,7 +71,6 @@ jobs:
6971
- name: lint:container
7072
if: always()
7173
run: php bin/console lint:container
72-
- name: lint:twig
7374
- name: lint:yaml
7475
if: always()
7576
run: php bin/console lint:yaml config src

compose.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ services:
3434
- xpack.security.enrollment.enabled=true
3535
- bootstrap.memory_lock=true
3636
- ES_JAVA_OPTS=-Xms512m -Xmx512m # 512mo HEAP
37+
- ELASTIC_PASSWORD=admin
3738
networks:
3839
- app-network
3940
ports:
4041
- 9200:9200
41-
volumes:
42-
- ./elastic/data:/usr/share/elasticsearch/elastic/data
4342

4443
backend:
4544
extra_hosts: *default-extra_hosts
@@ -62,7 +61,6 @@ services:
6261
environment:
6362
SERVER_NAME: localhost api.openchurch.local admin.openchurch.local
6463
DATABASE_URL: mysql://root:openchurch@db:3306/openchurch?serverVersion=11.5.2-MariaDB&charset=utf8mb4
65-
6664
volumes:
6765
openchurch_db_data: {}
6866

config/services.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ services:
5252
App\Core\Infrastructure\ElasticSearch\Helper\OfficialElasticSearchHelper:
5353
arguments:
5454
$elasticsearchHost: "%env(ELASTICSEARCH_IRI)%"
55+
56+
App\Core\Infrastructure\Doctrine\FixDoctrineMigrationTableSchema:
57+
autoconfigure: false
58+
arguments:
59+
$dependencyFactory: "@doctrine.migrations.dependency_factory"
60+
tags:
61+
- { name: "doctrine.event_listener", event: "postGenerateSchema" }

migrations/Version20241203150437.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
final class Version20241203150437 extends AbstractMigration
11+
{
12+
public function up(Schema $schema): void
13+
{
14+
$this->addSql('ALTER TABLE field ADD CONSTRAINT FK_5BF54558FDA7B0BF FOREIGN KEY (community_id) REFERENCES community (id)');
15+
$this->addSql('ALTER TABLE field ADD CONSTRAINT FK_5BF5455851D1B0E8 FOREIGN KEY (community_val_id) REFERENCES community (id)');
16+
$this->addSql('ALTER TABLE field ADD CONSTRAINT FK_5BF5455882D54272 FOREIGN KEY (place_val_id) REFERENCES place (id)');
17+
$this->addSql('ALTER TABLE field ADD CONSTRAINT FK_5BF545583414710B FOREIGN KEY (agent_id) REFERENCES agent (id)');
18+
$this->addSql('ALTER TABLE field ADD CONSTRAINT FK_5BF54558DA6A219 FOREIGN KEY (place_id) REFERENCES place (id)');
19+
}
20+
21+
public function down(Schema $schema): void
22+
{
23+
$this->addSql('ALTER TABLE field DROP FOREIGN KEY FK_5BF54558FDA7B0BF');
24+
$this->addSql('ALTER TABLE field DROP FOREIGN KEY FK_5BF5455851D1B0E8');
25+
$this->addSql('ALTER TABLE field DROP FOREIGN KEY FK_5BF5455882D54272');
26+
$this->addSql('ALTER TABLE field DROP FOREIGN KEY FK_5BF545583414710B');
27+
$this->addSql('ALTER TABLE field DROP FOREIGN KEY FK_5BF54558DA6A219');
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\Infrastructure\Doctrine;
6+
7+
use Doctrine\DBAL\Exception;
8+
use Doctrine\DBAL\Schema\SchemaException;
9+
use Doctrine\Migrations\DependencyFactory;
10+
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
11+
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
12+
use Webmozart\Assert\Assert;
13+
14+
/** @see https://github.com/doctrine/migrations/issues/1406 */
15+
final class FixDoctrineMigrationTableSchema
16+
{
17+
private TableMetadataStorageConfiguration $configuration;
18+
19+
public function __construct(
20+
private readonly DependencyFactory $dependencyFactory,
21+
) {
22+
$configuration = $this->dependencyFactory->getConfiguration()->getMetadataStorageConfiguration();
23+
24+
Assert::notNull($configuration);
25+
Assert::isInstanceOf($configuration, TableMetadataStorageConfiguration::class);
26+
27+
$this->configuration = $configuration;
28+
}
29+
30+
/**
31+
* @throws SchemaException
32+
* @throws Exception
33+
*/
34+
public function postGenerateSchema(GenerateSchemaEventArgs $args): void
35+
{
36+
$schema = $args->getSchema();
37+
$table = $schema->createTable($this->configuration->getTableName());
38+
$table->addColumn(
39+
$this->configuration->getVersionColumnName(),
40+
'string',
41+
['notnull' => true, 'length' => $this->configuration->getVersionColumnLength()],
42+
);
43+
$table->addColumn($this->configuration->getExecutedAtColumnName(), 'datetime', ['notnull' => false]);
44+
$table->addColumn($this->configuration->getExecutionTimeColumnName(), 'integer', ['notnull' => false]);
45+
46+
$table->setPrimaryKey([$this->configuration->getVersionColumnName()]);
47+
}
48+
}

0 commit comments

Comments
 (0)