Skip to content

Commit

Permalink
Merge pull request #17 from wayofdev/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp authored Jul 31, 2024
2 parents cebb491 + 8bfa24e commit 2eb65c4
Show file tree
Hide file tree
Showing 41 changed files with 408 additions and 122 deletions.
215 changes: 215 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
---

on: # yamllint disable-line rule:truthy
pull_request:
branches:
- master
- develop

name: 🧹 Fix PHP coding standards

env:
# Disable docker support in Makefile
APP_RUNNER: 'cd app &&'

jobs:
commit-linting:
timeout-minutes: 4
runs-on: ubuntu-latest
concurrency:
cancel-in-progress: true
group: commit-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
permissions:
contents: read
pull-requests: read
steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🧐 Lint commits using "commitlint"
uses: wagoid/commitlint-github-action@v6.0.1
with:
configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs
failOnWarnings: false
failOnErrors: true
helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'

yaml-linting:
timeout-minutes: 4
runs-on: ubuntu-latest
concurrency:
cancel-in-progress: true
group: yaml-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
permissions:
contents: read
pull-requests: read
steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🧐 Lint YAML files
uses: ibiqlik/action-yamllint@v3.1.1
with:
config_file: .github/.yamllint.yaml
file_or_dir: '.'
strict: true

