Skip to content

Commit

Permalink
Merge pull request #6 from MontealegreLuis/next
Browse files Browse the repository at this point in the history
Support for nullable types
  • Loading branch information
MontealegreLuis authored Jun 2, 2021
2 parents 2b0e696 + 7ce1a8a commit 0701c60
Show file tree
Hide file tree
Showing 167 changed files with 1,570 additions and 725 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on: [push, pull_request]

jobs:
ci:
runs-on: ubuntu-latest

steps:
- name: "Checkout project"
uses: actions/checkout@v1

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.1"
extensions: imagick
ini-values: memory_limit=-1
coverage: xdebug
tools: composer:v1

- name: "Install dependencies with composer"
run: |
sudo apt-get install graphviz
composer install --no-interaction --no-progress --no-suggest
- name: "Code quality checks"
run: "make check"

- name: "Run tests with coverage"
run: "vendor/bin/phpunit --exclude-group=snapshot --coverage-text --coverage-clover=coverage.clover"

- name: "Send code coverage to Scrutinizer"
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
31 changes: 31 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Documentation

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-18.04
steps:
- name: "Checkout documentation"
uses: actions/checkout@v1

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.1"
ini-values: memory_limit=-1
tools: composer:v1

- name: "Generate documentation"
run: |
composer global require couscous/couscous:1.7.3
couscous generate
- name: "Deploy documentation to Github Pages"
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./.couscous/generated
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ vendor
composer.lock
build
coverage.clover
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
.couscous
phuml.phar
phuml.phar.pubkey
Expand Down
33 changes: 33 additions & 0 deletions .php-cs-fixer-tests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* PHP version 7.1
*
* This source file is subject to the license that is bundled with this package in the file LICENSE.
*/

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/tests'])
->exclude('resources');

$config = new PhpCsFixer\Config();

return $config->setRules([
'@PSR2' => true,
'visibility_required' => false,
'no_unused_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'single_blank_line_before_namespace' => true,
'ordered_imports' => true,
'single_quote' => true,
'trailing_comma_in_multiline' => true,
'concat_space' => ['spacing' => 'one'],
'no_superfluous_phpdoc_tags' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'array_indentation' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'no_whitespace_in_blank_line' => true,
'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one']],
])
->setFinder($finder);
31 changes: 31 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* PHP version 7.1
*
* This source file is subject to the license that is bundled with this package in the file LICENSE.
*/

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/src']);

$config = new PhpCsFixer\Config();

return $config->setRules([
'@PSR2' => true,
'no_unused_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'single_blank_line_before_namespace' => true,
'ordered_imports' => true,
'single_quote' => true,
'trailing_comma_in_multiline' => true,
'concat_space' => ['spacing' => 'one'],
'no_superfluous_phpdoc_tags' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'array_indentation' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'no_whitespace_in_blank_line' => true,
'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one']],
])
->setFinder($finder);
20 changes: 20 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
build:
nodes:
php-scrutinizer-run:
project_setup:
override: true
tests:
override:
- echo 'No need to run tests'
dependencies:
override:
-
command: 'echo "No need to install dependencies"'
environment:
php:
version: 7.1.30
tests:
override: true
project_setup:
override: true

tools:
external_code_coverage:
timeout: 600
Expand Down
53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

59 changes: 34 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ By participating in this project you agree to abide by its terms.

* Fork the project.
* Make your bug fix or feature addition.
* Add tests for it. This is important so we don't break it in a future version unintentionally.
* Add tests for it. This is important, so we don't break it in a future version unintentionally.
* Send a pull request. Bonus points for topic branches.

Pull requests for bug fixes must be based on the current stable branch whereas pull requests for new features must be based on the `master` branch.
Expand All @@ -18,70 +18,79 @@ Pull requests for bug fixes must be based on the current stable branch whereas p

This project follows the coding standards proposed in [PSR-2][psr2]

You can use [PHP CS fixer][cs-fixer] to (re)format your sourcecode for compliance with this project's coding guidelines:

Run the following command to install the fixer.

```bash
$ composer global require friendsofphp/php-cs-fixer
```

