move tools to a sub directory

This commit is contained in:
azjezz 2021-03-27 21:32:45 +01:00 committed by Saif Eddin Gmati
parent 28eb34e788
commit aa7b5779b3
21 changed files with 319 additions and 121 deletions

17
.editorconfig Normal file
View File

@ -0,0 +1,17 @@
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_size = 2

41
.gitattributes vendored
View File

@ -1,8 +1,35 @@
docs export-ignore
tests export-ignore
.github export-ignore
# Autodetect text files
* text=auto
.php_cs.dist export-ignore
.phpcs.xml export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
# ...Unless the name matches the following overriding patterns
# Definitively text files
*.php text
*.css text
*.js text
*.txt text
*.md text
*.xml text
*.json text
*.bat text
*.sql text
*.yml text
# Ensure those won't be messed up with
*.png binary
*.jpg binary
*.gif binary
*.ttf binary
# Ignore some meta files when creating an archive of this repository
/.github export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/tools export-ignore
/tests export-ignore
/docs export-ignore
# Avoid merge conflicts in CHANGELOG
# https://about.gitlab.com/2015/02/10/gitlab-reduced-merge-conflicts-by-90-percent-with-changelog-placeholders/
/CHANGELOG.md merge=union

79
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,79 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
labels:
- "Priority: Medium"
- "Status: Review Needed"
- "Subject: Dependencies"
commit-message:
prefix: "[dependencies]"
assignees:
- "azjezz"
- package-ecosystem: "composer"
directory: "/tools/phpunit"
schedule:
interval: "daily"
labels:
- "Priority: Medium"
- "Status: Review Needed"
- "Subject: Dependencies"
commit-message:
prefix: "[tools]"
assignees:
- "azjezz"
- package-ecosystem: "composer"
directory: "/tools/php-cs-fixer"
schedule:
interval: "daily"
labels:
- "Priority: Medium"
- "Status: Review Needed"
- "Subject: Dependencies"
commit-message:
prefix: "[tools]"
assignees:
- "azjezz"
- package-ecosystem: "composer"
directory: "/tools/php-codesniffer"
schedule:
interval: "daily"
labels:
- "Priority: Medium"
- "Status: Review Needed"
- "Subject: Dependencies"
commit-message:
prefix: "[tools]"
assignees:
- "azjezz"
- package-ecosystem: "composer"
directory: "/tools/psalm"
schedule:
interval: "daily"
labels:
- "Priority: Medium"
- "Status: Review Needed"
- "Subject: Dependencies"
commit-message:
prefix: "[tools]"
assignees:
- "azjezz"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "Priority: Medium"
- "Status: Review Needed"
- "Subject: Dependencies"
commit-message:
prefix: "[ga]"
assignees:
- "azjezz"

View File

@ -23,14 +23,11 @@ jobs:
extensions: bcmath, mbstring, intl, sodium, json
- name: "installing dependencies"
run: "composer install --no-interaction --no-progress --ignore-platform-req php"
- name: "running unit tests ( phpunit )"
run: "php vendor/bin/phpunit"
run: |
make install-root-dependencies
make install-unit-tests-dependencies
- name: "sending code coverage to coveralls"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls -x tests/logs/clover.xml -o tests/logs/coveralls-upload.json -v
run: make code-coverage

View File

@ -21,10 +21,9 @@ jobs:
extensions: bcmath, mbstring, intl, sodium, json
- name: "installing dependencies"
run: "composer update --no-interaction --no-progress"
run: |
make install-root-dependencies
make install-coding-standard-dependencies
- name: "checking coding standards ( codesniffer )"
run: "php vendor/bin/phpcs"
- name: "checking coding standards ( php-cs-fixer )"
run: "php vendor/bin/php-cs-fixer fix --dry-run --diff --ansi"
- name: "checking coding standards"
run: make coding-standard-check

View File

@ -21,7 +21,9 @@ jobs:
extensions: bcmath, mbstring, intl, sodium, json
- name: "installing dependencies"
run: "composer update --no-interaction --no-progress"
run: |
make install-root-dependencies
make install-type-check-dependencies
- name: "running security analysis ( psalm )"
run: "vendor/bin/psalm --output-format=github --taint-analysis"
run: make security-analysis

View File

@ -23,7 +23,9 @@ jobs:
extensions: bcmath, mbstring, intl, sodium, json
- name: "installing dependencies"
run: "composer update --no-interaction --no-progress"
run: |
make install-root-dependencies
make install-type-check-dependencies
- name: "running static analysis ( psalm )"
run: "vendor/bin/psalm --shepherd --stats"
- name: "running static analysis"
run: make type-coverage

View File

