Skip to content

Commit

Permalink
feat: add build/docker in YASSG default (#155)
Browse files Browse the repository at this point in the history
* feat: add build/docker in YASSG default

* CS
  • Loading branch information
dkarlovi authored Jan 19, 2024
1 parent 1aff6a7 commit 69e1c05
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
9 changes: 9 additions & 0 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,13 @@
<code><![CDATA[$paths['shell: PHP']]]></code>
</PossiblyUndefinedStringArrayOffset>
</file>
<file src="tests/functional/YASSG/DefaultTest.php">
<NonInvariantDocblockPropertyType>
<code>$helpOverride</code>
</NonInvariantDocblockPropertyType>
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$paths['mkdir: phpqa']]]></code>
<code><![CDATA[$paths['shell: PHP']]]></code>
</PossiblyUndefinedStringArrayOffset>
</file>
</files>
9 changes: 8 additions & 1 deletion resources/YASSG/default.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
ifndef SIGWIN_INFRA_ROOT
SIGWIN_INFRA_ROOT := $(dir $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))))
endif
include ${SIGWIN_INFRA_ROOT:%/=%}/PHP/library.mk
include ${SIGWIN_INFRA_ROOT:%/=%}/YASSG/common.mk
include ${SIGWIN_INFRA_ROOT:%/=%}/PHP/common.mk

build/docker/imgproxy:
docker compose up imgproxy -d
build/docker: build/docker/imgproxy ## Build app for "APP_ENV" target (defaults to "prod") fully in Docker
docker compose run --rm webpack npm ci
docker compose run --rm webpack npx encore production
docker compose run --rm --env IMGPROXY_URL=http://imgproxy:8080 app vendor/sigwin/yassg/bin/yassg yassg:generate --env prod "$(BASE_URL)"
81 changes: 81 additions & 0 deletions tests/functional/YASSG/DefaultTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sigwin Infra project.
*
* (c) sigwin.hr
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Sigwin\Infra\Test\Functional\YASSG;

use Sigwin\Infra\Test\Functional\MakefileTestCase;
use Sigwin\Infra\Test\Functional\PHP\PhpTrait;

/**
* @internal
*
* @coversNothing
*
* @medium
*/
final class DefaultTest extends MakefileTestCase
{
use PhpTrait;

protected array $helpOverride = [
'start' => 'Start app in APP_ENV mode (defaults to "dev")',
'build/docker' => 'Build app for "APP_ENV" target (defaults to "prod") fully in Docker',
];

protected function getExpectedInitPaths(): array
{
return [
'Common/Platform/$PLATFORM/default',
'Common/default',
'PHP/common',
'YASSG/common',
'YASSG/default',
];
}

protected static function getExpectedHelpCommandsExecutionPath(?array $env = null): array
{
$paths = self::paths($env);

$mkdir = $paths['mkdir: phpqa'];
$build = [
'mkdir -p public',
'npm install',
'BASE_URL=file://localhost$ROOT/public node_modules/.bin/encore production',
'YASSG_SKIP_BUNDLES= php vendor/sigwin/yassg/bin/yassg yassg:generate --env prod "file://localhost$ROOT/public" ',
];

$start = [
'rm -rf var/cache/* var/log/* public',
'make dev/assets dev/server dev/compose -j3',
];

return [
'help' => [self::generateHelpExecutionPath([
__DIR__.'/../../../resources/YASSG/default.mk',
__DIR__.'/../../../resources/YASSG/common.mk',
__DIR__.'/../../../resources/PHP/common.mk',
])],
'build' => $build,
'build/docker' => [
'docker compose up imgproxy -d',
'docker compose run --rm webpack npm ci',
'docker compose run --rm webpack npx encore production',
'docker compose run --rm --env IMGPROXY_URL=http://imgproxy:8080 app vendor/sigwin/yassg/bin/yassg yassg:generate --env prod "file://localhost$ROOT/public"',
],
'sh/php' => array_merge($mkdir, $paths['shell: PHP']),
'start' => $start,
'start/dev' => $start,
];
}
}

0 comments on commit 69e1c05

Please sign in to comment.