-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 5384d7e
Showing
38 changed files
with
1,628 additions
and
0 deletions.
There are no files selected for viewing
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,19 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
|
||
[**.yml] | ||
indent_size = 2 | ||
|
||
[**.md] | ||
charset = utf-8 | ||
insert_final_newline = true | ||
|
||
[**.{php,xml,yml,json,dist}] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Do not put this files on a distribution package (by .gitignore) | ||
/tools/ export-ignore | ||
/vendor/ export-ignore | ||
/composer.lock export-ignore | ||
|
||
# Do not put this files on a distribution package | ||
/.github/ export-ignore | ||
/.phive/ export-ignore | ||
/build/ export-ignore | ||
/tests/ export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php-cs-fixer.dist.php export-ignore | ||
/phpcs.xml.dist export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/sonar-project.properties export-ignore | ||
|
||
# Do not count these files on github code language | ||
/tests/_files/** linguist-detectable=false |
Validating CODEOWNERS rules …
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 @@ | ||
# see https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners | ||
/.github/* @phpcfdi/core-maintainers |
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,130 @@ | ||
name: build | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ "main" ] | ||
push: | ||
branches: [ "main" ] | ||
schedule: | ||
- cron: '0 16 * * 0' # sunday 16:00 | ||
|
||
# Actions | ||
# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action | ||
|
||
jobs: | ||
|
||
composer-normalize: | ||
name: Composer normalization | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
coverage: none | ||
tools: composer-normalize | ||
env: | ||
fail-fast: true | ||
- name: Composer normalize | ||
run: composer-normalize | ||
|
||
phpcs: | ||
name: Code Style (phpcs) | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
coverage: none | ||
tools: cs2pr, phpcs | ||
env: | ||
fail-fast: true | ||
- name: Code style (phpcs) | ||
run: phpcs -q --report=checkstyle | cs2pr | ||
|
||
php-cs-fixer: | ||
name: Code style (php-cs-fixer) | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
coverage: none | ||
tools: cs2pr, php-cs-fixer | ||
env: | ||
fail-fast: true | ||
- name: Code style (php-cs-fixer) | ||
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr | ||
|
||
phpstan: | ||
name: Code analysis (phpstan) | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
extensions: gd | ||
coverage: none | ||
tools: composer:v2, cs2pr, phpstan | ||
env: | ||
fail-fast: true | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install project dependencies | ||
run: composer upgrade --no-interaction --no-progress --prefer-dist | ||
- name: PHPStan | ||
run: phpstan analyse --no-progress --verbose | ||
|
||
tests: | ||
name: Tests on PHP ${{ matrix.php-version }} | ||
runs-on: "ubuntu-latest" | ||
strategy: | ||
matrix: | ||
php-version: ['8.1', '8.2', '8.3'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
extensions: gd | ||
coverage: none | ||
tools: composer:v2 | ||
env: | ||
fail-fast: true | ||
- name: Set up environment | ||
run: cp tests/.env.example tests/.env | ||
- name: Get model files | ||
run: bin/download-model model | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install project dependencies | ||
run: composer upgrade --no-interaction --no-progress --prefer-dist | ||
- name: Tests (phpunit) | ||
run: vendor/bin/phpunit --testdox |
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,115 @@ | ||
name: sonarcloud | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ "main" ] | ||
|
||
# Actions | ||
# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action | ||
# sonarsource/sonarcloud-github-action@master https://github.com/marketplace/actions/sonarcloud-scan | ||
|
||
jobs: | ||
|
||
tests-coverage: | ||
name: Build code coverage | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
extensions: gd | ||
coverage: xdebug | ||
tools: composer:v2 | ||
env: | ||
fail-fast: true | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Set up environment | ||
run: cp tests/.env.example tests/.env | ||
- name: Get model files | ||
run: bin/download-model model | ||
- name: Install project dependencies | ||
run: composer upgrade --no-interaction --no-progress --prefer-dist | ||
- name: Create code coverage | ||
run: vendor/bin/phpunit --testdox --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml | ||
- name: Store code coverage | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: code-coverage | ||
path: build/coverage | ||
|
||
sonarcloud-secrets: | ||
name: SonarCloud check secrets are present | ||
runs-on: ubuntu-latest | ||
outputs: | ||
github: ${{ steps.check-secrets.outputs.github }} | ||
sonar: ${{ steps.check-secrets.outputs.sonar }} | ||
steps: | ||
- name: Check secrets are present | ||
id: check-secrets | ||
run: | | ||
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then | ||
echo "github=yes" >> $GITHUB_OUTPUT | ||
else | ||
echo "github=no" >> $GITHUB_OUTPUT | ||
echo "::warning ::GITHUB_TOKEN non set" | ||
fi | ||
if [ -n "${{ secrets.SONAR_TOKEN }}" ]; then | ||
echo "sonar=yes" >> $GITHUB_OUTPUT | ||
else | ||
echo "sonar=no" >> $GITHUB_OUTPUT | ||
echo "::warning ::SONAR_TOKEN non set" | ||
fi | ||
sonarcloud: | ||
name: SonarCloud Scan and Report | ||
needs: [ "tests-coverage", "sonarcloud-secrets" ] | ||
if: ${{ needs.sonarcloud-secrets.outputs.github == 'yes' && needs.sonarcloud-secrets.outputs.sonar == 'yes' }} | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Unshallow clone to provide blame information | ||
run: git fetch --unshallow | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.3' | ||
extensions: gd | ||
coverage: none | ||
tools: composer:v2 | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install project dependencies | ||
run: composer upgrade --no-interaction --no-progress --prefer-dist | ||
- name: Obtain code coverage | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: code-coverage | ||
path: build/coverage | ||
- name: Prepare SonarCloud Code Coverage Files | ||
run: | | ||
sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/junit.xml > build/sonar-junit.xml | ||
sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/clover.xml > build/sonar-coverage.xml | ||
- name: SonarCloud Scan | ||
uses: sonarsource/sonarcloud-github-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
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,5 @@ | ||
# do not include this files on git | ||
/tools/ | ||
/vendor/ | ||
/composer.lock | ||
.phpunit.result.cache |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="phpcs" version="^3.10.3" installed="3.10.3" location="./tools/phpcs" copy="false"/> | ||
<phar name="phpcbf" version="^3.10.3" installed="3.10.3" location="./tools/phpcbf" copy="false"/> | ||
<phar name="php-cs-fixer" version="^3.64.0" installed="3.64.0" location="./tools/php-cs-fixer" copy="false"/> | ||
<phar name="phpstan" version="^1.12.5" installed="1.12.5" location="./tools/phpstan" copy="false"/> | ||
<phar name="composer-normalize" version="^2.44.0" installed="2.44.0" location="./tools/composer-normalize" copy="false"/> | ||
</phive> |
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,50 @@ | ||
<?php | ||
|
||
/** | ||
* @noinspection PhpUndefinedClassInspection | ||
* @noinspection PhpUndefinedNamespaceInspection | ||
* @see https://cs.symfony.com/doc/ruleSets/ | ||
* @see https://cs.symfony.com/doc/rules/ | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRiskyAllowed(true) | ||
->setCacheFile(__DIR__ . '/build/php-cs-fixer.cache') | ||
->setRules([ | ||
'@PSR12' => true, | ||
'@PSR12:risky' => true, | ||
'@PHP71Migration:risky' => true, | ||
'@PHP73Migration' => true, | ||
// symfony | ||
'class_attributes_separation' => true, | ||
'whitespace_after_comma_in_array' => true, | ||
'no_empty_statement' => true, | ||
'no_extra_blank_lines' => true, | ||
'type_declaration_spaces' => true, | ||
'no_blank_lines_after_phpdoc' => true, | ||
'object_operator_without_whitespace' => true, | ||
'binary_operator_spaces' => true, | ||
'phpdoc_scalar' => true, | ||
'no_trailing_comma_in_singleline' => true, | ||
'single_quote' => true, | ||
'no_singleline_whitespace_before_semicolons' => true, | ||
'no_unused_imports' => true, | ||
'yoda_style' => ['equal' => true, 'identical' => true, 'less_and_greater' => null], | ||
'standardize_not_equals' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'linebreak_after_opening_tag' => true, | ||
// symfony:risky | ||
'no_alias_functions' => true, | ||
'self_accessor' => true, | ||
// contrib | ||
'not_operator_with_successor_space' => true, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
->append([__FILE__]) | ||
->exclude(['vendor', 'tools', 'build']) | ||
) | ||
; |
Oops, something went wrong.