From e1ad47ee9eae13ab2d453e58ea0205c33a6be306 Mon Sep 17 00:00:00 2001 From: Julien BIANCHI Date: Thu, 23 Jul 2020 22:26:42 +0200 Subject: [PATCH] chore: Add github workflows (#48) --- .github/workflows/Deploy.yml | 30 ++++++++++ .github/workflows/Test.yml | 43 ++++++++++++++ .php_cs | 11 ++-- .travis.yml | 40 ------------- Makefile | 6 +- README.md | 2 - composer.json | 10 ++-- composer.lock | 110 ++++++++++++++++++----------------- src/functions.php | 5 +- 9 files changed, 148 insertions(+), 109 deletions(-) create mode 100644 .github/workflows/Deploy.yml create mode 100644 .github/workflows/Test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml new file mode 100644 index 0000000..bd1a9ba --- /dev/null +++ b/.github/workflows/Deploy.yml @@ -0,0 +1,30 @@ +name: Test + +on: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-node-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Build and push Docker images + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: pmsipilot/docker-compose-viz + tag_with_ref: true diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml new file mode 100644 index 0000000..772f2ee --- /dev/null +++ b/.github/workflows/Test.yml @@ -0,0 +1,43 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Validate composer.json + run: composer validate --ansi --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-node-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Unit tests + run: composer run ut + + - name: Coding style + run: composer run cst + + - name: Build and push Docker images + uses: docker/build-push-action@v1 + with: + push: false diff --git a/.php_cs b/.php_cs index ed09307..b92f2ea 100644 --- a/.php_cs +++ b/.php_cs @@ -1,15 +1,18 @@ in(__DIR__.DIRECTORY_SEPARATOR.'src') ->in(__DIR__.DIRECTORY_SEPARATOR.'spec') ; -return CS\Config::create() +return (new PhpCsFixer\Config()) ->setRules([ + '@PSR2' => true, '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, ]) ->setFinder($finder) ; diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4fa831b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: php - -sudo: required - -services: - - docker - -php: - - 7.2 - - 7.3 - - 7.4 - - nightly - -env: - global: - # DOCKER_EMAIL - - secure: JAbpFtQJovMT1IqHJmSlVI3xQpLUoqDlbYXUgExK99dH7+GH78Rd6CgjCo5fDAw5KW4zBoTJut7BWv+qdF1j9qpUEXlxB6dEwKdLHCCM8M9p+BddkaZUWF9kG+4pC1h6AeDeWi7Q77TzrOX7VAP1UubFOPItRNayF99zCJH6ioh8qnHNi2XHedIagMW4PGLp6HmTuyhzdF6RVEXcCos2fpkx5wzcjALb/ffN8A0dqtfELRvs6bjaQZ1ktmNjd3fSnQOtGO14VOei8E58e4roZNdDHMoIxzeqaM+bphsTZvHne4DAZEn3wU2iguzXLZMCAgF336Inu+t2Rjv4UDLcPeppMrYA+02Ww0kbCXcIQx4Og0Un54SY5qdIHZtnTXA+SAFr+5r+T80p29Tlp9cUfxaHWFynDEEDWx7minAATweSQU50ipPnAkge1WY/ADSN1EARqM2GYVQYLvddIaTSIbnq37MnlncWL+jkcQ0cL83xidYd7JnQ7/gZJf9MzeZzMVXrY+2VYL1WOrv1uwmVi30bpQss1D7IVVt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G3LMhCl1sQjo3JKBxPsalQi78dShDUHcazAE68T7M1FjAZCJYia902FMDWiIuujLamq+NpDgEKB3aLCLwF/o3j8z3ekPrk2v9Zokz+t36cQ2BmPpwqFfhvPdUv9tj9bi7Qv2R4NKreX8TWB8KB5afSVWiKfufWV5hp5KfwEmcLBc/hQdjRIwzDqVPK/fyy/GJ5fT4X5kz+YYLQEFxeWPtxL+OpQUXx2P5iDhx5qz173lO4h1WX4vEQ3p4aFbfnNREUDPGYsMJo6flm5Azq8F0qh065sxPldKunr9H4fAXrFzqMJnTepReEGPNJRn35TLl08RI7GTp0hKxlaycsu+c2Qz0/GcKbODWf5w24d/pxrOMM9KmJpDZTBm9bWiZlRbbZm1OnK0PiaRi9ft44Em5NYTFVvuWL2M2tIyGObI3kquKTkANvrSuPTofJ0JawXg2YBKOH8=" - -matrix: - allow_failures: - - php: nightly - -script: - - make test - -deploy: - - provider: script - script: ci/deploy.sh - on: - php: 7.4 - all_branches: master - - provider: script - script: ci/deploy.sh - on: - php: 7.4 - tags: true diff --git a/Makefile b/Makefile index e75f6b6..43e5d69 100644 --- a/Makefile +++ b/Makefile @@ -12,13 +12,13 @@ docker: docker.lock test: vendor unit cs unit: vendor - $(PHP) bin/kahlan --pattern='*.php' --reporter=verbose --persistent=false --cc=true + $(COMPOSER) run ut cs: - $(PHP) bin/php-cs-fixer fix --dry-run + $(COMPOSER) run cst fix-cs: - $(PHP) bin/php-cs-fixer fix + $(COMPOSER) run cs clean: rm -rf vendor/ diff --git a/README.md b/README.md index 488d518..66a4347 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # `docker-compose-viz` -[![Build Status](https://img.shields.io/travis/pmsipilot/docker-compose-viz/master.svg?style=flat-square)](https://travis-ci.org/pmsipilot/docker-compose-viz) -[![StyleCI](https://styleci.io/repos/65026022/shield)](https://styleci.io/repos/65026022) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/pmsipilot/docker-compose-viz.svg)](http://isitmaintained.com/project/pmsipilot/docker-compose-viz "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/pmsipilot/docker-compose-viz.svg)](http://isitmaintained.com/project/pmsipilot/docker-compose-viz "Percentage of issues still open") [![Docker Stars](https://img.shields.io/docker/stars/pmsipilot/docker-compose-viz.svg?style=flat)](https://hub.docker.com/r/pmsipilot/docker-compose-viz/) diff --git a/composer.json b/composer.json index dc4dae5..7f5a992 100644 --- a/composer.json +++ b/composer.json @@ -9,8 +9,8 @@ "graphp/graphviz": "^0.2" }, "require-dev": { - "crysalead/kahlan": "^2.5.4", - "friendsofphp/php-cs-fixer": "^2" + "friendsofphp/php-cs-fixer": "^2", + "kahlan/kahlan": "^4.7" }, "license": "MIT", "authors": [ @@ -25,7 +25,9 @@ "PMSIpilot\\DockerComposeViz\\": "src/" } }, - "config": { - "bin-dir": "bin/" + "scripts": { + "cs": "php-cs-fixer fix", + "cst": "php-cs-fixer fix --dry-run", + "ut": "kahlan --grep='*.php' --reporter=verbose --persistent=false" } } diff --git a/composer.lock b/composer.lock index c2a23f3..3f1ad57 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b969fd3f88d63984295c01f8c964a703", + "content-hash": "883183cc51537213776e61c66e969e5a", "packages": [ { "name": "clue/graph", @@ -626,58 +626,6 @@ ], "time": "2020-06-04T11:16:35+00:00" }, - { - "name": "crysalead/kahlan", - "version": "2.5.8", - "source": { - "type": "git", - "url": "https://github.com/kahlan/kahlan.git", - "reference": "4fad70f5a81698fe6cae725b21bb08c4aa677788" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kahlan/kahlan/zipball/4fad70f5a81698fe6cae725b21bb08c4aa677788", - "reference": "4fad70f5a81698fe6cae725b21bb08c4aa677788", - "shasum": "" - }, - "require": { - "php": ">=5.4" - }, - "bin": [ - "bin/kahlan" - ], - "type": "library", - "autoload": { - "psr-4": { - "Kahlan\\": "src/" - }, - "files": [ - "src/init.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "CrysaLEAD" - } - ], - "description": "Behavior-Driven Development (BDD) library.", - "keywords": [ - "BDD", - "Behavior-Driven Development", - "Monkey Patching", - "TDD", - "mock", - "stub", - "testing", - "unit test" - ], - "abandoned": "kahlan/kahlan", - "time": "2016-09-29T01:40:20+00:00" - }, { "name": "doctrine/annotations", "version": "1.10.3", @@ -900,6 +848,60 @@ "description": "A tool to automatically fix PHP code style", "time": "2020-06-27T23:57:46+00:00" }, + { + "name": "kahlan/kahlan", + "version": "4.7.5", + "source": { + "type": "git", + "url": "https://github.com/kahlan/kahlan.git", + "reference": "c529ef24201053ba76d3c8c3531acd76b629ce87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kahlan/kahlan/zipball/c529ef24201053ba76d3c8c3531acd76b629ce87", + "reference": "c529ef24201053ba76d3c8c3531acd76b629ce87", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.4" + }, + "bin": [ + "bin/kahlan" + ], + "type": "library", + "autoload": { + "psr-4": { + "Kahlan\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "CrysaLEAD" + } + ], + "description": "The PHP Test Framework for Freedom, Truth and Justice.", + "keywords": [ + "BDD", + "Behavior-Driven Development", + "Monkey Patching", + "TDD", + "mock", + "stub", + "testing", + "unit test" + ], + "time": "2020-04-25T21:27:19+00:00" + }, { "name": "paragonie/random_compat", "version": "v9.99.99", @@ -1718,7 +1720,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": [], - "prefer-stable": true, + "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "^7.2" diff --git a/src/functions.php b/src/functions.php index c721bab..3de7e11 100644 --- a/src/functions.php +++ b/src/functions.php @@ -226,7 +226,8 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr if (false === ((bool) ($flags & WITHOUT_NETWORKS))) { foreach ($networks as $network => $definition) { addNetwork( - $graph, 'net: '.$network, + $graph, + 'net: '.$network, isset($definition['external']) && true === $definition['external'] ? 'external_network' : 'network' ); } @@ -237,7 +238,7 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr if (isset($definition['extends'])) { if (isset($definition['extends']['file'])) { - $configuration = readConfiguration(dirname($path) . DIRECTORY_SEPARATOR . $definition['extends']['file']); + $configuration = readConfiguration(dirname($path).DIRECTORY_SEPARATOR.$definition['extends']['file']); $extendedServices = fetchServices($configuration); $extendedVolumes = fetchVolumes($configuration); $extendedNetworks = fetchVolumes($configuration);