Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
khelmrich authored Apr 10, 2024
0 parents commit 8a76dfb
Show file tree
Hide file tree
Showing 29 changed files with 9,970 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_ENV=prod
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='Productsup\BinCdeAppSkeleton\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
19 changes: 19 additions & 0 deletions .github/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# auto merge security patches (as reported by dependabot)
- match:
dependency_type: all
update_type: security:patch

# auto merge PATCH semver updates for any package
- match:
dependency_type: all
update_type: semver:patch

# auto merge MINOR semver updates for productsupcom packages (trusted)
- match:
dependency_name: "#^productsupcom/.*#"
update_type: semver:minor

# auto merge MINOR semver updates for symfony packages (trusted)
- match:
dependency_name: "#^symfony/.*#"
update_type: semver:minor
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2

registries:
packagist:
type: composer-repository
url: https://repo.packagist.com
username: token
password: "${{ secrets.DEPENDABOT_PACKAGIST_TOKEN }}"

updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
reviewers:
- "productsupcom/channel-development"
registries:
- "packagist"
allow:
- dependency-name: "*"
dependency-type: "production"
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change. And don't forget to add the related Jira Issue ID (e.g.
DEV-7327). Swarmia adding then automatically the link to the PR.

### Checklist:

- [ ] All acceptance criteria/requirements are met
- [ ] New/updated functionality is covered by tests
- [ ] All tests have been successfully run
- [ ] CI run has passed all checks
- [ ] My code follows the style guidelines of this project
- [ ] Any dependent changes have been merged and released in downstream modules
- [ ] Single feature has passed QA on local environment
- [ ] The initial request has approved/reviewed changes
13 changes: 13 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: auto-merge

on:
pull_request_target:

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
github-token: "${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}"
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/vendor
/files
/tests/logs
/var
.phpunit.result.cache
.php_cs.cache

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###


###> symfony/framework-bundle ###
/.env.dev
/.env.local
/templates
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
###< symfony/framework-bundle ###
77 changes: 77 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

use PhpCsFixer\Config;

$config = new Config();

$config->getFinder()->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return $config
->setRules([
'@PSR12' => true,
'@PHP80Migration' => true,
'no_unused_imports' => true,
'declare_strict_types' => true,
'phpdoc_add_missing_param_annotation' => [
'only_untyped' => true,
],
'self_accessor' => true,
'self_static_accessor' => true,
'no_unneeded_braces' => true,
'no_superfluous_elseif' => true,
'no_useless_else' => true,
'simplified_if_return' => true,
'yoda_style' => true,
'type_declaration_spaces' => true,
'lambda_not_used_import' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => [
'class',
'function',
'const',
],
],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'declare_parentheses' => true,
'explicit_indirect_variable' => true,
'single_space_around_construct' => true,
'no_leading_namespace_whitespace' => true,
'concat_space' => true,
'object_operator_without_whitespace' => true,
'operator_linebreak' => true,
'standardize_increment' => true,
'standardize_not_equals' => true,
'align_multiline_comment' => [
'comment_type' => 'all_multiline',
],
'general_phpdoc_tag_rename' => [
'replacements' => [
'inheritDocs' => 'inheritDoc',
],
],
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_single_line_var_spacing' => true,
'no_useless_return' => true,
'return_assignment' => true,
'simplified_null_return' => true,
'explicit_string_variable' => true,
'single_quote' => true,
'array_indentation' => true,
'blank_line_before_statement' => true,
'method_chaining_indentation' => true,
'no_extra_blank_lines' => true,
'no_spaces_around_offset' => true,
'types_spaces' => true,
])
->setRiskyAllowed(true)
->setCacheFile(__DIR__ . '/.php_cs.cache');
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @productsupcom/connector-development
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM docker.productsup.com/cde/cde-php-cli-base:8.2

COPY src/ ./src
COPY config/ ./config
COPY bin/ ./bin
COPY .env composer.json composer.lock symfony.lock ./

