Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Aug 26, 2023
1 parent db0a0f9 commit bdbd631
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 23 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,8 @@ jobs:
env:
PHP_DOCKER_IMAGE: eu.gcr.io/${{ secrets.GKE_PROJECT }}/php:latest
APP_SECRET: "ba63418865d58089f7f070e0a437b6d16b1fb970"
CADDY_MERCURE_JWT_SECRET: "f8675b65055fc9f1ccdc21e425c00798633d5556"
PWA_DOCKER_IMAGE: eu.gcr.io/${{ secrets.GKE_PROJECT }}/pwa:latest
NEXTAUTH_SECRET: "0efafa22ed0e5f4d1875777584eebeebf14068f1"
CADDY_DOCKER_IMAGE: eu.gcr.io/${{ secrets.GKE_PROJECT }}/caddy:latest
POSTGRES_PASSWORD: "01c3b2511ddbff2838fa39cc3b823037e1627397"
KEYCLOAK_POSTGRES_PASSWORD: "b8ef720708474177fa169a5c3fec495e04660f44"
steps:
-
name: Checkout
Expand All @@ -113,13 +109,16 @@ jobs:
*.cache-to=type=gha,scope=${{github.ref}}-e2e,mode=max
-
name: Start Services
run: docker compose up --wait --no-build
run: docker compose -f docker-compose.yml -f docker-compose.prod.yml up --wait --no-build
-
name: Debug Services
if: failure()
run: |
docker compose ps
docker compose logs
docker compose -f docker-compose.yml -f docker-compose.prod.yml ps
docker compose -f docker-compose.yml -f docker-compose.prod.yml logs
-
name: Load Fixtures
run: docker compose -f docker-compose.yml -f docker-compose.prod.yml run --rm --env APP_ENV=dev php bin/console doctrine:fixtures:load --no-interaction
-
name: Cache Playwright Binaries
uses: actions/cache@v3
Expand Down
31 changes: 23 additions & 8 deletions api/src/DataFixtures/Factory/BookFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,24 @@
*/
final class BookFactory extends ModelFactory
{
private readonly array $data;

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
*/
public function __construct(private readonly DecoderInterface $decoder)
public function __construct(readonly DecoderInterface $decoder)
{
parent::__construct();

$this->data = $decoder->decode(file_get_contents(__DIR__.'/../books.json'), 'json');
}

/**
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
*/
protected function getDefaults(): array
{
$data = $this->decoder->decode(file_get_contents(__DIR__.'/../books.json'), 'json');
$datum = $data[array_rand($data)];

return [
'book' => $datum['book'],
'title' => $datum['title'],
'author' => $datum['author'],
'condition' => self::faker()->randomElement(BookCondition::getCases()),
];
}
Expand All @@ -79,7 +77,24 @@ protected function getDefaults(): array
protected function initialize(): self
{
return $this
// ->afterInstantiate(function(Book $book): void {})
->afterInstantiate(function(Book $book): void {
if ($book->book && $book->title && $book->author) {
return;
}

$book->book ??= $this->data[array_rand($this->data)]['book'];

if ($book->title && $book->author) {
return;
}

$datum = current(array_filter($this->data, static function (array $datum) use ($book) {
return $book->book === $datum['book'];
}));

$book->title ??= $datum['title'] ?? self::faker()->title();
$book->author ??= $datum['author'] ?? self::faker()->name();
})
;
}

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ services:
target: php_prod
environment:
APP_SECRET: ${APP_SECRET}
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET}

pwa:
image: ${PWA_DOCKER_IMAGE}
build:
context: ./pwa
target: prod
environment:
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}

caddy:
image: ${CADDY_DOCKER_IMAGE}
Expand All @@ -33,6 +36,15 @@ services:
}
CADDY_CACHE: cache

database:
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

keycloak-database:
environment:
POSTGRES_PASSWORD: ${KEYCLOAK_POSTGRES_PASSWORD}

keycloak:
environment:
KEYCLOAK_PRODUCTION: "true"
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ services:
database:
image: postgres:${POSTGRES_VERSION:-15}-alpine
environment:
- POSTGRES_DB=${POSTGRES_DB:-app}
POSTGRES_DB: ${POSTGRES_DB:-app}
# You should definitely change the password in production
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-!ChangeMe!}
- POSTGRES_USER=${POSTGRES_USER:-app}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
POSTGRES_USER: ${POSTGRES_USER:-app}
volumes:
- db_data:/var/lib/postgresql/data
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
Expand All @@ -86,10 +86,10 @@ services:
keycloak-database:
image: postgres:${KEYCLOAK_POSTGRES_VERSION:-15}-alpine
environment:
- POSTGRES_DB=${KEYCLOAK_POSTGRES_DB:-keycloak}
POSTGRES_DB: ${KEYCLOAK_POSTGRES_DB:-keycloak}
# You should definitely change the password in production
- POSTGRES_PASSWORD=${KEYCLOAK_POSTGRES_PASSWORD:-!ChangeMe!}
- POSTGRES_USER=${KEYCLOAK_POSTGRES_USER:-keycloak}
POSTGRES_PASSWORD: ${KEYCLOAK_POSTGRES_PASSWORD:-!ChangeMe!}
POSTGRES_USER: ${KEYCLOAK_POSTGRES_USER:-keycloak}
volumes:
- keycloak_db_data:/var/lib/postgresql/data

Expand Down Expand Up @@ -117,8 +117,8 @@ services:
image: bitnami/keycloak-config-cli:5-debian-11
environment:
KEYCLOAK_URL: http://caddy/oidc/
KEYCLOAK_USER: ${KEYCLOAK_USER:-admin}
KEYCLOAK_PASSWORD: ${KEYCLOAK_PASSWORD:-!ChangeMe!}
KEYCLOAK_USER: ${KEYCLOAK_ADMIN_USER:-admin}
KEYCLOAK_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:-!ChangeMe!}
KEYCLOAK_AVAILABILITYCHECK_ENABLED: true
KEYCLOAK_AVAILABILITYCHECK_TIMEOUT: 120s
IMPORT_FILES_LOCATIONS: "/config/*"
Expand Down

0 comments on commit bdbd631

Please sign in to comment.