diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fc134fc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# https://EditorConfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +block_comment_start = /* +block_comment = * +block_comment_end = */ + +[*.yml] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 4ad9030..789106a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,11 @@ +.editorconfig export-ignore .gitattributes export-ignore +.github/ export-ignore .gitignore export-ignore CHANGELOG.md export-ignore ecs.php export-ignore phpstan.neon export-ignore phpunit.xml.dist export-ignore -README.md export-ignore -/docs export-ignore -/tests export-ignore +docs/ export-ignore +tests/ export-ignore +stubs/ export-ignore diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml new file mode 100644 index 0000000..1a42dfc --- /dev/null +++ b/.github/workflows/integrate.yml @@ -0,0 +1,169 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow + +name: "Integrate" + +on: + push: + branches: + - "develop" + pull_request: null + +jobs: + byte_level: + name: "0️⃣ Byte-level" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Check file permissions" + run: | + test "$(find . -type f -not -path './.git/*' -executable)" = "" + + - name: "Find non-printable ASCII characters" + run: | + ! LC_ALL=C.UTF-8 find . -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]" | grep -v '// @ignore-non-ascii$' + + syntax_errors: + name: "1️⃣ Syntax errors" + runs-on: "ubuntu-latest" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + extensions: "intl" + ini-values: "post_max_size=256M" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Check source code for syntax errors" + run: "composer exec -- parallel-lint src/ ecs.php" + # @TODO Check template files for syntax errors + + unit_tests: + name: "2️⃣ Unit and functional tests" + needs: + - "byte_level" + - "syntax_errors" + strategy: + matrix: + php-version: + - "8.0" + - "8.1" + dependencies: + - "lowest" + - "highest" + runs-on: "ubuntu-latest" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + extensions: "intl" + ini-values: "post_max_size=256M" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependencies }}" + + - name: "Execute unit tests" +# run: "composer run-script --no-interaction phpunit -- --verbose" + run: "echo 'Tom has the key.'" + # @TODO Functional tests + +# - name: Send coverage to Coveralls +# if: "matrix.php-version == '8.1' && matrix.dependencies == 'highest'" +# env: +# COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" +# run: | +# wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.2/php-coveralls.phar" +# php ./php-coveralls.phar -v + + static_analysis: + name: "3️⃣ Static Analysis" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-latest" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + extensions: "intl" + ini-values: "post_max_size=256M" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Validate Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Execute static analysis" + run: "composer run-script --no-interaction analyze" + # @TODO Magic Number Detector, Copy-Paste Detector + + coding_standards: + name: "4️⃣ Coding Standards" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-latest" + steps: + - name: "Set up PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + extensions: "intl" + ini-values: "post_max_size=256M" + + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Check EditorConfig configuration" + run: "test -f .editorconfig" + + - name: "Check adherence to EditorConfig" + uses: "greut/eclint-action@v0" + + - name: "Install dependencies" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: "Check coding style" + run: "composer run-script --no-interaction ecs" + + exported_files: + name: "5️⃣ Exported files" + needs: + - "byte_level" + - "syntax_errors" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout code" + uses: "actions/checkout@v3" + + - name: "Check exported files" + run: | + EXPECTED="LICENSE,README.md,composer.json" + CURRENT="$(git archive HEAD | tar --list --exclude="src" --exclude="src/*" | paste -s -d ",")" + echo "CURRENT =${CURRENT}" + echo "EXPECTED=${EXPECTED}" + test "${CURRENT}" = "${EXPECTED}" diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 6202d6e..0000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: PHP Composer - -on: - push: - branches: [ develop ] - pull_request: - branches: [ develop ] - -jobs: - build: - - runs-on: ${{ matrix.operating-system }} - strategy: - matrix: - operating-system: [ubuntu-latest] - php-versions: ['8.0', '8.1'] - name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: intl #optional - ini-values: "post_max_size=256M" #optional - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v2 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- - - - name: Install dependencies - run: composer install --prefer-dist --no-progress - - - name: Run PHPStan - run: composer run-script analyze -- --no-interaction - - - name: Run ECS - run: composer run-script psr12 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2228e54..2d09aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.2.2 (2022-09-27) +* Updated Veneer dependency +* Updated CI environment + ## v0.2.1 (2022-08-24) * Added concrete types to all members diff --git a/LICENSE b/LICENSE index ed668e1..2c15aa8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Decode Labs +Copyright (c) 2022 Decode Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 5cf40ff..61b40a1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/typify?style=flat)](https://packagist.org/packages/decodelabs/typify) [![Latest Version](https://img.shields.io/packagist/v/decodelabs/typify.svg?style=flat)](https://packagist.org/packages/decodelabs/typify) [![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/typify.svg?style=flat)](https://packagist.org/packages/decodelabs/typify) -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/decodelabs/typify/PHP%20Composer)](https://github.com/decodelabs/typify/actions/workflows/php.yml) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/decodelabs/typify/Integrate)](https://github.com/decodelabs/typify/actions/workflows/integrate.yml) [![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true&style=flat)](https://github.com/phpstan/phpstan) [![License](https://img.shields.io/packagist/l/decodelabs/typify?style=flat)](https://packagist.org/packages/decodelabs/typify) diff --git a/composer.json b/composer.json index 359c877..67b2fd3 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,14 @@ "require": { "php": "^8.0", - "decodelabs/veneer": "^0.9", + "decodelabs/veneer": "^0.10", "decodelabs/exceptional": "^0.4" }, "require-dev": { "phpunit/phpunit": "^9", "phpstan/phpstan": "^1", "phpstan/extension-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3", "symplify/easy-coding-standard": "^11", "decodelabs/phpstan-decodelabs": "^0.6" @@ -42,7 +43,19 @@ }, "scripts": { "analyze": "phpstan analyze --no-progress", - "psr12": "ecs check --no-progress-bar", - "psr12-fix": "ecs check --no-progress-bar --fix" + "ecs": "ecs check --no-progress-bar", + "ecs-fix": "ecs check --no-progress-bar --fix", + "lint": "parallel-lint src/ stubs/ ecs.php", + "eclint": "eclint check src/ stubs/ ecs.php", + "eclint-fix": "eclint fix src/ stubs/ ecs.php", + "non-ascii": "! LC_ALL=C.UTF-8 find src/ -type f -name \"*.php\" -print0 | xargs -0 -- grep -PHn \"[^ -~]\" | grep -v '// @ignore-non-ascii$'", + "check": [ + "@composer update", + "@analyze", + "@ecs", + "@lint", + "@eclint", + "@non-ascii" + ] } } diff --git a/phpstan.neon b/phpstan.neon index 16f0d34..b625587 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,4 @@ parameters: paths: - - src + - src/ level: max diff --git a/stubs/DecodeLabs/Typify.php b/stubs/DecodeLabs/Typify.php index be87bbc..d440483 100644 --- a/stubs/DecodeLabs/Typify.php +++ b/stubs/DecodeLabs/Typify.php @@ -7,6 +7,6 @@ use DecodeLabs\Veneer\Proxy; use DecodeLabs\Veneer\ProxyTrait; use DecodeLabs\Typify\Detector as Inst; -class Typify implements Proxy { use ProxyTrait; +class Typify implements Proxy { use ProxyTrait; const VENEER = 'Typify'; const VENEER_TARGET = Inst::class;};