diff --git a/.gitattributes b/.gitattributes index 6efd058..f5e312c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,6 @@ +/.github export-ignore /tests export-ignore .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore -build.xml export-ignore phpunit.xml.dist export-ignore phpcs.xml.dist export-ignore diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml new file mode 100644 index 0000000..290d1a6 --- /dev/null +++ b/.github/workflows/cs.yml @@ -0,0 +1,35 @@ +name: CS + +on: + push: + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + checkcs: + name: 'Check code style' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: cs2pr + + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies + uses: "ramsey/composer-install@v1" + + - name: Check PHP code style + continue-on-error: true + run: vendor/bin/phpcs --report-full --report-checkstyle=./checkstyle.xml + + - name: Show PHPCS results in PR + run: cs2pr ./checkstyle.xml --graceful-warnings diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3f1e4bb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: Test + +on: + pull_request: + push: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + experimental: [false] + + include: + - php: '8.1' + experimental: true + + name: "Test on PHP ${{ matrix.php }}" + continue-on-error: ${{ matrix.experimental }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: cs2pr + + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies - normal + if: ${{ matrix.experimental == false }} + uses: "ramsey/composer-install@v1" + + # For the PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow it. + - name: Install Composer dependencies - with ignore platform + if: ${{ matrix.experimental == true }} + uses: "ramsey/composer-install@v1" + with: + composer-options: --ignore-platform-reqs + + - name: Lint + run: composer phplint -- --checkstyle | cs2pr + + - name: Run unit tests + run: composer phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1c00b45..0000000 --- a/.travis.yml +++ /dev/null @@ -1,48 +0,0 @@ -os: linux -dist: xenial -language: php - -addons: - apt: - packages: - - ant - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - - "nightly" - -jobs: - fast_finish: true - include: - - php: 5.4 - dist: trusty - - php: 5.5 - dist: trusty - allow_failures: - # Allow failures for unstable builds. - - php: "nightly" - -cache: - directories: - - vendor - - $HOME/.composer/cache - -before_script: - - | - if [[ $TRAVIS_PHP_VERSION != "nightly" && $TRAVIS_PHP_VERSION != "8.0" ]]; then - composer install --no-suggest --no-interaction - else - # Ignore platform requirements to allow PHPUnit to install on PHP 8. - composer install --no-suggest --no-interaction --ignore-platform-reqs - fi - -script: - - ant phplint - - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.4" ]]; then ant phpcs;fi - - ant phpunit diff --git a/README.md b/README.md index 5cc7691..cb18fe5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ PHP Console Color ================= [![Downloads this Month](https://img.shields.io/packagist/dm/php-parallel-lint/php-console-color.svg)](https://packagist.org/packages/php-parallel-lint/php-console-color) -[![Build Status](https://travis-ci.org/php-parallel-lint/PHP-Console-Color.svg?branch=master)](https://travis-ci.org/php-parallel-lint/PHP-Console-Color) +[![CS](https://github.com/php-parallel-lint/PHP-Console-Color/actions/workflows/cs.yml/badge.svg)](https://github.com/php-parallel-lint/PHP-Console-Color/actions/workflows/cs.yml) +[![Test](https://github.com/php-parallel-lint/PHP-Console-Color/actions/workflows/test.yml/badge.svg)](https://github.com/php-parallel-lint/PHP-Console-Color/actions/workflows/test.yml) [![License](https://poser.pugx.org/php-parallel-lint/php-console-color/license.svg)](https://packagist.org/packages/php-parallel-lint/php-console-color) Simple library for creating colored console ouput. diff --git a/build.xml b/build.xml deleted file mode 100644 index a0bd8ab..0000000 --- a/build.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/composer.json b/composer.json index 3e3cdd2..cab122f 100644 --- a/composer.json +++ b/composer.json @@ -26,5 +26,40 @@ }, "replace": { "jakub-onderka/php-console-color": "*" + }, + "scripts" : { + "phplint": [ + "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git" + ], + "vardumpcheck": [ + "@php ./vendor/php-parallel-lint/php-var-dump-check/var-dump-check . --exclude vendor --exclude .git" + ], + "phpcs": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report-full --report-checkstyle=./build/logs/checkstyle.xml" + ], + "fixcs": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf" + ], + "phpunit": [ + "@php ./vendor/phpunit/phpunit/phpunit --no-coverage" + ], + "coverage": [ + "@php ./vendor/phpunit/phpunit/phpunit" + ], + "build": [ + "@phplint", + "@vardumpcheck", + "@phpcs", + "@phpunit" + ] + }, + "scripts-descriptions": { + "phplint": "Check syntax errors in PHP files", + "vardumpcheck": "Check PHP files for forgotten variable dumps", + "phpcs": "Check PHP code style", + "fixcs": "Auto-fix PHP code style", + "phpunit": "PHP unit", + "coverage": "PHP unit with code coverage", + "build": "Run all checks" } }