diff --git a/.editorconfig b/.editorconfig index e147490..5e5b915 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,6 @@ indent_style = tab indent_size = tab tab_width = 4 -[{*.json,*.yaml,*.yml,*.md}] +[*.{json,yaml,yml,md}] indent_style = space indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 12910b6..62483a6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,10 @@ -# Not archived .docs export-ignore -tests export-ignore .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore +.github export-ignore Makefile export-ignore -phpstan.neon export-ignore README.md export-ignore +phpstan.neon export-ignore ruleset.xml export-ignore +tests export-ignore diff --git a/.github/.kodiak.toml b/.github/.kodiak.toml deleted file mode 100644 index 60c34b6..0000000 --- a/.github/.kodiak.toml +++ /dev/null @@ -1,10 +0,0 @@ -version = 1 - -[merge] -automerge_label = "automerge" -blacklist_title_regex = "^WIP.*" -blacklist_labels = ["WIP"] -method = "rebase" -delete_branch_on_merge = true -notify_on_conflict = true -optimistic_updates = false diff --git a/.github/workflows/codesniffer.yml b/.github/workflows/codesniffer.yml new file mode 100644 index 0000000..590394f --- /dev/null +++ b/.github/workflows/codesniffer.yml @@ -0,0 +1,18 @@ +name: "Codesniffer" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 8 * * 1" + +jobs: + codesniffer: + name: "Codesniffer" + uses: contributte/.github/.github/workflows/codesniffer.yml@master + with: + php: "8.4" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..c51c356 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,18 @@ +name: "Coverage" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 9 * * 1" + +jobs: + coverage: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master + with: + php: "8.4" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index 6654f5a..0000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,269 +0,0 @@ -name: "build" - -on: - pull_request: - paths-ignore: - - ".docs/**" - push: - branches: - - "master" - schedule: - - cron: "0 8 * * 1" # At 08:00 on Monday - -env: - extensions: "json" - cache-version: "1" - composer-version: "v1" - composer-install: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-stable" - -jobs: - qa: - name: "Quality assurance" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: ["7.4"] - operating-system: ["ubuntu-latest"] - fail-fast: false - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Validate Composer" - run: "composer validate" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "Coding Standard" - run: "make cs" - - static-analysis: - name: "Static analysis" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: ["7.4"] - operating-system: ["ubuntu-latest"] - fail-fast: false - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "PHPStan" - run: "make phpstan" - - tests: - name: "Tests" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: ["7.2", "7.3", "7.4"] - operating-system: ["ubuntu-latest"] - composer-args: [ "" ] - include: - - php-version: "7.2" - operating-system: "ubuntu-latest" - composer-args: "--prefer-lowest" - - php-version: "8.0" - operating-system: "ubuntu-latest" - composer-args: "" - fail-fast: false - - continue-on-error: "${{ matrix.php-version == '8.0' }}" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }} ${{ matrix.composer-args }}" - - - name: "Setup problem matchers for PHPUnit" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"' - - - name: "Tests" - run: "make tests" - - tests-code-coverage: - name: "Tests with code coverage" - runs-on: "${{ matrix.operating-system }}" - - strategy: - matrix: - php-version: ["7.4"] - operating-system: ["ubuntu-latest"] - fail-fast: false - - if: "github.event_name == 'push'" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Setup PHP cache environment" - id: "extcache" - uses: "shivammathur/cache-extensions@v1" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - key: "${{ env.cache-version }}" - - - name: "Cache PHP extensions" - uses: "actions/cache@v2" - with: - path: "${{ steps.extcache.outputs.dir }}" - key: "${{ steps.extcache.outputs.key }}" - restore-keys: "${{ steps.extcache.outputs.key }}" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.extensions }}" - tools: "composer:${{ env.composer-version }} " - - - name: "Setup problem matchers for PHP" - run: 'echo "::add-matcher::${{ runner.tool_cache }}/php.json"' - - - name: "Get Composer cache directory" - id: "composercache" - run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' - - - name: "Cache PHP dependencies" - uses: "actions/cache@v2" - with: - path: "${{ steps.composercache.outputs.dir }}" - key: "${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}" - restore-keys: "${{ runner.os }}-composer-" - - - name: "Install dependencies" - run: "${{ env.composer-install }}" - - - name: "Tests" - run: "make coverage-clover" - - - name: "Coveralls.io" - env: - CI_NAME: github - CI: true - COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - run: | - wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar - php php-coveralls.phar --verbose --config tests/.coveralls.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..cd37eba --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,18 @@ +name: "Phpstan" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 10 * * 1" + +jobs: + phpstan: + name: "Phpstan" + uses: contributte/.github/.github/workflows/phpstan.yml@master + with: + php: "8.4" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ef17693 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,43 @@ +name: "Nette Tester" + +on: + pull_request: + workflow_dispatch: + + push: + branches: ["*"] + + schedule: + - cron: "0 10 * * 1" + +jobs: + test85: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.5" + + test84: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.4" + + test83: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.3" + + test82: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.2" + + testlower: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@master + with: + php: "8.2" + composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/.gitignore b/.gitignore index b0fa45a..f0b3670 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,9 @@ /composer.lock # Tests -/coverage.xml +/tests/tmp +/coverage.* +/tests/**/*.log +/tests/**/*.html +/tests/**/*.expected +/tests/**/*.actual diff --git a/Makefile b/Makefile index efd1247..06ce148 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,34 @@ -.PHONY: install qa cs csf phpstan tests coverage-clover coverage-html - +.PHONY: install install: composer update +.PHONY: qa qa: phpstan cs +.PHONY: cs cs: - vendor/bin/codesniffer src tests +ifdef GITHUB_ACTION + vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" -q --report=checkstyle src tests | cs2pr +else + vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" src tests +endif +.PHONY: csf csf: - vendor/bin/codefixer src tests + vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" src tests +.PHONY: phpstan phpstan: - vendor/bin/phpstan analyse -l max -c phpstan.neon src + vendor/bin/phpstan analyse -c phpstan.neon +.PHONY: tests tests: - vendor/bin/tester -s -p php --colors 1 -C tests/cases - -coverage-clover: - vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests/cases - -coverage-html: - vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.html --coverage-src ./src tests/cases + vendor/bin/tester -s -p php --colors 1 -C tests/Cases + +.PHONY: coverage +coverage: +ifdef GITHUB_ACTION + vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases +else + vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.html --coverage-src src tests/Cases +endif diff --git a/README.md b/README.md index 87ee3fd..4d95365 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ composer require juicyfx/juicy | State | Version | Branch | PHP | |-------------|---------|----------|---------| -| dev | `^0.2` | `master` | `>=7.2` | -| stable | `^0.1` | `master` | `>=7.2` | +| dev | `^0.4` | `master` | `>=8.2` | +| stable | `^0.3` | `master` | `>=8.2` | ## Usage diff --git a/composer.json b/composer.json index a881fc0..135e593 100644 --- a/composer.json +++ b/composer.json @@ -1,28 +1,25 @@ { "name": "juicyfx/juicy", - "description": "\uD83D\uDC18 PHP client for serverless juicy functions", + "description": "PHP client for serverless juicy functions", "keywords": ["juicyfx", "juicy", "php", "serverless", "lambda", "zeit", "now", "zeit-now"], "type": "library", "license": "MIT", "homepage": "https://github.com/juicyfx/juicy", "authors": [ { - "name": "Milan Felix Ć ulc", + "name": "Milan Felix Sulc", "homepage": "https://f3l1x.io" } ], "require": { - "php": ">=7.2", - "guzzlehttp/guzzle": "^6.5.5 || ^7.2.0" + "php": ">=8.2", + "guzzlehttp/guzzle": "^7.2.0" }, "require-dev": { - "mockery/mockery": "^1.3.3", - "ninjify/nunjuck": "^0.4.0", - "ninjify/qa": "^0.12.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-nette": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12" + "contributte/phpstan": "^0.2.0", + "contributte/qa": "^0.4.0", + "contributte/tester": "^0.3.0", + "mockery/mockery": "^1.6.12" }, "autoload": { "psr-4": { @@ -31,17 +28,20 @@ }, "autoload-dev": { "psr-4": { - "Tests\\Cases\\": "tests/cases" + "Tests\\": "tests" } }, "minimum-stability": "dev", "prefer-stable": true, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "extra": { "branch-alias": { - "dev-master": "0.2.x-dev" + "dev-master": "0.4.x-dev" } } } diff --git a/phpstan.neon b/phpstan.neon index 4c2ba4a..5011892 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,8 +1,15 @@ includes: - - vendor/phpstan/phpstan-deprecation-rules/rules.neon - - vendor/phpstan/phpstan-nette/extension.neon - - vendor/phpstan/phpstan-nette/rules.neon - - vendor/phpstan/phpstan-strict-rules/rules.neon + - vendor/contributte/phpstan/phpstan.neon parameters: - ignoreErrors: + level: 9 + phpVersion: 80200 + + scanDirectories: + - src + + fileExtensions: + - php + + paths: + - src diff --git a/ruleset.xml b/ruleset.xml index 670f46a..fa3627b 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,14 +1,14 @@ - + - + - + diff --git a/src/Lambda/Pdfx/PdfResponse.php b/src/Lambda/Pdfx/PdfResponse.php index 55ef98a..3a0e88a 100644 --- a/src/Lambda/Pdfx/PdfResponse.php +++ b/src/Lambda/Pdfx/PdfResponse.php @@ -7,11 +7,9 @@ class PdfResponse { - /** @var ResponseInterface */ - protected $origin; + protected ResponseInterface $origin; - /** @var mixed */ - protected $parsed; + protected mixed $parsed = null; public function __construct(ResponseInterface $origin) { @@ -28,10 +26,7 @@ public function getStatusCode(): int return $this->origin->getStatusCode(); } - /** - * @return mixed - */ - public function getData() + public function getData(): mixed { return $this->getParsedBody(); } @@ -41,10 +36,7 @@ public function save(string $filename): void file_put_contents($filename, $this->getData()); } - /** - * @return mixed - */ - protected function getParsedBody() + protected function getParsedBody(): mixed { if ($this->parsed === null) { $body = $this->origin->getBody(); diff --git a/src/Lambda/Pdfx/PdfService.php b/src/Lambda/Pdfx/PdfService.php index c29e48c..4b23102 100644 --- a/src/Lambda/Pdfx/PdfService.php +++ b/src/Lambda/Pdfx/PdfService.php @@ -8,8 +8,7 @@ class PdfService { - /** @var ClientInterface */ - protected $client; + protected ClientInterface $client; public function __construct(ClientInterface $client) { diff --git a/src/Lambda/Pdfx/PdfxClient.php b/src/Lambda/Pdfx/PdfxClient.php index 8fb0ae5..db962ac 100644 --- a/src/Lambda/Pdfx/PdfxClient.php +++ b/src/Lambda/Pdfx/PdfxClient.php @@ -7,8 +7,7 @@ class PdfxClient { - /** @var ClientInterface */ - protected $client; + protected ClientInterface $client; public function __construct(ClientInterface $client) { diff --git a/tests/.coveralls.yml b/tests/.coveralls.yml deleted file mode 100644 index 403f48b..0000000 --- a/tests/.coveralls.yml +++ /dev/null @@ -1,4 +0,0 @@ -# for php-coveralls -service_name: github-actions -coverage_clover: coverage.xml -json_path: coverage.json \ No newline at end of file diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index f0d3402..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Folders - recursive -*.expected -*.actual - -# Folders -/tmp - -# Files -/*.log -/*.html diff --git a/tests/cases/E2E/Lambda/Pdfx/PdfService.phpt b/tests/Cases/E2E/Lambda/Pdfx/PdfService.phpt similarity index 55% rename from tests/cases/E2E/Lambda/Pdfx/PdfService.phpt rename to tests/Cases/E2E/Lambda/Pdfx/PdfService.phpt index d168c1c..a1d381d 100644 --- a/tests/cases/E2E/Lambda/Pdfx/PdfService.phpt +++ b/tests/Cases/E2E/Lambda/Pdfx/PdfService.phpt @@ -2,8 +2,9 @@ namespace Tests\Cases\E2E\Lambda\Pdfx; +use Contributte\Tester\Environment; +use Contributte\Tester\Toolkit; use JuicyFx\Juicy\JuicyFx; -use Ninjify\Nunjuck\Toolkit; use Tester\Assert; require_once __DIR__ . '/../../../../bootstrap.php'; @@ -14,9 +15,9 @@ Toolkit::test(function (): void { Assert::equal(200, $response->getStatusCode()); - Assert::false(file_exists(TEMP_DIR . '/pdf-url.pdf')); - $response->save(TEMP_DIR . '/pdf-url.pdf'); - Assert::true(file_exists(TEMP_DIR . '/pdf-url.pdf')); + Assert::false(file_exists(Environment::getTestDir() . '/pdf-url.pdf')); + $response->save(Environment::getTestDir() . '/pdf-url.pdf'); + Assert::true(file_exists(Environment::getTestDir() . '/pdf-url.pdf')); }); Toolkit::test(function (): void { @@ -25,9 +26,9 @@ Toolkit::test(function (): void { Assert::equal(200, $response->getStatusCode()); - Assert::false(file_exists(TEMP_DIR . '/pdf-raw.pdf')); - $response->save(TEMP_DIR . '/pdf-raw.pdf'); - Assert::true(file_exists(TEMP_DIR . '/pdf-raw.pdf')); + Assert::false(file_exists(Environment::getTestDir() . '/pdf-raw.pdf')); + $response->save(Environment::getTestDir() . '/pdf-raw.pdf'); + Assert::true(file_exists(Environment::getTestDir() . '/pdf-raw.pdf')); }); Toolkit::test(function (): void { @@ -38,9 +39,9 @@ Toolkit::test(function (): void { Assert::equal(200, $response->getStatusCode()); - Assert::false(file_exists(TEMP_DIR . '/pdf-json.pdf')); - $response->save(TEMP_DIR . '/pdf-json.pdf'); - Assert::true(file_exists(TEMP_DIR . '/pdf-json.pdf')); + Assert::false(file_exists(Environment::getTestDir() . '/pdf-json.pdf')); + $response->save(Environment::getTestDir() . '/pdf-json.pdf'); + Assert::true(file_exists(Environment::getTestDir() . '/pdf-json.pdf')); }); Toolkit::test(function (): void { @@ -57,7 +58,7 @@ Toolkit::test(function (): void { Assert::equal(200, $response->getStatusCode()); - Assert::false(file_exists(TEMP_DIR . '/pdf-json-full.pdf')); - $response->save(TEMP_DIR . '/pdf-json-full.pdf'); - Assert::true(file_exists(TEMP_DIR . '/pdf-json-full.pdf')); + Assert::false(file_exists(Environment::getTestDir() . '/pdf-json-full.pdf')); + $response->save(Environment::getTestDir() . '/pdf-json-full.pdf'); + Assert::true(file_exists(Environment::getTestDir() . '/pdf-json-full.pdf')); }); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f9ee4bc..86c92a0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,13 +1,10 @@