-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
3,403 additions
and
107 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace qa; | ||
|
||
use Castor\Attribute\AsTask; | ||
|
||
use function Castor\io; | ||
use function Castor\variable; | ||
use function docker\docker_compose_run; | ||
use function docker\docker_exit_code; | ||
|
||
#[AsTask(description: 'Runs all QA tasks')] | ||
function all(): int | ||
{ | ||
install(); | ||
$cs = cs(); | ||
$phpstan = phpstan(); | ||
// $phpunit = phpunit(); | ||
|
||
return max($cs, $phpstan/* , $phpunit */); | ||
} | ||
|
||
#[AsTask(description: 'Installs tooling')] | ||
function install(): void | ||
{ | ||
io()->title('Installing QA tooling'); | ||
|
||
docker_compose_run('composer install -o', workDir: '/var/www/tools/php-cs-fixer'); | ||
docker_compose_run('composer install -o', workDir: '/var/www/tools/phpstan'); | ||
} | ||
|
||
#[AsTask(description: 'Runs PHPUnit', aliases: ['phpunit'])] | ||
function phpunit(): int | ||
{ | ||
return docker_exit_code('vendor/bin/simple-phpunit'); | ||
} | ||
|
||
#[AsTask(description: 'Runs PHPStan', aliases: ['phpstan'])] | ||
function phpstan(bool $generateBaseline = false): int | ||
{ | ||
if (!is_dir(variable('root_dir') . '/tools/phpstan/vendor')) { | ||
io()->error('PHPStan is not installed. Run `castor qa:install` first.'); | ||
|
||
return 1; | ||
} | ||
|
||
return docker_exit_code('phpstan' . ($generateBaseline ? ' -b' : ''), workDir: '/var/www'); | ||
} | ||
|
||
#[AsTask(description: 'Fixes Coding Style', aliases: ['cs'])] | ||
function cs(bool $dryRun = false): int | ||
{ | ||
if (!is_dir(variable('root_dir') . '/tools/php-cs-fixer/vendor')) { | ||
io()->error('PHP-CS-Fixer is not installed. Run `castor qa:install` first.'); | ||
|
||
return 1; | ||
} | ||
|
||
if ($dryRun) { | ||
return docker_exit_code('php-cs-fixer fix --dry-run --diff', workDir: '/var/www'); | ||
} | ||
|
||
return docker_exit_code('php-cs-fixer fix', workDir: '/var/www'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 | |
# | ||
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" | ||
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4" | ||
DATABASE_URL="postgresql://qotd:qotd@postgres:5432/qotd?serverVersion=15&charset=utf8" | ||
DATABASE_URL="postgresql://app:app@postgres:5432/app?serverVersion=15&charset=utf8" | ||
###< doctrine/doctrine-bundle ### | ||
|
||
SLACK_SIGNING_SECRET=FIXME | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Force LF line ending (mandatory for Windows) | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
/* | ||
* This is an example Stimulus controller! | ||
* | ||
* Any element with a data-controller="hello" attribute will cause | ||
* this controller to be executed. The name "hello" comes from the filename: | ||
* hello_controller.js -> "hello" | ||
* | ||
* Delete this file or adapt it for your use! | ||
*/ | ||
export default class extends Controller { | ||
connect() { | ||
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
if (!ini_get('date.timezone')) { | ||
ini_set('date.timezone', 'UTC'); | ||
} | ||
|
||
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) { | ||
if (PHP_VERSION_ID >= 80000) { | ||
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit'; | ||
} else { | ||
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php'); | ||
require PHPUNIT_COMPOSER_INSTALL; | ||
PHPUnit\TextUI\Command::main(); | ||
} | ||
} else { | ||
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) { | ||
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n"; | ||
exit(1); | ||
} | ||
|
||
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
use Castor\Attribute\AsTask; | ||
|
||
use function Castor\guard_min_version; | ||
use function Castor\import; | ||
use function Castor\io; | ||
use function Castor\notify; | ||
use function docker\about; | ||
use function docker\build; | ||
use function docker\docker_compose_run; | ||
use function docker\generate_certificates; | ||
use function docker\up; | ||
|
||
guard_min_version('0.15.0'); | ||
|
||
import(__DIR__ . '/.castor'); | ||
|
||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
function create_default_variables(): array | ||
{ | ||
return [ | ||
'project_name' => 'qotd', | ||
'root_domain' => 'local.qotd.offithings.jolicode.com', | ||
'registry' => 'ghcr.io/jolicode/qotd', | ||
]; | ||
} | ||
|
||
#[AsTask(description: 'Builds and starts the infrastructure, then install the application (composer, yarn, ...)')] | ||
function start(): void | ||
{ | ||
io()->title('Starting the stack'); | ||
|
||
generate_certificates(force: false); | ||
build(); | ||
up(); | ||
cache_clear(); | ||
install(); | ||
migrate(); | ||
|
||
notify('The stack is now up and running.'); | ||
io()->success('The stack is now up and running.'); | ||
|
||
about(); | ||
} | ||
|
||
#[AsTask(description: 'Installs the application (composer, yarn, ...)', namespace: 'app', aliases: ['install'])] | ||
function install(): void | ||
{ | ||
io()->title('Installing the application'); | ||
|
||
io()->section('Installing PHP dependencies'); | ||
docker_compose_run('composer install -n --prefer-dist --optimize-autoloader'); | ||
|
||
io()->section('Installing importmap'); | ||
docker_compose_run('bin/console importmap:install'); | ||
|
||
migrate(); | ||
fixtures(); | ||
|
||
qa\install(); | ||
} | ||
|
||
#[AsTask(description: 'Clear the application cache', namespace: 'app', aliases: ['cache-clear'])] | ||
function cache_clear(): void | ||
{ | ||
io()->title('Clearing the application cache'); | ||
|
||
docker_compose_run('rm -rf var/cache/ && bin/console cache:warmup'); | ||
} | ||
|
||
#[AsTask(description: 'Migrates database schema', namespace: 'app:db', aliases: ['migrate'])] | ||
function migrate(): void | ||
{ | ||
io()->title('Migrating the database schema'); | ||
|
||
docker_compose_run('bin/console doctrine:database:create --if-not-exists'); | ||
docker_compose_run('bin/console doctrine:migration:migrate -n --allow-no-migration'); | ||
} | ||
|
||
#[AsTask(description: 'Injects fixtures in the database', namespace: 'app:db', aliases: ['fixtures'])] | ||
function fixtures(): void | ||
{ | ||
io()->title('Injects fixtures in the database'); | ||
|
||
docker_compose_run('bin/console doctrine:fixture:load -n'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
services: | ||
builder: | ||
build: | ||
context: services/php | ||
target: builder | ||
cache_from: | ||
- "type=registry,ref=${REGISTRY:-}/builder:cache" | ||
depends_on: | ||
- postgres | ||
user: "${USER_ID}:${USER_ID}" | ||
environment: | ||
- COMPOSER_MEMORY_LIMIT=-1 | ||
- UID=${USER_ID} | ||
- APP_ENV=${APP_ENV:-dev} | ||
# The following list contains the common environment variables exposed by CI platforms | ||
- GITHUB_ACTIONS | ||
- CI # Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari | ||
- CONTINUOUS_INTEGRATION # Travis CI, Cirrus CI | ||
- BUILD_NUMBER # Jenkins, TeamCity | ||
- RUN_ID # TaskCluster, dsari | ||
- HOME=/home/app | ||
volumes: | ||
- "../..:/var/www:cached" | ||
- "../../.home:/home/app:cached" | ||
profiles: | ||
- default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This file is used only when using Docker for Mac or Windows | ||
|
||
services: | ||
router: | ||
# Docker for Mac or Windows does not support the "network_mode=host" | ||
# So we use the default network mode and we map all needed ports | ||
network_mode: "${PROJECT_NAME}_default" | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
- "8080:8080" | ||
profiles: | ||
- default |
Oops, something went wrong.