markdown-linting:
timeout-minutes: 4
runs-on: ubuntu-latest
concurrency:
cancel-in-progress: true
group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
steps:
- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🧐 Lint Markdown files
uses: DavidAnson/markdownlint-cli2-action@v16.0.0
with:
config: '.github/.markdownlint.json'
globs: |
**/*.md
!CHANGELOG.md
!app/vendor
!app/node_modules
composer-linting:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: composer-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
matrix:
os:
- ubuntu-latest
php-version:
- '8.3'
dependencies:
- locked
permissions:
contents: write
steps:
- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@2.30.5
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets
ini-values: error_reporting=E_ALL
coverage: none
tools: phive

- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🛠️ Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: 🤖 Validate composer.json and composer.lock
run: make validate-composer

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1
with:
working-directory: app

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/install@v3.1.1
with:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 📥 Install dependencies with phive
working-directory: app
env:
PHIVE_HOME: .phive
run: phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x47436587D82C4A39
shell: bash

- name: 🔍 Run ergebnis/composer-normalize
working-directory: app
run: .phive/composer-normalize --ansi --dry-run

coding-standards:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
matrix:
os:
- ubuntu-latest
php-version:
- '8.3'
dependencies:
- locked
permissions:
contents: write
steps:
- name: ⚙️ Set git to use LF line endings
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: 🛠️ Setup PHP
uses: shivammathur/setup-php@2.30.5
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, decimal
ini-values: error_reporting=E_ALL
coverage: none

- name: 📦 Check out the codebase
uses: actions/checkout@v4.1.6

- name: 🛠️ Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: 🤖 Validate composer.json and composer.lock
run: make validate-composer

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.1
with:
working-directory: app

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/cache@v4.0.2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/install@v3.1.1
with:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 🛠️ Prepare environment
run: make prepare

- name: 🚨 Run coding standards task
run: make lint-php
env:
PHP_CS_FIXER_IGNORE_ENV: true

- name: 📤 Commit and push changed files back to GitHub
uses: stefanzweifel/git-auto-commit-action@v5.0.1
with:
commit_message: 'style(php-cs-fixer): lint php files and fix coding standards'
branch: ${{ github.head_ref }}
commit_author: 'github-actions <github-actions@users.noreply.github.com>'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ up: # Creates and starts containers, defined in docker-compose and override file
@sleep 1
$(DOCKER_COMPOSE) exec app wait4x postgresql 'postgres://${DB_USERNAME}:${DB_PASSWORD}@database:5432/${DB_DATABASE}?sslmode=disable' -t 1m
$(DOCKER_COMPOSE) exec app wait4x tcp '${TEMPORAL_ADDRESS}' -t 1m
@echo ""
@echo "${GREEN}Project is up and running!${RST}"
@echo ""
@echo "${BLUE}API:${RST} https://api.${COMPOSE_PROJECT_NAME}.docker"
@echo "${BLUE}Temporal UI:${RST} https://temporal.${COMPOSE_PROJECT_NAME}.docker"
@echo ""
.PHONY: up

down: # Stops and removes containers of this project
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ You should observe your current-date route within the displayed list:
+--------------+--------+----------+------------------------------------------------+--------+
```

#### What's Next?
### What's Next?

Now, dive deeper into the fundamentals by reading some articles:

Expand Down Expand Up @@ -189,7 +189,7 @@ composer rr:download

If you chose to install the default application skeleton, your project will have the following directory structure:

```
```text
- Endpoint
- Web
- UserController.php
Expand Down Expand Up @@ -242,7 +242,7 @@ If you chose to install the default application skeleton, your project will have
- ExceptionHandlerInterceptor.php
```

#### Here's a brief explanation of the directories and files in this structure
### Here's a brief explanation of the directories and files in this structure

- **Endpoint**: This directory contains the entry points for your application, including HTTP endpoints (in the Web
subdirectory), command-line interfaces (in the Console subdirectory), and gRPC services (in the RPC subdirectory).
Expand Down
24 changes: 24 additions & 0 deletions app/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use WayOfDev\PhpCsFixer\Config\ConfigBuilder;
use WayOfDev\PhpCsFixer\Config\RuleSets\DefaultSet;

require_once 'vendor/autoload.php';

$config = ConfigBuilder::createFromRuleSet(new DefaultSet(['static_lambda' => false]))
->inDir(__DIR__ . '/app')
->inDir(__DIR__ . '/tests')
->addFiles([
__FILE__,
__DIR__ . '/functions.php',
__DIR__ . '/app.php',
])
->useParallelConfig()
->getConfig()
;

$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php-cs-fixer.cache');

return $config;
11 changes: 5 additions & 6 deletions app/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

declare(strict_types=1);

use App\Application\Kernel;
use App\Application\Exception\Handler;
use App\Application\Kernel;

// If you forgot to configure some of this in your php.ini file,
// then don't worry, we will set the standard environment
// settings for you.

\mb_internal_encoding('UTF-8');
\error_reporting((E_ALL | E_STRICT) ^ E_DEPRECATED);
\ini_set('display_errors', 'stderr');
mb_internal_encoding('UTF-8');
error_reporting((E_ALL | E_STRICT) ^ E_DEPRECATED);
ini_set('display_errors', 'stderr');

// Application helper functions. Must be included before the composer autoloader.
require __DIR__ . '/functions.php';

// Register Composer's auto loader.
require __DIR__ . '/vendor/autoload.php';


// Initialize shared container, bindings, directories and etc.
$app = Kernel::create(
directories: ['root' => __DIR__],
Expand All @@ -30,5 +29,5 @@
exit(255);
}

$code = (int)$app->serve();
$code = (int) $app->serve();
exit($code);
11 changes: 5 additions & 6 deletions app/app/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
/**
* Configuration for cache component.
*
* @link https://spiral.dev/docs/basics-cache
* @see https://spiral.dev/docs/basics-cache
*/
return [
/**
/*
* The default cache connection that gets used while using this caching library.
*/
'default' => env('CACHE_STORAGE', 'rr-local'),

/**
/*
* Aliases, if you want to use domain specific storages.
*/
'aliases' => [
Expand All @@ -27,11 +27,10 @@
// 'blog-data' => 'rr-local',
],

/**
/*
* Here you may define all of the cache "storages" for your application as well as their types.
*/
'storages' => [

'rr-local' => [
'type' => 'roadrunner',
'driver' => 'local',
Expand All @@ -49,7 +48,7 @@
],
],

/**
/*
* Aliases for storage types
*/
'typeAliases' => [
Expand Down
Loading

0 comments on commit 2eb65c4

Please sign in to comment.