From f8bd74007ad8021fa24d80d60c42d9bfda980cf9 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Tue, 2 Feb 2021 21:21:35 +0100 Subject: [PATCH] Update ci pipeline --- .github/workflows/push.yml | 217 ++++++++---------- Makefile | 13 +- phive.xml | 1 + phpstan.neon | 2 +- psalm.xml | 11 +- .../PHPStan/MethodReflectionExtension.php | 2 +- 6 files changed, 117 insertions(+), 129 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 7fc10c9..fb92990 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,69 +1,44 @@ -on: push +on: + push: + branches: + - master + pull_request: name: Qa workflow +env: + extensions: mbstring, intl, iconv, libxml, dom, json, simplexml, zlib, fileinfo + key: cache-v1 # can be any string, change to clear the extension cache. + defaultPHPVersion: '7.3' jobs: - setup: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Restore/cache vendor folder - uses: actions/cache@v1 - with: - path: vendor - key: all-build-${{ hashFiles('**/composer.lock') }} - restore-keys: | - all-build-${{ hashFiles('**/composer.lock') }} - all-build- - - name: Restore/cache tools folder - uses: actions/cache@v1 - with: - path: tools - key: all-tools-${{ github.sha }} - restore-keys: | - all-tools-${{ github.sha }}- - all-tools- - - name: composer - uses: docker://composer - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - args: install --no-interaction --prefer-dist --optimize-autoloader - - name: Install phive - run: make install-phive - - name: Install PHAR dependencies - run: tools/phive.phar --no-progress install --copy --trust-gpg-keys 4AA394086372C20A,D2CCAC42F6295E7D,E82B2FB314E9906E,8E730BA25823D8B5 --force-accept-unsigned - phpunit-with-coverage: runs-on: ubuntu-latest name: Unit tests - needs: setup steps: - - uses: actions/checkout@master - - name: Restore/cache vendor folder - uses: actions/cache@v1 - with: - path: vendor - key: all-build-${{ hashFiles('**/composer.lock') }} - restore-keys: | - all-build-${{ hashFiles('**/composer.lock') }} - all-build- - - name: Restore/cache tools folder - uses: actions/cache@v1 - with: - path: tools - key: all-tools-${{ github.sha }} - restore-keys: | - all-tools-${{ github.sha }}- - all-tools- + - uses: actions/checkout@v2 + - name: Install graphviz run: sudo apt-get update && sudo apt-get install -y graphviz + - name: Setup PHP - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v2 with: - php-version: 7.2 - extension-csv: mbstring, simplexml - ini-values-csv: memory_limit=2G, display_errors=On, error_reporting=-1 - coverage: xdebug - pecl: false + php-version: ${{ env.defaultPHPVersion }} + ini-values: memory_limit=2G, display_errors=On, error_reporting=-1 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ hashFiles('**/composer.lock') }} + restore-keys: composer- + + - name: Install Composer dependencies + run: | + composer install --no-progress --prefer-dist --optimize-autoloader + - name: Run PHPUnit run: php vendor/bin/phpunit - name: Upload to Scrutinizer @@ -78,42 +53,39 @@ jobs: php-versions: ['7.2', '7.3', '7.4', '8.0'] name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }} needs: - - setup - phpunit-with-coverage steps: - - uses: actions/checkout@master - - name: Restore/cache vendor folder - uses: actions/cache@v1 - with: - path: vendor - key: all-build-${{ hashFiles('**/composer.lock') }} - restore-keys: | - all-build-${{ hashFiles('**/composer.lock') }} - all-build- - - name: Restore/cache tools folder - uses: actions/cache@v1 - with: - path: tools - key: all-tools-${{ github.sha }} - restore-keys: | - all-tools-${{ github.sha }}- - all-tools- + - uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@master + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} extension-csv: mbstring, simplexml - ini-values-csv: memory_limit=2G, display_errors=On, error_reporting=-1 - pecl: false + ini-values: memory_limit=2G, display_errors=On, error_reporting=-1 + tools: pecl + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ hashFiles('**/composer.lock') }} + restore-keys: composer- + + - name: Install Composer dependencies + run: | + composer install --no-progress --prefer-dist --optimize-autoloader + - name: Run PHPUnit - continue-on-error: true - run: php tools/phpunit + run: php vendor/bin/phpunit codestyle: runs-on: ubuntu-latest - needs: [setup, phpunit] steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2 - name: Restore/cache vendor folder uses: actions/cache@v1 with: @@ -139,54 +111,63 @@ jobs: phpstan: runs-on: ubuntu-latest - needs: [setup, phpunit] steps: - - uses: actions/checkout@master - - name: Restore/cache vendor folder - uses: actions/cache@v1 + - uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - path: vendor - key: all-build-${{ hashFiles('**/composer.lock') }} - restore-keys: | - all-build-${{ hashFiles('**/composer.lock') }} - all-build- - - name: Restore/cache tools folder - uses: actions/cache@v1 + php-version: ${{ env.defaultPHPVersion }} + ini-values: memory_limit=2G, display_errors=On, error_reporting=-1 + tools: pecl + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 with: - path: tools - key: all-tools-${{ github.sha }} - restore-keys: | - all-tools-${{ github.sha }}- - all-tools- + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ hashFiles('**/composer.lock') }} + restore-keys: composer- + + - name: Install Composer dependencies + run: | + composer install --no-progress --prefer-dist --optimize-autoloader + - name: PHPStan - uses: docker://phpdoc/phpstan-ga:0.12 + uses: phpDocumentor/phpstan-ga@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - args: analyse src tests --level max --configuration phpstan.neon + args: analyse src tests --configuration phpstan.neon psalm: runs-on: ubuntu-latest - needs: [setup, phpunit] steps: - - uses: actions/checkout@master - - name: Restore/cache vendor folder - uses: actions/cache@v1 + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - path: vendor - key: all-build-${{ hashFiles('**/composer.lock') }} - restore-keys: | - all-build-${{ hashFiles('**/composer.lock') }} - all-build- - - name: Restore/cache tools folder - uses: actions/cache@v1 + php-version: 7.3 + ini-values: memory_limit=2G, display_errors=On, error_reporting=-1 + tools: pecl, psalm + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v2 with: - path: tools - key: all-tools-${{ github.sha }} - restore-keys: | - all-tools-${{ github.sha }}- - all-tools- + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ hashFiles('**/composer.lock') }} + restore-keys: composer- + + - name: Install Composer dependencies + run: | + composer install --no-progress --prefer-dist --optimize-autoloader + - name: Psalm - uses: docker://mickaelandrieu/psalm-ga - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: psalm --output-format=github diff --git a/Makefile b/Makefile index df20505..f863fdf 100644 --- a/Makefile +++ b/Makefile @@ -10,23 +10,26 @@ install-phive: .PHONY: setup setup: install-phive docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phar-ga:latest php tools/phive.phar install --force-accept-unsigned +.PHONY: phpcbf +phpcbf: + docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf ${ARGS} .PHONY: phpcs phpcs: - docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M + docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s .PHONY: phpstan phpstan: - docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpstan-ga:0.12 analyse src tests --no-progress --level max --configuration phpstan.neon + docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src tests --configuration phpstan.neon ${ARGS} -.PHONY: psaml +.PHONY: psalm psalm: - docker run -it --rm -v${PWD}:/opt/project -w /opt/project mickaelandrieu/psalm-ga + docker run -it --rm -v${CURDIR}:/data -w /data php:7.3 ./tools/psalm .PHONY: test test: docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.2 vendor/bin/phpunit .PHONY: pre-commit-test -pre-commit-test: test phpcs phpstan psalm +pre-commit-test: phpcs phpstan psalm test diff --git a/phive.xml b/phive.xml index 0a51544..078a08d 100644 --- a/phive.xml +++ b/phive.xml @@ -2,4 +2,5 @@ + diff --git a/phpstan.neon b/phpstan.neon index fc6ffe5..b9e02dd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,10 +3,10 @@ includes: - ./extension.neon parameters: + level: max ignoreErrors: #We have some runtime protection that needs to be tested. Ignore these errors - '#Call to an undefined method phpDocumentor\\GraphViz\\Edge::someNonExcistingMethod\(\)\.#' - '#Call to an undefined method phpDocumentor\\GraphViz\\Graph::MyMethod\(\)\.#' - '#Call to an undefined method phpDocumentor\\GraphViz\\Graph::getNotExisting\(\)\.#' - '#Call to an undefined method phpDocumentor\\GraphViz\\Node::someNonExistingMethod\(\)\.#' - - '#Call to method PHPStan\\Mockery\\Type\\Expects::andReturn\(\) on a separate line has no effect\.#' diff --git a/psalm.xml b/psalm.xml index 9fedb8a..648b6d2 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,9 +1,10 @@ @@ -14,5 +15,7 @@ + + diff --git a/src/phpDocumentor/PHPStan/MethodReflectionExtension.php b/src/phpDocumentor/PHPStan/MethodReflectionExtension.php index 16a115a..149c4da 100644 --- a/src/phpDocumentor/PHPStan/MethodReflectionExtension.php +++ b/src/phpDocumentor/PHPStan/MethodReflectionExtension.php @@ -105,7 +105,7 @@ private function getAttributeInputType(string $ref) : Type } $type = $attributes[0]['type']; - $type = str_replace('xsd:', '', $type); + $type = str_replace('xsd:', '', (string) $type); switch ($type) { case 'boolean': return new BooleanType();