From 13f76d97fa168d5717a47f459d23b407bf3d628c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 23:48:12 +0200 Subject: [PATCH 1/3] Composer/Ant: move the build scripts to the Composer configuration As this is a PHP project and the build steps are relatively simple, it will make it more intuitive for contributors to use Composer scripts to run CI checks, than to have to install Ant for this. This commit creates the same build/CI scripts as were previously available via Ant in the Composer configuration file. Notes: - The scripts are set up to respect the PHP version used by Composer (instead of a system default). - The scripts are set up to work equally well on Linux/Windows/Mac. - The only two differences are: - The `mkdir` and file deletions won't automatically be done anymore. Generally speaking, the `mkdir` should only need to be run once anyway and the file deletes should not be necessary as the log files will just be overwritten by the tools, so I deemed this an acceptable trade-off. - The `colors` argument won't be set anymore. For most tools, this means, the tool will default to automatically determining whether the CLI used supports colourized output. As the determination of this in most tools has become pretty good, I, again, deemed this an acceptable trade-off. --- .gitattributes | 1 - build.xml | 84 -------------------------------------------------- composer.json | 35 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 85 deletions(-) delete mode 100644 build.xml diff --git a/.gitattributes b/.gitattributes index 6efd058..c9bd78d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,5 @@ .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/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" } } From a57d911ac7539a309e771b06b6bfebee6b34ef01 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Mar 2021 23:51:52 +0200 Subject: [PATCH 2/3] CI: switch to GitHub Actions - step 1: code style sniffing This commit: * Adds a GH Actions workflow for the code style CI check which was previously run on Travis. * Removes that part of the `.travis.yml` configuration. * Updates the `.gitattributes` file. * Adds a separate badge for the CS workflow to the README. --- .gitattributes | 1 + .github/workflows/cs.yml | 35 +++++++++++++++++++++++++++++++++++ .travis.yml | 1 - README.md | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cs.yml diff --git a/.gitattributes b/.gitattributes index c9bd78d..d58de37 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ +/.github export-ignore /tests export-ignore .gitattributes export-ignore .gitignore 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/.travis.yml b/.travis.yml index 1c00b45..852ac68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,5 +44,4 @@ before_script: 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..800380c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ 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) +[![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) [![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) [![License](https://poser.pugx.org/php-parallel-lint/php-console-color/license.svg)](https://packagist.org/packages/php-parallel-lint/php-console-color) From 3b956f6a417d65fe0904c888097f722b4d34c1bf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 29 Mar 2021 00:00:22 +0200 Subject: [PATCH 3/3] CI: switch to GitHub Actions - step 2: linting and tests This commit: * Adds a GH Actions workflow for the PHP lint and unit test CI checks which were previously run on Travis. * Removes the, now redundant, `.travis.yml` configuration. * Updates the `.gitattributes` file. * Updates the "Build Status" badge in the Readme to use the results from the GH `Test` Actions runs. --- .gitattributes | 1 - .github/workflows/test.yml | 53 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 47 --------------------------------- README.md | 2 +- 4 files changed, 54 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index d58de37..f5e312c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,5 @@ /tests export-ignore .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore phpunit.xml.dist export-ignore phpcs.xml.dist export-ignore 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 852ac68..0000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +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 - - ant phpunit diff --git a/README.md b/README.md index 800380c..cb18fe5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ 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) [![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) -[![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) +[![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.