From 0f53519bfdf906682f968ffef5cebfa1a29c673a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20L=C3=A9v=C3=AAque?= Date: Fri, 18 Feb 2022 14:50:49 +0100 Subject: [PATCH] migrate travis to circle-ci --- .github/workflows/ci.yaml | 110 +++++++++++++++++++++++++++++++++++ .gitignore | 3 +- .php_cs => .php-cs-fixer.php | 6 +- .travis.yml | 71 ---------------------- Makefile | 5 ++ Model/FormTree.php | 21 ++++++- composer.json | 11 ++-- phpunit.xml.dist | 50 ++++++---------- 8 files changed, 162 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/ci.yaml rename .php_cs => .php-cs-fixer.php (89%) delete mode 100644 .travis.yml create mode 100644 Makefile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..fa3624f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,110 @@ +name: CI + +on: + workflow_dispatch: ~ + push: + branches: + - master + pull_request: ~ + +jobs: + + lint: + name: Lint + runs-on: 'ubuntu-latest' + timeout-minutes: 5 + + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + + - name: 'Setup PHP' + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: 'Install dependencies' + run: make php-cs-fixer.phar + + - name: 'Check style' + run: ./php-cs-fixer.phar fix --dry-run --no-interaction --diff + + test: + name: ${{ matrix.name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 8 + continue-on-error: ${{ matrix.allow-failure == 1 }} + + strategy: + fail-fast: false + matrix: + include: + # Lowest deps + - name: 'Test lowest deps [Linux, PHP 7.4]' + os: 'ubuntu-latest' + php: '7.4' + symfony: '4.4.*@dev' + composer-flags: '--prefer-lowest' + allow-unstable: true + + # Most recent versions + - name: 'Test Symfony 5.4 [Linux, PHP 8.0]' + os: 'ubuntu-latest' + php: '8.0' + symfony: '5.4.*@dev' + allow-unstable: true + + - name: 'Test Symfony 6.0 [Linux, PHP 8.1]' + os: 'ubuntu-latest' + php: '8.1' + symfony: '6.0.*@dev' + allow-unstable: true + + # Bleeding edge (unreleased dev versions where failures are allowed) + - name: 'Test next Symfony [Linux, PHP 8.1] (allowed failure)' + os: 'ubuntu-latest' + php: '8.1' + symfony: '6.1.*@dev' + composer-flags: '--ignore-platform-req php' + allow-unstable: true + allow-failure: true + + steps: + - name: 'Set git to use LF' + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: 'Checkout' + uses: actions/checkout@v2 + + - name: 'Setup PHP' + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: pdo_sqlite + coverage: pcov + tools: 'composer:v2,flex' + + - name: 'Get composer cache directory' + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: 'Cache dependencies' + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-${{ hashFiles('**/composer.json') }}-flags-${{ matrix.composer-flags }} + restore-keys: ${{ runner.os }}-composer- + + - name: 'Allow unstable packages' + run: composer config minimum-stability dev + if: ${{ matrix.allow-unstable }} + + - name: 'Install dependencies' + run: composer update --prefer-dist ${{ matrix.composer-flags }} --ansi + env: + SYMFONY_REQUIRE: "${{ matrix.symfony }}" + + - name: 'Run PHPUnit tests' + run: vendor/bin/simple-phpunit --testdox --verbose ${{ matrix.code-coverage && '--coverage-text --coverage-clover build/logs/clover.xml' }} diff --git a/.gitignore b/.gitignore index 5e10c17..308533e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor composer.lock -.php_cs.cache +.php-cs-fixer.cache +php-cs-fixer.phar .phpunit.result.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 89% rename from .php_cs rename to .php-cs-fixer.php index c6f4680..0015d37 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -14,14 +14,14 @@ ]) ; -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setUsingCache(true) ->setFinder($finder) ->setRules([ '@Symfony' => true, 'php_unit_namespaced' => true, - 'psr0' => false, + 'psr_autoloading' => true, 'concat_space' => ['spacing' => 'one'], 'phpdoc_summary' => false, 'phpdoc_annotation_without_dot' => false, @@ -30,7 +30,7 @@ 'ordered_imports' => true, 'simplified_null_return' => false, 'header_comment' => ['header' => $header], - 'yoda_style' => null, + 'yoda_style' => [], 'native_function_invocation' => ['include' => ['@compiler_optimized']], 'single_line_throw' => false, ]) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 38226a2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,71 +0,0 @@ -sudo: false -language: php - -branches: - only: - - master - -env: - global: - - CHECK_CODE_STYLE="no" - - COMPOSER_FLAGS="" - - COMPOSER_MEMORY_LIMIT=-1 - - ENABLE_CODE_COVERAGE="no" - - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" - - SYMFONY_VERSION="" - -matrix: - fast_finish: true - include: - - php: 7.1 - env: SYMFONY_VERSION="3.0.*" - - php: 7.2 - env: SYMFONY_VERSION="3.0.*" - - php: 7.1 - env: SYMFONY_VERSION="4.0.*" - - php: 7.2 - env: SYMFONY_VERSION="4.0.*" - - php: 7.3 - env: SYMFONY_VERSION="4.4.*" - - php: 7.3 - env: SYMFONY_VERSION="5.0.*" - - php: 7.4 - env: SYMFONY_VERSION="5.0.*" - - php: 7.4 - env: SYMFONY_VERSION="5.1.*" - - php: 8.0 - env: SYMFONY_VERSION="5.2.*" - # bleeding edge (unreleased dev versions where failures are allowed): - - php: nightly # PHP 8 - env: SYMFONY_VERSION="5.3.*" - allow_failures: - - env: SYMFONY_VERSION="5.3.*" - -cache: - directories: - - $HOME/.composer/cache - - $HOME/symfony-bridge/.phpunit - -before_install: - - if [[ "$ENABLE_CODE_COVERAGE" != "yes" ]]; then phpenv config-rm xdebug.ini || true; fi; - - if [[ "$SYMFONY_VERSION" != "" ]]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; - - if [[ "$CHECK_CODE_STYLE" != "yes" ]]; then composer remove "friendsofphp/php-cs-fixer" --no-update --no-interaction --dev; fi; - -install: - - | - # Set composer's platform to php 7.4 if we're on php 8 & use dev version of phpunit-bridge (which ignores platform reqs) - echo $TRAVIS_PHP_VERSION - if [[ $TRAVIS_PHP_VERSION = 'nightly' ]]; then - echo "Set composer's platform to php 7.4" - composer config platform.php 7.4.99 - composer require "symfony/phpunit-bridge:5.1.x-dev" --no-update --no-interaction --dev - fi - - composer update --prefer-dist --no-interaction --optimize-autoloader --prefer-stable --no-progress $COMPOSER_FLAGS - - if [[ "$ENABLE_CODE_COVERAGE" == "yes" ]]; then composer require --dev satooshi/php-coveralls; fi; - -script: - - if [[ "$ENABLE_CODE_COVERAGE" == "yes" ]]; then vendor/bin/simple-phpunit --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/simple-phpunit; fi; - - if [[ "$CHECK_CODE_STYLE" == "yes" ]]; then PHP_CS_FIXER_FUTURE_MODE=1 vendor/bin/php-cs-fixer fix --config=.php_cs --dry-run --no-interaction --diff; fi; - -after_success: - - if [[ "$ENABLE_CODE_COVERAGE" == "yes" ]]; then php vendor/bin/coveralls -v; fi; diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de9113b --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +PHP_CS_FIXER_VERSION=v3.4.0 + +php-cs-fixer.phar: + wget --no-verbose https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/${PHP_CS_FIXER_VERSION}/php-cs-fixer.phar + chmod +x php-cs-fixer.phar diff --git a/Model/FormTree.php b/Model/FormTree.php index 1b607a8..e9835bd 100644 --- a/Model/FormTree.php +++ b/Model/FormTree.php @@ -67,7 +67,10 @@ public function addChild(FormTreeNode $node) /** * Set the loop back to the start + * + * @return void */ + #[\ReturnTypeWillChange] public function rewind() { $this->position = 0; @@ -75,10 +78,8 @@ public function rewind() /** * Return the length of the tree - * - * @return int */ - public function count() + public function count(): int { return \count($this->nodes); } @@ -88,6 +89,7 @@ public function count() * * @return FormTreeNode */ + #[\ReturnTypeWillChange] public function current() { return $this->nodes[$this->position]; @@ -98,6 +100,7 @@ public function current() * * @return int */ + #[\ReturnTypeWillChange] public function key() { return $this->position; @@ -105,7 +108,10 @@ public function key() /** * Increment current position + * + * @return void */ + #[\ReturnTypeWillChange] public function next() { ++$this->position; @@ -116,6 +122,7 @@ public function next() * * @return int */ + #[\ReturnTypeWillChange] public function valid() { return $this->offsetExists($this->position); @@ -128,6 +135,7 @@ public function valid() * * @return bool */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->nodes[$offset]); @@ -140,6 +148,7 @@ public function offsetExists($offset) * * @return FormTreeNode */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->offsetExists($offset) ? $this->nodes[$offset] : null; @@ -150,7 +159,10 @@ public function offsetGet($offset) * * @param mixed $offset * @param mixed $value + * + * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { /* Not implemented: Use addParent and addChild methods */ @@ -160,7 +172,10 @@ public function offsetSet($offset, $value) * Unset node at the given offset * * @param mixed $offset + * + * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { /* Not implemented: FormTree nodes should not be unsetable */ diff --git a/composer.json b/composer.json index 7e14af9..d0a1655 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,13 @@ } ], "require": { - "php": ">=7.1.0", - "symfony/framework-bundle": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/form": "~2.8|~3.0|~4.0|~5.0|~6.0", - "symfony/property-access": "~2.8|~3.0|~4.0|~5.0|~6.0" + "php": ">=7.4.0", + "symfony/framework-bundle": "~4.4|~5.0|~6.0", + "symfony/form": "~2.8|~3.0|~4.4|~5.0|~6.0", + "symfony/property-access": "~4.4|~5.0|~6.0" }, "require-dev": { - "symfony/phpunit-bridge": "^5.0", - "friendsofphp/php-cs-fixer": "^2.16" + "symfony/phpunit-bridge": "^5.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 721153f..ce23af4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,33 +1,21 @@ - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - + + + + ./ + + + ./Resources + ./Tests + ./vendor + + + + + + + + ./Tests/ + +