From d9cb363dca11b0b38cf865b1c8a373de496216e0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 14:07:09 +0200 Subject: [PATCH 1/8] Travis: remove steps already moved to GH Actions Various CI steps were previously already moved to GH Actions via PR 96. This removes those parts of the Travis script. --- .travis.yml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index e67d104a..1062627c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: php cache: directories: - "${HOME}/.composer/cache" - - "${HOME}/.npm/" env: global: @@ -12,18 +11,6 @@ env: jobs: include: - - php: 7.3 - name: Linting - stage: lint - before_install: - - npm set loglevel error - - npm set progress false - install: - - npm install -g jsonlint - script: - - find . -type f -name "*.json" -print0 | xargs -0 -n1 jsonlint -q - - composer validate - - stage: test php: 8.0 env: PHPCS_VERSION="dev-master" LINT=1 @@ -36,7 +23,7 @@ jobs: # Lowest PHPCS version on which PHP 7.4 is supported. env: PHPCS_VERSION="3.5.0" - php: 7.3 - env: SECURITY=1 PHPCS_VERSION="3.5.3" LINT=1 PHPCS=1 + env: SECURITY=1 PHPCS_VERSION="3.5.3" LINT=1 - php: 7.3 # Lowest PHPCS version on which PHP 7.3 is supported. env: PHPCS_VERSION="3.3.1" @@ -147,10 +134,7 @@ script: - composer install-codestandards - ./vendor/bin/phpcs -i - | - if [[ "$PHPCS" == "1" ]]; then - # Do the actual code style check for this repo. - ./vendor/bin/phpcs - elif [[ ${PHPCS_VERSION:0:3} < "2.3" ]]; then + if [[ ${PHPCS_VERSION:0:3} < "2.3" ]]; then # Test that an external standard has been registered correctly by running it against the codebase on PHPCS < 2.3. ./vendor/bin/phpcs -ps ./src/ \ --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" \ From 35f6f5cabea98c27de3f53259cd226ad3727d8b0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 14:15:24 +0200 Subject: [PATCH 2/8] GH Actions/linting: allow for manually triggering a build Triggering a workflow for a branch manually is not supported by default in GH Actions, but has to be explicitly allowed. This is useful if, for instance, an external action script or composer dependency has broken. Once a fix is available, failing builds for open PRs can be retriggered manually instead of having to be re-pushed to retrigger the workflow. Ref: https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ --- .github/workflows/linting.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml index c40a2f87..2f5c3fda 100644 --- a/.github/workflows/linting.yaml +++ b/.github/workflows/linting.yaml @@ -5,6 +5,7 @@ name: Linting jobs on: - push - pull_request + - workflow_dispatch jobs: validate-composer: From 00a5252d55463a33b5c167bd054e4f83644b4c34 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 14:21:40 +0200 Subject: [PATCH 3/8] GH Actions: add phplint workflow This commit: * Adds a dependency to the PHP Parallel Lint tool to handle the PHP linting. As of PHP Parallel Lint 1.3.0, the tool also supports PHP 5.3, making a viable option. Ref: https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/tag/v1.3.0 * Adds a Composer script to run Parallel Lint with preset optimized CLI arguments, making it easy for devs to run the tooling locally. Note: this uses `@php path/to/tool` to force the script to run under the same PHP version as Composer is run under in a cross-platform compatible manner. * Adds a separate GH Actions workflow to lint the code against the highest and lowest supported PHP versions, as well as two arbitrary interim PHP versions. This workflow has `cs2pr` enabled, which means that any issues found will be shown inline in PRs. * Removes the linting step from the Travis script. --- .github/workflows/phplint.yml | 38 +++++++++++++++++++++++++++++++++++ .travis.yml | 26 +++++++++--------------- composer.json | 6 +++++- 3 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/phplint.yml diff --git a/.github/workflows/phplint.yml b/.github/workflows/phplint.yml new file mode 100644 index 00000000..12c8f850 --- /dev/null +++ b/.github/workflows/phplint.yml @@ -0,0 +1,38 @@ +--- +name: PHP Lint + +# yamllint disable-line rule:truthy +on: + - push + - pull_request + # Allow manually triggering the workflow. + - workflow_dispatch + +jobs: + phplint: + runs-on: ubuntu-latest + + strategy: + matrix: + php: ['5.3', '5.6', '7.2', 'latest'] + + name: "PHP Lint: PHP ${{ matrix.php }}" + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install 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 + uses: "ramsey/composer-install@v1" + + - name: Lint against parse errors + run: composer lint -- --checkstyle | cs2pr diff --git a/.travis.yml b/.travis.yml index 1062627c..1c92ae58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,41 +13,41 @@ jobs: include: - stage: test php: 8.0 - env: PHPCS_VERSION="dev-master" LINT=1 + env: PHPCS_VERSION="dev-master" - php: 8.0 # Lowest PHPCS version on which PHP 8.0 is supported. env: PHPCS_VERSION="3.5.7" - php: 7.4 - env: PHPCS_VERSION="dev-master" LINT=1 + env: PHPCS_VERSION="dev-master" - php: 7.4 # Lowest PHPCS version on which PHP 7.4 is supported. env: PHPCS_VERSION="3.5.0" - php: 7.3 - env: SECURITY=1 PHPCS_VERSION="3.5.3" LINT=1 + env: SECURITY=1 PHPCS_VERSION="3.5.3" - php: 7.3 # Lowest PHPCS version on which PHP 7.3 is supported. env: PHPCS_VERSION="3.3.1" - php: 7.2 - env: PHPCS_VERSION="3.2.3" LINT=1 + env: PHPCS_VERSION="3.2.3" - php: 7.2 # Lowest PHPCS version on which PHP 7.2 is supported. env: PHPCS_VERSION="2.9.2" - php: 7.1 - env: PHPCS_VERSION="3.1.1" LINT=1 + env: PHPCS_VERSION="3.1.1" - php: 7.1 env: PHPCS_VERSION="2.0.0" - php: 7.0 - env: PHPCS_VERSION="3.4.2" LINT=1 + env: PHPCS_VERSION="3.4.2" - php: 7.0 env: PHPCS_VERSION="2.2.0" - php: 5.6 - env: PHPCS_VERSION="3.0.2" LINT=1 + env: PHPCS_VERSION="3.0.2" - php: 5.6 env: PHPCS_VERSION="2.4.0" - php: 5.5 # As the latest Debian does not support PHP 5.5 anymore, we need to force using 'trusty'. dist: trusty - env: PHPCS_VERSION="dev-master" LINT=1 + env: PHPCS_VERSION="dev-master" - php: 5.5 # As the latest Debian does not support PHP 5.5 anymore, we need to force using 'trusty'. dist: trusty @@ -55,7 +55,7 @@ jobs: - php: 5.4 # As the latest Debian does not support PHP 5.4 anymore, we need to force using 'trusty'. dist: trusty - env: PHPCS_VERSION="3.5.3" LINT=1 + env: PHPCS_VERSION="3.5.3" - php: 5.4 # As the latest Debian does not support PHP 5.4 anymore, we need to force using 'trusty'. dist: trusty @@ -73,7 +73,7 @@ jobs: env: PHPCS_VERSION="4.0.x-dev as 3.9.99" - php: nightly - env: PHPCS_VERSION="dev-master" LINT=1 + env: PHPCS_VERSION="dev-master" allow_failures: # Allow failures for unstable builds. @@ -125,12 +125,6 @@ install: fi script: - - | - if [[ "$LINT" == "1" ]]; then - if find . -path ./vendor -prune -o -name "*.php" -exec php -l {} \; | grep "^[Parse error|Fatal error]"; then - exit 1 - fi - fi - composer install-codestandards - ./vendor/bin/phpcs -i - | diff --git a/composer.json b/composer.json index 7d637a17..1a94372c 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "require-dev": { "composer/composer": "*", "enlightn/security-checker": "^1.2", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "php-parallel-lint/php-parallel-lint": "^1.3" }, "minimum-stability": "dev", "prefer-stable": true, @@ -45,6 +46,9 @@ "scripts": { "install-codestandards": [ "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" + ], + "lint": [ + "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git" ] } } From f5906a72d5df70a7e3553fd4ac773af97c79c2b4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 14:47:38 +0200 Subject: [PATCH 4/8] GH Actions: add security-check workflow * Remove the `enlightn/security-checker` dependency which was added in 130 as it conflicts with the minimum PHP requirements of this project (PHP 5.6 vs PHP 5.3). Also see 131. * Adds a separate GH Actions workflow to check for insecure dependencies against the highest and lowest supported PHP versions using the `fabpot/local-php-security-checker` instead. Note: this workflow does a `composer install` as this package does not have a committed `composer.lock` file and we need the `lock` file to do the check on. Regarding the choice for this tool: - This tool will run independently of the PHP version used, making it more versatile. - It complies with most other criteria as set forth in 131 (not deprecated, lightweight, versioned, easy to install/update). - As for running it locally - either devs can download the tool and run it locally or they can use the tooling available to run GH actions locally, so IMO that part is covered too. * Removes the security-check step from the Travis script. Ref: https://github.com/fabpot/local-php-security-checker/releases/tag/v1.0.0 --- .github/workflows/securitycheck.yml | 42 +++++++++++++++++++++++++++++ .travis.yml | 6 +---- composer.json | 1 - 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/securitycheck.yml diff --git a/.github/workflows/securitycheck.yml b/.github/workflows/securitycheck.yml new file mode 100644 index 00000000..3800428e --- /dev/null +++ b/.github/workflows/securitycheck.yml @@ -0,0 +1,42 @@ +--- +name: Security check + +# yamllint disable-line rule:truthy +on: + - push + - pull_request + # Allow manually triggering the workflow. + - workflow_dispatch + +jobs: + security-check: + runs-on: ubuntu-latest + name: "Security check" + + strategy: + matrix: + php: ['5.3', 'latest'] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + # 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: Download security checker + run: wget -P . https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64 + + - name: Make security checker executable + run: chmod +x ./local-php-security-checker_1.0.0_linux_amd64 + + - name: Check against insecure dependencies + run: ./local-php-security-checker_1.0.0_linux_amd64 --path=composer.lock diff --git a/.travis.yml b/.travis.yml index 1c92ae58..67fcc3b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ jobs: # Lowest PHPCS version on which PHP 7.4 is supported. env: PHPCS_VERSION="3.5.0" - php: 7.3 - env: SECURITY=1 PHPCS_VERSION="3.5.3" + env: PHPCS_VERSION="3.5.3" - php: 7.3 # Lowest PHPCS version on which PHP 7.3 is supported. env: PHPCS_VERSION="3.3.1" @@ -141,7 +141,3 @@ script: --sniffs=PHPCompatibility.FunctionUse.RemovedFunctions \ --standard=PHPCompatibility fi - - | - if [[ "$SECURITY" == "1" ]]; then - ./vendor/bin/security-checker -n security:check - fi diff --git a/composer.json b/composer.json index 1a94372c..f30f6c42 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ }, "require-dev": { "composer/composer": "*", - "enlightn/security-checker": "^1.2", "phpcompatibility/php-compatibility": "^9.0", "php-parallel-lint/php-parallel-lint": "^1.3" }, From 4b106c78c6c4e3e21dbe212b90d4e22a48692e51 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 16:30:42 +0200 Subject: [PATCH 5/8] GH Actions: add integration test workflow This commit: * Adds a separate GH Actions workflow to run the "integration tests" as previously run on Travis. The script is largely the same as the original Travis script with only some minor tweaks. * Removes the Travis script file as all actions have now been moved to GH Actions. Notes: * This script is only run on pushes to `master` and on pull requests. For pushes to "feature branches" the next commit will add a slimmed down version of this script to conserve resources as this is a very extensive build. --- .gitattributes | 1 - .github/workflows/integrationtest.yml | 179 ++++++++++++++++++++++++++ .travis.yml | 143 -------------------- 3 files changed, 179 insertions(+), 144 deletions(-) create mode 100644 .github/workflows/integrationtest.yml delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 049130f7..5e43d025 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,6 @@ .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore .github export-ignore CONTRIBUTING.md export-ignore diff --git a/.github/workflows/integrationtest.yml b/.github/workflows/integrationtest.yml new file mode 100644 index 00000000..0a80ba63 --- /dev/null +++ b/.github/workflows/integrationtest.yml @@ -0,0 +1,179 @@ +--- +name: Integration Test + +on: + # Run on pushes to `master` and on all pull requests. + push: + branches: + - master + pull_request: + # 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'] + phpcs_version: ['dev-master'] + phpcompat: ['composer'] + experimental: [false] + + include: + # Ensure a "highest" PHP/PHPCS build combination for PHPCS 2.x is included. + - php: '5.3' + phpcs_version: '2.9.2' + phpcompat: 'composer' + experimental: false + + # Complement the matrix with build against the lowest supported PHPCS version + # for each PHP version. + - php: '8.0' + # Lowest PHPCS version on which PHP 8.0 is supported. + phpcs_version: '3.5.7' + phpcompat: 'composer' + experimental: false + - php: '7.4' + # Lowest PHPCS version on which PHP 7.4 is supported. + phpcs_version: '3.5.0' + phpcompat: 'composer' + experimental: false + - php: '7.3' + # Lowest PHPCS version on which PHP 7.3 is supported. + phpcs_version: '3.3.1' + phpcompat: 'composer' + experimental: false + - php: '7.2' + # Lowest PHPCS version on which PHP 7.2 is supported. + phpcs_version: '2.9.2' + phpcompat: 'composer' + experimental: false + - php: '7.1' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + experimental: false + - php: '7.0' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + experimental: false + - php: '5.6' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + experimental: false + - php: '5.5' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + experimental: false + - php: '5.4' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + experimental: false + - php: '5.3' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + experimental: false + + # Additional builds against arbitrary interim PHPCS versions. + - php: '7.3' + phpcs_version: '3.5.3' + phpcompat: 'composer' + experimental: false + - php: '7.2' + phpcs_version: '3.2.3' + phpcompat: 'composer' + experimental: false + - php: '7.1' + phpcs_version: '3.1.1' + phpcompat: 'composer' + experimental: false + - php: '7.0' + phpcs_version: '3.4.2' + phpcompat: 'composer' + experimental: false + - php: '7.0' + phpcs_version: '2.2.0' + phpcompat: '^8.0' + experimental: false + - php: '5.6' + phpcs_version: '3.0.2' + phpcompat: 'composer' + experimental: false + - php: '5.6' + phpcs_version: '2.4.0' + phpcompat: 'composer' + experimental: false + - php: '5.5' + phpcs_version: '2.6.1' + phpcompat: 'composer' + experimental: false + - php: '5.4' + phpcs_version: '3.5.3' + phpcompat: 'composer' + experimental: false + - php: '5.4' + phpcs_version: '2.8.1' + phpcompat: 'composer' + experimental: false + + # Experimental builds. These are allowed to fail. + - php: '8.1' + phpcs_version: 'dev-master' + phpcompat: 'composer' + experimental: true + + - php: '8.0' + phpcs_version: '4.0.x-dev as 3.9.99' + phpcompat: 'composer' + experimental: true + + name: "Integration test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}" + + continue-on-error: ${{ matrix.experimental }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: 'Composer: set PHPCS version for tests' + run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" + + # Install PHPCompatibility 7.x/8.x for PHPCS < 2.3. + - name: 'Composer: set PHPCompatibility version for tests (PHPCS < 2.3)' + if: ${{ matrix.phpcompat != 'composer' }} + run: composer require --dev --no-update --no-scripts phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" + + # 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" + with: + composer-options: --no-scripts --optimize-autoloader + + # Rename the PHPCompatibility directory as PHPCompatibility 7.x wasn't fully compatible with Composer yet. + - name: 'Rename the PHPCompatibility directory (PHPCS < 2.2)' + if: ${{ matrix.phpcompat == '^7.0' }} + run: mv ./vendor/phpcompatibility/php-compatibility ./vendor/phpcompatibility/PHPCompatibility + + - name: 'Install standards' + run: composer install-codestandards + + - name: 'Show installed standards' + run: vendor/bin/phpcs -i + + # Test that an external standard has been registered correctly by running it against the codebase on PHPCS < 2.3. + - name: 'Test the PHPCompatibility standard was installed succesfully (PHPCS < 2.3)' + if: ${{ matrix.phpcompat != 'composer' }} + run: ./vendor/bin/phpcs -ps ./src/ --standard=PHPCompatibility --sniffs=PHPCompatibility.PHP.DeprecatedFunctions --runtime-set testVersion ${{ matrix.php }} + + # Test that an external standard has been registered correctly by running it against the codebase. + - name: 'Test the PHPCompatibility standard was installed succesfully (PHPCS >= 2.3)' + if: ${{ matrix.phpcompat == 'composer' }} + run: ./vendor/bin/phpcs -ps ./src/ --standard=PHPCompatibility --sniffs=PHPCompatibility.FunctionUse.RemovedFunctions --runtime-set testVersion ${{ matrix.php }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 67fcc3b5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,143 +0,0 @@ ---- -language: php - -cache: - directories: - - "${HOME}/.composer/cache" - -env: - global: - - PATH="${HOME}/bin:${PATH}" - -jobs: - include: - - stage: test - php: 8.0 - env: PHPCS_VERSION="dev-master" - - php: 8.0 - # Lowest PHPCS version on which PHP 8.0 is supported. - env: PHPCS_VERSION="3.5.7" - - php: 7.4 - env: PHPCS_VERSION="dev-master" - - php: 7.4 - # Lowest PHPCS version on which PHP 7.4 is supported. - env: PHPCS_VERSION="3.5.0" - - php: 7.3 - env: PHPCS_VERSION="3.5.3" - - php: 7.3 - # Lowest PHPCS version on which PHP 7.3 is supported. - env: PHPCS_VERSION="3.3.1" - - php: 7.2 - env: PHPCS_VERSION="3.2.3" - - php: 7.2 - # Lowest PHPCS version on which PHP 7.2 is supported. - env: PHPCS_VERSION="2.9.2" - - php: 7.1 - env: PHPCS_VERSION="3.1.1" - - php: 7.1 - env: PHPCS_VERSION="2.0.0" - - php: 7.0 - env: PHPCS_VERSION="3.4.2" - - php: 7.0 - env: PHPCS_VERSION="2.2.0" - - php: 5.6 - env: PHPCS_VERSION="3.0.2" - - php: 5.6 - env: PHPCS_VERSION="2.4.0" - - php: 5.5 - # As the latest Debian does not support PHP 5.5 anymore, we need to force using 'trusty'. - dist: trusty - env: PHPCS_VERSION="dev-master" - - php: 5.5 - # As the latest Debian does not support PHP 5.5 anymore, we need to force using 'trusty'. - dist: trusty - env: PHPCS_VERSION="2.6.1" - - php: 5.4 - # As the latest Debian does not support PHP 5.4 anymore, we need to force using 'trusty'. - dist: trusty - env: PHPCS_VERSION="3.5.3" - - php: 5.4 - # As the latest Debian does not support PHP 5.4 anymore, we need to force using 'trusty'. - dist: trusty - env: PHPCS_VERSION="2.8.1" - - php: 5.3 - # As the latest Debian does not support PHP 5.3 anymore, we need to force using 'precise'. - dist: precise - env: PHPCS_VERSION="2.9.2" - - php: 5.3 - # As the latest Debian does not support PHP 5.3 anymore, we need to force using 'precise'. - dist: precise - env: PHPCS_VERSION="2.0.0" - - - php: 7.4 - env: PHPCS_VERSION="4.0.x-dev as 3.9.99" - - - php: nightly - env: PHPCS_VERSION="dev-master" - - allow_failures: - # Allow failures for unstable builds. - - php: "nightly" - - env: PHPCS_VERSION="4.0.x-dev as 3.9.99" - - fast_finish: true - -before_install: - # Speed up build time by disabling Xdebug. - phpenv config-rm xdebug.ini || echo 'No xdebug config.' - -install: - - composer require --no-update --no-suggest --no-scripts squizlabs/php_codesniffer:"${PHPCS_VERSION}" - - | - if [[ ${PHPCS_VERSION:0:3} < "2.2" ]]; then - # Install PHPCompatibility 7.x for PHPCS < 2.2. - composer require --no-update --no-suggest --no-scripts phpcompatibility/php-compatibility:"^7.0" - elif [[ ${PHPCS_VERSION:0:3} < "2.3" ]]; then - # Install PHPCompatibility 8.x for PHPCS 2.2 < 2.3. - composer require --no-update --no-suggest --no-scripts phpcompatibility/php-compatibility:"^8.0" - fi - - | - if [[ $TRAVIS_PHP_VERSION != "nightly" && $TRAVIS_PHP_VERSION != "8.0" ]]; then - travis_wait composer install \ - --no-interaction \ - --no-progress \ - --no-scripts \ - --no-suggest \ - --optimize-autoloader \ - --prefer-dist --verbose - else - composer require --no-update --no-suggest --no-scripts phpcompatibility/php-compatibility - travis_wait composer install \ - --ignore-platform-reqs \ - --no-dev \ - --no-interaction \ - --no-progress \ - --no-scripts \ - --no-suggest \ - --optimize-autoloader \ - --prefer-dist \ - --verbose - fi - - > - if [[ ${PHPCS_VERSION:0:3} < "2.2" ]]; then - # Rename the PHPCompatibility directory as PHPCompatibility 7.x wasn't fully compatible with Composer yet. - mv ./vendor/phpcompatibility/php-compatibility ./vendor/phpcompatibility/PHPCompatibility - fi - -script: - - composer install-codestandards - - ./vendor/bin/phpcs -i - - | - if [[ ${PHPCS_VERSION:0:3} < "2.3" ]]; then - # Test that an external standard has been registered correctly by running it against the codebase on PHPCS < 2.3. - ./vendor/bin/phpcs -ps ./src/ \ - --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" \ - --sniffs=PHPCompatibility.PHP.DeprecatedFunctions \ - --standard=PHPCompatibility - else - # Test that an external standard has been registered correctly by running it against the codebase. - ./vendor/bin/phpcs -ps ./src/ \ - --runtime-set testVersion "${TRAVIS_PHP_VERSION:0:3}" \ - --sniffs=PHPCompatibility.FunctionUse.RemovedFunctions \ - --standard=PHPCompatibility - fi From 6ac97a7e6138d0260870a3e3bbbf6814369ac0c2 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 16:26:31 +0200 Subject: [PATCH 6/8] GH Actions: add a quicktest workflow This commit: * Adds a separate GH Actions workflow to run the "integration tests" against a slimmed down matrix for pushes to "feature branches". The script part of this workflow is the same as the script in the integration test workflow. --- .github/workflows/quicktest.yml | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/quicktest.yml diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml new file mode 100644 index 00000000..5fc76c95 --- /dev/null +++ b/.github/workflows/quicktest.yml @@ -0,0 +1,84 @@ +--- +name: Quicktest + +on: + # Run on pushes to feature branches. + push: + branches-ignore: + - master + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + #### QUICK TEST STAGE #### + # This is a much quicker test which only runs the integration tests against a limited set of + # supported PHP/PHPCS combinations. + quicktest: + runs-on: ubuntu-latest + + strategy: + matrix: + include: + - php: 'latest' + phpcs_version: 'dev-master' + phpcompat: 'composer' + - php: '7.3' + phpcs_version: '2.9.2' + phpcompat: 'composer' + - php: '7.1' + phpcs_version: '3.3.1' + phpcompat: 'composer' + - php: '5.6' + phpcs_version: '2.6.0' + phpcompat: 'composer' + - php: '5.3' + phpcs_version: '2.0.0' + phpcompat: '^7.0' + + name: "Quick test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}" + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: 'Composer: set PHPCS version for tests' + run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" + + # Install PHPCompatibility 7.x/8.x for PHPCS < 2.3. + - name: 'Composer: set PHPCompatibility version for tests (PHPCS < 2.3)' + if: ${{ matrix.phpcompat != 'composer' }} + run: composer require --dev --no-update --no-scripts phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" + + # 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" + with: + composer-options: --no-scripts --optimize-autoloader + + # Rename the PHPCompatibility directory as PHPCompatibility 7.x wasn't fully compatible with Composer yet. + - name: 'Rename the PHPCompatibility directory (PHPCS < 2.2)' + if: ${{ matrix.phpcompat == '^7.0' }} + run: mv ./vendor/phpcompatibility/php-compatibility ./vendor/phpcompatibility/PHPCompatibility + + - name: 'Install standards' + run: composer install-codestandards + + - name: 'Show installed standards' + run: vendor/bin/phpcs -i + + # Test that an external standard has been registered correctly by running it against the codebase on PHPCS < 2.3. + - name: 'Test the PHPCompatibility standard was installed succesfully (PHPCS < 2.3)' + if: ${{ matrix.phpcompat != 'composer' }} + run: ./vendor/bin/phpcs -ps ./src/ --standard=PHPCompatibility --sniffs=PHPCompatibility.PHP.DeprecatedFunctions --runtime-set testVersion ${{ matrix.php }} + + # Test that an external standard has been registered correctly by running it against the codebase. + - name: 'Test the PHPCompatibility standard was installed succesfully (PHPCS >= 2.3)' + if: ${{ matrix.phpcompat == 'composer' }} + run: ./vendor/bin/phpcs -ps ./src/ --standard=PHPCompatibility --sniffs=PHPCompatibility.FunctionUse.RemovedFunctions --runtime-set testVersion ${{ matrix.php }} From 52d2c44f96268ee17a7b898797a1f5fc4c30617a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 13 Jun 2021 16:36:11 +0200 Subject: [PATCH 7/8] README: switch Travis badge to GH Actions I've chosen to only show a badge for the integration test workflow as that is the most important one after all. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2be42ed7..f90ea5da 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![Awesome][awesome-shield] [![License][license-shield]](LICENSE.md) -[![Travis][travis-shield]][travis] +[![Tests][ghactionstest-shield]][ghactions] [![Scrutinizer][scrutinizer-shield]][scrutinizer] [![Latest Version on Packagist][packagist-version-shield]][packagist-version] [![Packagist][packagist-shield]][packagist] @@ -245,7 +245,7 @@ THE SOFTWARE. [project-stage-shield]: https://img.shields.io/badge/Project%20Stage-Development-yellowgreen.svg [scrutinizer-shield]: https://img.shields.io/scrutinizer/g/dealerdirect/phpcodesniffer-composer-installer.svg [scrutinizer]: https://scrutinizer-ci.com/g/dealerdirect/phpcodesniffer-composer-installer/ -[travis-shield]: https://img.shields.io/travis/Dealerdirect/phpcodesniffer-composer-installer.svg -[travis]: https://travis-ci.org/Dealerdirect/phpcodesniffer-composer-installer +[ghactionstest-shield]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/actions/workflows/integrationtest.yml/badge.svg +[ghactions]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/actions/workflows/integrationtest.yml [tutorial]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial [using-composer-plugins]: https://getcomposer.org/doc/articles/plugins.md#using-plugins From 49a4e7b12a0ceb1b74bc493624f337a1c5464925 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 21 Jun 2021 21:56:30 +0200 Subject: [PATCH 8/8] GH Actions: set error reporting to E_ALL Turns out the default setting for `error_reporting` used by the SetupPHP action is `error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT` and `display_errors` is set to `Off`. For the purposes of CI, I'd recommend running with `E_ALL` and `display_errors=On` to ensure **all** PHP notices are shown. --- .github/workflows/integrationtest.yml | 1 + .github/workflows/quicktest.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/integrationtest.yml b/.github/workflows/integrationtest.yml index 0a80ba63..3d847f55 100644 --- a/.github/workflows/integrationtest.yml +++ b/.github/workflows/integrationtest.yml @@ -140,6 +140,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + ini-values: error_reporting=E_ALL, display_errors=On coverage: none - name: 'Composer: set PHPCS version for tests' diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 5fc76c95..f6155942 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -45,6 +45,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + ini-values: error_reporting=E_ALL, display_errors=On coverage: none - name: 'Composer: set PHPCS version for tests'