Skip to content

Commit

Permalink
NGSTACK-886 add symfony skeleton recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
vesnacustic committed Oct 28, 2024
1 parent fa394c3 commit ca6848b
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/callable-flex-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_call:
inputs:
branch:
default: master
default: symfony-skeleton-test
required: false
type: string

Expand Down Expand Up @@ -35,10 +35,10 @@ jobs:
name: Update Flex endpoint
run: |
mkdir .github/flex-endpoint
git ls-tree HEAD */*/* | php .github/recipes-checker-main/run generate:flex-endpoint ${{ github.repository }} master flex .github/flex-endpoint
git switch flex
git ls-tree HEAD */*/* | php .github/recipes-checker-main/run generate:flex-endpoint ${{ github.repository }} symfony-skeleton-test flex-test .github/flex-endpoint
git switch flex-test
git rm -q *.json
mv .github/flex-endpoint/*.json .
git add *.json
git commit -m 'Update Flex endpoint' || true
git push origin -f flex
git push origin -f flex-test
14 changes: 14 additions & 0 deletions .github/workflows/flex-update-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Update Flex endpoint - test

on:
push:
branches:
- symfony-skeleton-test

defaults:
run:
shell: bash

jobs:
call-flex-update:
uses: netgen/recipes/.github/workflows/callable-flex-update.yml@symfony-skeleton-test
1 change: 1 addition & 0 deletions netgen/symfony-skeleton/1.0/config/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v21
54 changes: 54 additions & 0 deletions netgen/symfony-skeleton/1.0/config/.php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PER' => true,
'@PER:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,

// Overrides for rules included in PhpCsFixer rule sets
'concat_space' => ['spacing' => 'one'],
'fully_qualified_strict_types' => ['phpdoc_tags' => []],
'method_chaining_indentation' => false,
'multiline_whitespace_before_semicolons' => false,
'native_function_invocation' => ['include' => ['@all']],
'no_superfluous_phpdoc_tags' => false,
'no_unset_on_property' => false,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'alpha'],
'php_unit_internal_class' => false,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'php_unit_test_class_requires_covers' => false,
'phpdoc_align' => false,
'phpdoc_order' => ['order' => ['param', 'throws', 'return']],
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'single_line_comment_style' => false,
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'match', 'parameters']],
'yoda_style' => false,

// Additional rules
'date_time_immutable' => true,
'declare_strict_types' => true,
'global_namespace_import' => [
'import_classes' => null,
'import_constants' => true,
'import_functions' => true,
],
'heredoc_indentation' => ['indentation' => 'same_as_start'],
'mb_str_functions' => true,
'native_constant_invocation' => true,
'nullable_type_declaration_for_default_null_value' => true,
'static_lambda' => true,
'ternary_to_null_coalescing' => true,
'use_arrow_functions' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(['src', 'tests'])
->notPath(['Kernel.php', 'bootstrap.php']),
)
;
87 changes: 87 additions & 0 deletions netgen/symfony-skeleton/1.0/config/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
APP_ENV = dev
PHP_VERSION = php8.2
PHP_RUN = /usr/bin/env $(PHP_VERSION)
COMPOSER_PATH = /usr/local/bin/composer2
ifeq ("$(wildcard $(COMPOSER_PATH))","")
COMPOSER_PATH = /usr/local/bin/composer
endif
COMPOSER_RUN = $(PHP_RUN) $(COMPOSER_PATH)
CACHE_POOL = cache.redis
STASH_HASH := $(shell git stash create)

.PHONY: help
help: ## List of all available commands
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help

.PHONY: php-version
php-version: ## See PHP version needed for this project
@echo $(PHP_VERSION)

COMPOSER_INSTALL_PARAMETERS =
ifeq ($(APP_ENV), prod)
COMPOSER_INSTALL_PARAMETERS = --no-dev -o
endif

.PHONY: vendor
vendor: ## Run composer install
$(COMPOSER_RUN) install $(COMPOSER_INSTALL_PARAMETERS)

.PHONY: assets
.ONESHELL:
assets: ## Build frontend assets for DEV environment
. ${NVM_DIR}/nvm.sh && nvm use || nvm install $(cat .nvmrc)
yarn install
yarn build:dev

.PHONY: assets-prod
.ONESHELL:
assets-prod: ## Build frontend assets for PROD environment
. ${NVM_DIR}/nvm.sh && nvm use || nvm install $(cat .nvmrc)
yarn install
yarn build:prod

.PHONY: assets-watch
.ONESHELL:
assets-watch: ## Watch frontend assets (during development)
. ${NVM_DIR}/nvm.sh && nvm use || nvm install $(cat .nvmrc)
yarn install
yarn watch

.PHONY: clear-cache
clear-cache: ## Clear caches for specified environment (default: APP_ENV=dev)
$(PHP_RUN) bin/console cache:clear --env=$(APP_ENV)

.PHONY: clear-all-cache
clear-all-cache: ## Clear all caches for specified environment (including eg. Redis) (default: APP_ENV=dev)
@$(MAKE) -s clear-cache
$(PHP_RUN) bin/console cache:pool:clear $(CACHE_POOL) --env=$(APP_ENV)

.PHONY: migrations
migrations: ## Run Doctrine migrations for specified environment (default: APP_ENV=dev)
$(PHP_RUN) bin/console doctrine:migration:migrate --allow-no-migration --env=$(APP_ENV)

.PHONY: build
build: ## Build the project (install vendor, migrations, build assets, clear cache) for specified environment (default: APP_ENV=dev)
@$(MAKE) -s vendor
@$(MAKE) -s migrations
ifeq ($(APP_ENV), prod)
$(MAKE) -s assets-prod
else
$(MAKE) -s assets
endif
@$(MAKE) -s clear-cache

.PHONY: update-code
update-code: ## Pull the latest code from the repository (on the current branch)
ifeq ($(STASH_HASH),)
git pull --rebase
else
git stash && git pull --rebase && git stash pop
endif

.PHONY: refresh
refresh: ## Fetch latest changes and build the project for specified environment (default: APP_ENV=dev)
@$(MAKE) -s update-code
@$(MAKE) -s build
92 changes: 92 additions & 0 deletions netgen/symfony-skeleton/1.0/config/captainhook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"commit-msg": {
"enabled": true,
"actions": [
{
"action": "\\Netgen\\GitHooks\\Action\\Regex",
"options": {
"regex": "/^[A-Z0-9]+-\\d+:?\\s/",
"error": "Your commit message MUST start with a ticket ID"
}
}
]
},
"pre-push": {
"enabled": false,
"actions": []
},
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "\\Netgen\\GitHooks\\Action\\CheckForBlockedWords",
"options": {
"extensions": ["php"],
"keyword_blocklist": ["var_dump", "dump", "dd"],
"excluded_files": []
}
},
{
"action": "\\Netgen\\GitHooks\\Action\\CheckForBlockedWords",
"options": {
"extensions": ["twig"],
"keyword_blocklist": ["dump"],
"excluded_files": []
}
},
{
"action": "\\CaptainHook\\App\\Hook\\Composer\\Action\\CheckLockFile"
},
{
"action": "\\Netgen\\GitHooks\\Action\\PHPCSFixer",
"options": {
"excluded_files": ["deploy.php", "/^deploy.*/", "config/bundles.php"],
"fixer_path": "vendor/bin/php-cs-fixer"
}
},
{
"action": "\\Netgen\\GitHooks\\Action\\PHPStan",
"options": {
"excluded_files": ["/^deploy.*/"]
}
},
{
"action": "\\Netgen\\GitHooks\\Action\\JSLinter",
"options": {
"excluded_files": []
}
},
{
"action": "\\Netgen\\GitHooks\\Action\\JSPrettier",
"options": {
"excluded_files": []
}
},
{
"action": "\\Netgen\\GitHooks\\Action\\CheckLockFileCommitted",
"options": {
"enabled": true
}
}
]
},
"prepare-commit-msg": {
"enabled": false,
"actions": []
},
"post-commit": {
"enabled": false,
"actions": []
},
"post-merge": {
"enabled": false,
"actions": []
},
"post-checkout": {
"enabled": false,
"actions": []
},
"config": {
"php-path": "/usr/bin/env php8.2"
}
}
12 changes: 12 additions & 0 deletions netgen/symfony-skeleton/1.0/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"copy-from-recipe": {
"config/captainhook.json": "captainhook.json",
"config/Makefile": "Makefile",
"config/.nvmrc": ".nvmrc",
"config/.php-cs-fixer.php": ".php-cs-fixer.php",
"public/": "%PUBLIC_DIR%/"
},
"env": {
"CACHE_DSN": "redis://localhost"
}
}

0 comments on commit ca6848b

Please sign in to comment.