ARG COMPOSER_AUTH=local
RUN composer install --no-dev
RUN bin/console cache:warmup --env=prod

CMD ["php", "bin/console"]
123 changes: 123 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
env.name = "bin-cde-app-skeleton"
env.description = "bin-cde-app-skeleton"
env.maintainer = "Channel Dev Team <[email protected]>"
env.homepage = "https://github.com/productsupcom/bin-cde-app-skeleton"
def slack_channel = "#team-cd-dromund-kaas-notifications"
String runtimeContainer = "php-cli"
env.box_version = "3.11.1"
env.branch
env.version
env.gitCommitHash
env.gitCommitAuthor
env.gitCommitMessage
env.package_file_name
env.current_stage = 'undefined'

def setCurrentStage(name) {
env.current_stage = name
}

pipeline {
agent { label 'jenkins-4'}

options {
buildDiscarder(
logRotator(
numToKeepStr: '5',
artifactNumToKeepStr: '5'
)
)
timestamps()
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
skipDefaultCheckout()
}

environment {
COMPOSE_PROJECT_NAME = "${env.JOB_NAME}_${env.BUILD_ID}"
}

stages {
// Checkout code with tags. The regular scm call does a flat checkout
// and we need the tags to set the version
stage("Checkout") {
steps {
setCurrentStage("Checkout")
gitCheckout()
}
}

// set version with the following scheme
// tags: version = <tag>
// PR: version = <latest tag>-<PR number>
// branch: version = <latest tag>-<branch name>
stage('Prepare Info') {
steps {
setCurrentStage("Prepare Info")
prepareInfo()
}
}

// Pull docker image to use for the tests / build
stage('Pull image and build code') {
steps {
setCurrentStage("Pull image and build code")
pullAndBuild(runtimeContainer: "${runtimeContainer}")
}
}

stage('Check APP_ENV') {
steps {
script {
def envFile = readProperties file: '.env'
if (envFile['APP_ENV'] != 'prod') {
error("APP_ENV is not set to 'prod' in .env file")
}
}
}
}

stage('Running CS diff') {
steps {
setCurrentStage("Running CS diff")
sh "docker-compose run ${runtimeContainer} composer csdiff"
}
}

stage('Running Static Code Analysis') {
steps {
setCurrentStage("Running Static Code Analysis")
sh "docker-compose run ${runtimeContainer} composer stan"
}
}

stage('Running Unit Tests') {
steps {
setCurrentStage("Running Unit Tests")
runUnitTests(runtimeContainer: "${runtimeContainer}")
}
post {
failure {
junit skipPublishingChecks: true, testResults: 'reports/logfile.xml'
}
}
}
}

// Run post jobs steps
post {
// failure sends a failure slack message if the pipeline exit with a failed state
failure {
slackSend message: "*${env.name} <${RUN_DISPLAY_URL}|failed>*\nat stage: *${env.current_stage}*\nfor *${env.branch}* at commit *${env.gitCommitHash}*\nwhen *${env.gitCommitAuthor}* performed\n> ${env.gitCommitMessage}", channel: "${slack_channel}", color: "danger"
}
// success sends a success slack message if the pipeline exit with a success state
success {
slackSend message: "*${env.name} <${RUN_DISPLAY_URL}|success>*.\nAll checks passed for *${env.branch}* \nat commit *${env.gitCommitHash}* \nwhen *${env.gitCommitAuthor}* performed \n> ${env.gitCommitMessage}.", channel: "${slack_channel}", color: "good"
}
// cleanup always run last and will trigger for both success and failure states
cleanup {
sh "docker-compose down --volumes"
cleanWs deleteDirs: true
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# bin-cde-app-skeleton
17 changes: 17 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php

use Productsup\BinCdeAppSkeleton\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
19 changes: 19 additions & 0 deletions bin/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php

if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
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';
}
Loading

0 comments on commit 8a76dfb

Please sign in to comment.