@ -42,7 +42,9 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}"
- name: "installing dependencies"
run: "composer install --no-interaction --no-progress --ignore-platform-req php"
run: |
make install-root-dependencies
make install-unit-tests-dependencies
- name: "running unit tests ( phpunit )"
run: "php vendor/bin/phpunit"
- name: "running unit tests"
run: make unit-tests

26
.gitignore vendored
View File

@ -1,7 +1,25 @@
/tests/logs/*
# phpstorm project files
.idea
# vs code project files
.vscode
# composer vendor dir
/vendor/
/tools/*/vendor/
composer.lock
# composer lock file
/composer.lock
/tools/*/composer.lock
.php_cs.cache
.phpunit.result.cache
# Mac DS_Store files
.DS_Store
# php-cs-fixer cache
/.php_cs.cache
# phpunit cache
/tools/phpunit/.phpunit.result.cache
# test logs
/tests/logs/*

40
Makefile Normal file
View File

@ -0,0 +1,40 @@
install-root-dependencies:
composer update
install-coding-standard-dependencies:
cd tools/php-cs-fixer && composer update --ignore-platform-req php
cd tools/php-codesniffer && composer update
install-type-check-dependencies:
cd tools/psalm && composer update
install-unit-tests-dependencies:
cd tools/phpunit && composer update
install: install-root-dependencies install-coding-standard-dependencies install-type-check-dependencies install-unit-tests-dependencies
coding-standard-fix:
php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php_cs.dist
php tools/php-codesniffer/vendor/bin/phpcbf --standard=tools/php-codesniffer/.phpcs.xml
coding-standard-check:
php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php_cs.dist --dry-run
php tools/php-codesniffer/vendor/bin/phpcs --standard=tools/php-codesniffer/.phpcs.xml
type-check:
php tools/psalm/vendor/bin/psalm -c tools/psalm/psalm.xml
type-coverage:
php tools/psalm/vendor/bin/psalm -c tools/psalm/psalm.xml --shepherd --stats
security-analysis:
php tools/psalm/vendor/bin/psalm -c tools/psalm/psalm.xml --taint-analysis
unit-tests:
php tools/phpunit/vendor/bin/phpunit -c tools/phpunit/phpunit.xml.dist
code-coverage: unit-tests
composer global require php-coveralls/php-coveralls
php-coveralls -x tests/logs/clover.xml -o tests/logs/coveralls-upload.json -v
check: coding-standard-check type-check security-analysis unit-tests

View File

@ -17,14 +17,6 @@
"ext-sodium": "*",
"ext-intl": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^2.18",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "dev-master",
"php-standard-library/psalm-plugin": "^1.0"
},
"autoload": {
"psr-4": {
"Psl\\Integration\\": "integration"
@ -38,31 +30,6 @@
"Psl\\Tests\\": "tests/Psl"
}
},
"scripts": {
"cs:fix": [
"phpcbf",
"php-cs-fixer fix"
],
"cs:check": [
"phpcs",
"php-cs-fixer fix --dry-run"
],
"type:check": "psalm",
"type:coverage": "psalm --shepherd",
"test:unit": "phpunit",
"code:coverage": "php-coveralls -v",
"security:analysis": "psalm --taint-analysis",
"check": [
"@cs:check",
"@type:check",
"@security:analysis",
"@test:unit"
]
},
"config": {
"process-timeout": 1200,
"sort-packages": true
},
"extra": {
"psalm": {
"pluginClass": "Psl\\Integration\\Psalm\\Plugin"

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" colors="true" stopOnFailure="true" bootstrap="vendor/autoload.php">
<coverage processUncoveredFiles="true">
<include>
<directory>src</directory>
</include>
<exclude>
<!-- Internal -->
<file>src/preload.php</file>
<file>src/bootstrap.php</file>
<directory>src/Psl/Internal</directory>
<!-- Base Exceptions -->
<directory>src/Psl/Exception</directory>
<!-- Constants -->
<file>src/Psl/Str/constants.php</file>
<file>src/Psl/Math/constants.php</file>
<file>src/Psl/Filesystem/constants.php</file>
<!-- Things that are not easily tested -->
<file>src/Psl/Filesystem/get_group.php</file>
<file>src/Psl/Filesystem/change_group.php</file>
<file>src/Psl/Filesystem/Internal/change_group.php</file>
<file>src/Psl/Filesystem/get_owner.php</file>
<file>src/Psl/Filesystem/change_owner.php</file>
<file>src/Psl/Filesystem/Internal/change_owner.php</file>
</exclude>
<report>
<clover outputFile="tests/logs/clover.xml"/>
</report>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="PHP Standard Library">
<directory>tests/Psl</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>

View File

@ -12,7 +12,7 @@ final class CurrentExecTest extends TestCase
{
public function testCurrentExe(): void
{
$phpunit = __DIR__ . '/../../../vendor/bin/phpunit';
$phpunit = __DIR__ . '/../../../tools/phpunit/vendor/bin/phpunit';
$phpunit = Filesystem\canonicalize($phpunit);
if (PHP_OS_FAMILY !== 'Windows' && Filesystem\is_symbolic_link($phpunit)) {
$phpunit = Filesystem\read_symbolic_link($phpunit);

View File

@ -3,8 +3,8 @@
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>The coding standard for PHP Standard Library.</description>
<file>src</file>
<file>tests</file>
<file>../../src</file>
<file>../../tests</file>
<arg name="basepath" value="."/>
<arg name="colors"/>

View File

@ -0,0 +1,12 @@
{
"type": "project",
"require": {
"php": "^7.4 || ^8.0",
"ext-bcmath": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-sodium": "*",
"squizlabs/php_codesniffer": "^3.5"
}
}

View File

@ -4,9 +4,9 @@ return PhpCsFixer\Config::create()
->setFinder(
\Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/docs',
__DIR__ . '/tests',
__DIR__ . '/../../src',
__DIR__ . '/../../docs',
__DIR__ . '/../../tests',
])
)
->setRiskyAllowed(true)

View File

@ -0,0 +1,12 @@
{
"type": "project",
"require": {
"php": "^7.4 || ^8.0",
"ext-bcmath": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-sodium": "*",
"friendsofphp/php-cs-fixer": "^2.18"
}
}

View File

@ -0,0 +1,12 @@
{
"type": "project",
"require": {
"php": "^7.4 || ^8.0",
"ext-bcmath": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-sodium": "*",
"phpunit/phpunit": "^9.5"
}
}

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" colors="true" stopOnFailure="true" bootstrap="../../vendor/autoload.php">
<coverage processUncoveredFiles="true">
<include>
<directory>../../src</directory>
</include>
<exclude>
<!-- Internal -->
<file>../../src/preload.php</file>
<file>../../src/bootstrap.php</file>
<directory>../../src/Psl/Internal</directory>
<!-- Base Exceptions -->
<directory>../../src/Psl/Exception</directory>
<!-- Constants -->
<file>../../src/Psl/Str/constants.php</file>
<file>../../src/Psl/Math/constants.php</file>
<file>../../src/Psl/Filesystem/constants.php</file>
<!-- Things that are not easily tested -->
<file>../../src/Psl/Filesystem/get_group.php</file>
<file>../../src/Psl/Filesystem/change_group.php</file>
<file>../../src/Psl/Filesystem/Internal/change_group.php</file>
<file>../../src/Psl/Filesystem/get_owner.php</file>
<file>../../src/Psl/Filesystem/change_owner.php</file>
<file>../../src/Psl/Filesystem/Internal/change_owner.php</file>
</exclude>
<report>
<clover outputFile="../../tests/logs/clover.xml" />
</report>
</coverage>
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="PHP Standard Library">
<directory>../../tests/Psl</directory>
</testsuite>
</testsuites>
<logging />
</phpunit>

13
tools/psalm/composer.json Normal file
View File

@ -0,0 +1,13 @@
{
"type": "project",
"require": {
"php": "^7.4 || ^8.0",
"ext-bcmath": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-sodium": "*",
"vimeo/psalm": "dev-master",
"php-standard-library/psalm-plugin": "^1.0"
}
}

View File

@ -1,13 +1,12 @@
<?xml version="1.0"?>
<psalm totallyTyped="true" resolveFromConfigFile="true" forbidEcho="true" strictBinaryOperands="true" phpVersion="7.4" allowPhpStormGenerics="true" allowStringToStandInForClass="true" rememberPropertyAssignmentsAfterCall="false" skipChecksOnUnresolvableIncludes="false" checkForThrowsDocblock="true" checkForThrowsInGlobalScope="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<projectFiles>
<directory name="src" />
<directory name="integration" />
<directory name="../../src" />
<directory name="../../integration" />
<ignoreFiles>
<directory name="vendor" />
<file name="src/bootstrap.php" />
<file name="src/preload.php" />
<file name="src/Psl/Internal/Loader.php" />
<file name="../../src/bootstrap.php" />
<file name="../../src/preload.php" />
<file name="../../src/Psl/Internal/Loader.php" />
</ignoreFiles>
</projectFiles>
@ -47,6 +46,6 @@
</issueHandlers>
<plugins>
<pluginClass class="Psl\Integration\Psalm\Plugin" />
<pluginClass class="Psl\Psalm\Plugin" />
</plugins>
</psalm>