Run the following command if you modified either production or tests.
Run the following command if you modified either production code or tests.

```bash
$ make fix
make format
```

[Make][make] will run the fixer in both folders `src` and `tests`.
[Make][make] will run [PHP CS fixer][cs-fixer] in both folders `src` and `tests`.

## Using phUML from a Git checkout

The following commands can be used to perform the initial checkout of phUML:

```bash
$ git clone git://github.com/MontealegreLuis/phuml.git

$ cd phuml
git clone git://github.com/MontealegreLuis/phuml.git
cd phuml
```

Retrieve phUML's dependencies using [Composer][composer]:

```bash
$ composer install
composer install
```

## Running phUML's test suite

There's a group of tests that verify that the generated class diagrams did not change.
Since there's a slight difference in the output between operating systems.
There's a slight difference in the output between operating systems.
It is recommended to run the whole test suite using the provided [Docker][docker] container.
In order to run the container you'll also need to have [Docker Compose][docker-compose] installed.
The container mimics the environment in [Travis][travis].
Please make sure the tests pass in the container so you can be sure they will pass in Travis too.
The container mimics the environment in Github Actions.
Please make sure the tests pass in the container, so you can be sure they will pass in Github Actions too.

You can run the tests as follows:

```
$ make test
```bash
make test
```

`make` will run PHPUnit with the same options it runs in Travis inside the Docker container.
`make` will run PHPUnit with the same options it runs in Github Actions inside the Docker container.

You can alternatively run the test suite without this group of tests in your local environment.

```
$ vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover --exclude-group=snapshot
```bash
vendor/bin/phpunit --exclude-group=snapshot
```

You will need [XDebug][xdebug] installed to be able to generate the code coverage report.

```bash
make coverage
```

## Running the commands from the container

If you want to get the same output as in the screenshots shown in the documentation, use the Docker container in this repository.

Use the following `make` commands to create the files using the Docker container

```
$ make diagram ARGS="src example.png -p neato"
$ make stats ARGS="src example.gv"
$ make stats ARGS="src statistics.txt"
```

With these commands you can pass the options and arguments via the `ARGS` variable

## Contributing to the documentation

The documentation of this package is generated by [Couscous][couscous].
You can install Couscous globally with the following commands.

```
$ curl -OS http://couscous.io/couscous.phar
$ curl -OS https://couscous.io/couscous.phar
$ chmod +x couscous.phar
$ sudo mv couscous.phar /usr/local/bin/couscous
```
Expand Down
42 changes: 27 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
FROM ubuntu:trusty

RUN apt-get update -y
RUN apt-get install -y software-properties-common python-software-properties
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get update -y
RUN apt-get install -y graphviz
RUN apt-get install -y pkg-config
RUN apt-get -y install libmagickwand-dev imagemagick php7.1 php7.1-dev php7.1-xml php7.1-xdebug
RUN yes | pecl install imagick
RUN echo "extension=imagick.so" > /etc/php/7.1/mods-available/imagick.ini
RUN ln -s /etc/php/7.1/mods-available/imagick.ini /etc/php/7.1/cli/conf.d/20-imagick.ini
RUN mkdir -p /usr/src/phuml

WORKDIR /usr/src/phuml
FROM composer:1.10 AS composer

ADD composer.* ./
ADD src/ src

RUN composer global require hirak/prestissimo --no-plugins --no-scripts
RUN composer install --optimize-autoloader --prefer-dist --no-progress --no-interaction --ignore-platform-reqs

FROM php:7.1.30-cli-alpine AS phuml
MAINTAINER Luis Montealegre <[email protected]>

RUN apk add --update --no-cache autoconf g++ pkgconfig imagemagick imagemagick-dev make ttf-freefont graphviz \
&& printf "\n" | pecl install imagick \
&& echo "extension=imagick.so" >> /usr/local/etc/php/php.ini

WORKDIR /app

ADD bin/phuml* bin/
ADD src/ src

ENV PATH="/app/bin:${PATH}"

COPY --from=composer /app/vendor/ ./vendor

WORKDIR /code

ENTRYPOINT ["phuml"]
Loading

0 comments on commit 0701c60

Please sign in to comment.