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..3d847f55 --- /dev/null +++ b/.github/workflows/integrationtest.yml @@ -0,0 +1,180 @@ +--- +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 }} + ini-values: error_reporting=E_ALL, display_errors=On + 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/.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: 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/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml new file mode 100644 index 00000000..f6155942 --- /dev/null +++ b/.github/workflows/quicktest.yml @@ -0,0 +1,85 @@ +--- +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 }} + ini-values: error_reporting=E_ALL, display_errors=On + 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/.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 deleted file mode 100644 index e67d104a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,169 +0,0 @@ ---- -language: php - -cache: - directories: - - "${HOME}/.composer/cache" - - "${HOME}/.npm/" - -env: - global: - - PATH="${HOME}/bin:${PATH}" - -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 - - 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 - - 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 PHPCS=1 - - 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 - - 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 - - php: 7.1 - env: PHPCS_VERSION="2.0.0" - - php: 7.0 - env: PHPCS_VERSION="3.4.2" LINT=1 - - php: 7.0 - env: PHPCS_VERSION="2.2.0" - - php: 5.6 - env: PHPCS_VERSION="3.0.2" LINT=1 - - 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 - - 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" LINT=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="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" LINT=1 - - 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: - - | - 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 - - | - if [[ "$PHPCS" == "1" ]]; then - # Do the actual code style check for this repo. - ./vendor/bin/phpcs - elif [[ ${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 - - | - if [[ "$SECURITY" == "1" ]]; then - ./vendor/bin/security-checker -n security:check - fi diff --git a/README.md b/README.md index 8d4dcf48..50faf21a 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] @@ -255,8 +255,8 @@ 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 [v0.4]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.4.0 diff --git a/composer.json b/composer.json index 7d637a17..f30f6c42 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,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 +45,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" ] } }