diff --git a/.github/workflows/codesniffer.yml b/.github/workflows/codesniffer.yml new file mode 100644 index 0000000..dfc76ff --- /dev/null +++ b/.github/workflows/codesniffer.yml @@ -0,0 +1,15 @@ +name: "Codesniffer" + +on: + pull_request: + + push: + branches: ["*"] + + schedule: + - cron: "0 8 * * 1" + +jobs: + codesniffer: + name: "Codesniffer" + uses: contributte/.github/.github/workflows/codesniffer.yml@v1 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..efda94a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,17 @@ +name: "Coverage" + +on: + pull_request: + + push: + branches: ["*"] + + schedule: + - cron: "0 8 * * 1" + +jobs: + coverage: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester-coverage.yml@v1 + with: + php: "7.4" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index f7acb31..0000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,285 +0,0 @@ -name: "build" - -on: - pull_request: - paths-ignore: - - ".docs/**" - push: - branches: - - "*" - schedule: - - cron: "0 8 * * 1" # At 08:00 on Monday - -env: - extensions: "json" - cache-version: "1" - composer-version: "v2" - composer-install: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable" - coverage: "none" - -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 }}, cs2pr" - coverage: "${{ env.coverage }}" - - - 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 }}" - coverage: "${{ env.coverage }}" - - - 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 }}" - coverage: "${{ env.coverage }}" - - - 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: "Tests" - run: "make tests" - - - name: "Upload test output" - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: output - path: tests/**/output - - 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 }}" - coverage: "${{ env.coverage }}" - - - 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: "Upload test output" - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: output - path: tests/**/output - - - 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..43545cf --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,15 @@ +name: "PHPStan" + +on: + pull_request: + + push: + branches: ["*"] + + schedule: + - cron: "0 8 * * 1" + +jobs: + phpstan: + name: "PHPStan" + uses: contributte/.github/.github/workflows/phpstan.yml@v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..4e40cae --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,42 @@ +name: "Nette Tester" + +on: + pull_request: + + push: + branches: ["*"] + + schedule: + - cron: "0 8 * * 1" + +jobs: + test81: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + with: + php: "8.1" + + test80: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + with: + php: "8.0" + + test74: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + with: + php: "7.4" + + test73: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + with: + php: "7.3" + + test72: + name: "Nette Tester" + uses: contributte/.github/.github/workflows/nette-tester.yml@v1 + with: + php: "7.2" + composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" diff --git a/.gitignore b/.gitignore index b1b6f4d..9f0e148 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ # Tests /temp +/coverage.html /coverage.xml diff --git a/Makefile b/Makefile index 60ce194..6388967 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: install qa cs csf phpstan tests coverage-clover coverage-html +.PHONY: install qa cs csf phpstan tests coverage install: composer update @@ -7,7 +7,7 @@ qa: phpstan cs cs: ifdef GITHUB_ACTION - vendor/bin/codesniffer -q --report=checkstyle src tests | cs2pr + vendor/bin/codesniffer -q --report=checkstyle src tests | cs2pr else vendor/bin/codesniffer src tests endif @@ -16,13 +16,14 @@ csf: vendor/bin/codefixer src tests phpstan: - vendor/bin/phpstan analyse -l max -c phpstan.neon src + vendor/bin/phpstan analyse -c phpstan.neon 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 +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/composer.json b/composer.json index 403212d..e000e2b 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ "symfony/console": "^4.2.9|^5.0.0|^6.0.0" }, "require-dev": { - "nette/http": "~3.0.1", + "nette/http": "^3.0.1", "ninjify/nunjuck": "^0.4", - "ninjify/qa": "^0.12", - "phpstan/phpstan": "^1.0", + "ninjify/qa": "^v0.13.0", + "phpstan/phpstan": "^1.8.11", "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-nette": "^1.0", - "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-nette": "^1.1.0", + "phpstan/phpstan-strict-rules": "^1.4.4", "symfony/event-dispatcher": "^4.3 || ^5.0 || ^6.0" }, "autoload": { @@ -44,7 +44,11 @@ "minimum-stability": "dev", "prefer-stable": true, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "extra": { "branch-alias": { diff --git a/phpstan.neon b/phpstan.neon index 5a078a0..f4567fb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,5 +5,8 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon parameters: + level: 9 + paths: + - src ignoreErrors: - - '#^Parameter \#1 \$function of function call_user_func expects callable\(\): mixed, array\{string\|null, .+\} given\.$#' + - '#^Parameter \#1 \$callback of function call_user_func expects callable\(\): mixed, array\{string\|null, .+\} given\.$#'