Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 49 additions & 172 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,175 +1,52 @@
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:
phpunit-with-coverage:
runs-on: ubuntu-latest
name: Unit tests
steps:
- 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@v2
with:
php-version: ${{ env.defaultPHPVersion }}
ini-values: memory_limit=2G, display_errors=On, error_reporting=-1
tools: phive

- 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

phpunit:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system:
- ubuntu-latest
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
needs:
- phpunit-with-coverage
steps:
- 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@v2
with:
php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, simplexml
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-
# https://docs.github.com/en/actions

- name: Install Composer dependencies
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
name: "Integrate"

- name: Run PHPUnit
run: php vendor/bin/phpunit

codestyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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: Code style check
uses: docker://phpdoc/phpcs-ga:latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: -d memory_limit=1024M

phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
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: ${{ 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: phpDocumentor/phpstan-ga@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: analyse src tests --configuration phpstan.neon

psalm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
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: ${{ 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
on: # yamllint disable-line rule:truthy
push:
branches:
- "master"
pull_request: null
schedule:
- cron: "0 14 * * 1"
# Allow manually triggering the workflow.
workflow_dispatch: true

- name: Psalm
run: vendor/bin/psalm.phar --output-format=github
jobs:
code-coverage:
name: "Code Coverage"
uses: "phpDocumentor/.github/.github/workflows/code-coverage.yml@main"
with:
composer-root-version: "1.x-dev"

coding-standards:
name: "Coding Standards"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
with:
composer-root-version: "1.x-dev"

dependency-analysis:
name: "Dependency analysis"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
with:
composer-root-version: "1.x-dev"

lint-root:
name: "Lint root"
uses: "phpDocumentor/.github/.github/workflows/lint.yml@main"
with:
composer-options: "--no-check-publish --ansi"

static-analysis:
name: "Static analysis"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
with:
php-extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, pcntl, posix"
composer-root-version: "1.x-dev"

unit-tests:
name: "Unit test"
uses: "phpDocumentor/.github/.github/workflows/[email protected]"
with:
composer-root-version: "1.x-dev"
upcoming-releases: true
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ setup: install-phive
phpcbf:
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf ${ARGS}


.PHONY: build-test-image
build-test-image:
docker build -t php-graphviz -f tests/Resources/Dockerfile tests/Resources

.PHONY: phpcs
phpcs:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s
phpcs: build-test-image
docker run -it --rm -v${CURDIR}:/data -w /data php-graphviz vendor/bin/phpcs

.PHONY: phpstan
phpstan:
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project phpdoc/phpstan-ga:latest analyse src tests --configuration phpstan.neon ${ARGS}
phpstan: build-test-image
docker run -it --rm -v${CURDIR}:/data -w /data php-graphviz ./vendor/phpstan/phpstan/phpstan analyse src ${ARGS}

.PHONY: psalm
psalm:
docker run -it --rm -v${CURDIR}:/data -w /data php:7.3 vendor/bin/psalm.phar
psalm: build-test-image
docker run -it --rm -v${CURDIR}:/data -w /data php-graphviz vendor/bin/psalm.phar

.PHONY: test
test:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.3 vendor/bin/phpunit
test: build-test-image
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php-graphviz ./vendor/bin/phpunit

.PHONY: pre-commit-test
pre-commit-test: phpcs phpstan psalm test
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,3 @@ GraphViz

GraphViz is a library meant for generating .dot files for GraphViz with a
fluent interface.


### PHPStan extension

This library contains a number of magic methods to set attributes on `Node`, `Graph` and `Edge`
this will result in errors when using the library with checks by PHPStan. For your convenience this
library provides an phpStan extension so your code can be checked correctly by phpstan.

```
includes:
- vendor/phpdocumentor/graphviz/extension.neon
```
25 changes: 15 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,35 @@
}
],
"require": {
"php": "^7.2 || ^8.0"
"php": "^8.2"
},
"autoload": {
"psr-4": {
"phpDocumentor\\GraphViz\\": "src/phpDocumentor/GraphViz",
"phpDocumentor\\GraphViz\\PHPStan\\": "./src/phpDocumentor/PHPStan"
"phpDocumentor\\GraphViz\\": "src/phpDocumentor/GraphViz"
}
},
"autoload-dev": {
"psr-4": {
"phpDocumentor\\GraphViz\\Test\\": "./tests/phpDocumentor/GraphViz/Test",
"phpDocumentor\\GraphViz\\PHPStan\\": "./tests/phpDocumentor/PHPStan"
"phpDocumentor\\GraphViz\\Test\\": "./tests/phpDocumentor/GraphViz/Test"
}
},
"require-dev": {
"phpunit/phpunit": "^8.2 || ^9.2",
"mockery/mockery": "^1.2",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^11.0",
"mockery/mockery": "@stable",
"phpstan/phpstan": "@stable",
"ext-simplexml": "*",
"psalm/phar": "^4.15 || ^5.0"
"psalm/phar": "@stable",
"squizlabs/php_codesniffer": "@stable",
"phpstan/phpstan-mockery": "@stable"
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-master": "3.x-dev"
}
},
"config": {
"allow-plugins": {
"ondrejmirtes/composer-attribute-collector": true
}
}
}
9 changes: 0 additions & 9 deletions extension.neon

This file was deleted.

3 changes: 0 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<file>tests</file>
<arg value="p"/>
<rule ref="PSR2" />
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment" />
</rule>

<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>tests/phpDocumentor/GraphViz/Test/GraphTest\.php</exclude-pattern>
Expand Down
8 changes: 2 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
includes:
- /composer/vendor/phpstan/phpstan-mockery/extension.neon
- ./extension.neon
- ./vendor/phpstan/phpstan-mockery/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\(\)\.#'
- '#Cannot cast mixed to string#'
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<testsuite name="Graphviz suite">
<directory>./tests/phpDocumentor/GraphViz</directory>
</testsuite>
<testsuite name="PHPStan suite">
<directory>./tests/phpDocumentor/PHPStan</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml" />
Expand Down
3 changes: 2 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
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"
Expand All @@ -22,5 +21,7 @@
<file name="src/phpDocumentor/GraphViz/Graph.php" />
</errorLevel>
</MixedArgumentTypeCoercion>
<PossiblyUnusedMethod errorLevel="suppress" />
<MissingOverrideAttribute errorLevel="suppress" />
</issueHandlers>
</psalm>
Loading