Skip to content

Commit

Permalink
Update ci pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapio committed Feb 2, 2021
1 parent a19fa87 commit f8bd740
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 129 deletions.
217 changes: 99 additions & 118 deletions .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
Expand All @@ -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:
Expand All @@ -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
13 changes: 8 additions & 5 deletions Makefile
Expand Up @@ -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

1 change: 1 addition & 0 deletions phive.xml
Expand Up @@ -2,4 +2,5 @@
<phive xmlns="https://phar.io/phive">
<phar name="php-coveralls/php-coveralls" version="^2.2.0" installed="2.2.0" location="./tools/php-coveralls" copy="true"/>
<phar name="scrutinizer-ci/ocular" version="^1.6.0" installed="1.6.0" location="./tools/ocular" copy="true" force-accept-unsigned="true"/>
<phar name="psalm" version="^4.4.1" installed="4.4.1" location="./tools/psalm" copy="true"/>
</phive>
2 changes: 1 addition & 1 deletion phpstan.neon
Expand Up @@ -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\.#'
11 changes: 7 additions & 4 deletions psalm.xml
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config file:///composer/vendor/vimeo/psalm/config.xsd"
resolveFromConfigFile="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"
errorLevel="1"
>
<projectFiles>
<directory name="src" />
Expand All @@ -14,5 +15,7 @@

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<MissingDependency errorLevel="info" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/phpDocumentor/PHPStan/MethodReflectionExtension.php
Expand Up @@ -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();
Expand Down

0 comments on commit f8bd740

Please sign in to comment.