diff --git a/.gitattributes b/.gitattributes index 9f34fee..98ab92e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,6 +15,7 @@ /phpunit.xml export-ignore /phpunit.xml.dist export-ignore /.cache export-ignore +/.github export-ignore /images export-ignore /tests export-ignore diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml new file mode 100644 index 0000000..6da4040 --- /dev/null +++ b/.github/workflows/cs.yml @@ -0,0 +1,44 @@ +name: CS + +on: + # Run on all pushes and on all pull requests. + 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 + + # Validate the composer.json file. + # @link https://getcomposer.org/doc/03-cli.md#validate + - name: Validate Composer installation + run: composer validate --no-check-all + + # 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 + + # Check the codestyle of the files within YoastCS. + # The results of the CS check will be shown inline in the PR via the CS2PR tool. + # @link https://github.com/staabm/annotate-pull-request-from-checkstyle/ + - name: Check PHP code style + continue-on-error: true + run: composer check-cs -- --report-full --report-checkstyle=./phpcs-report.xml + + - name: Show PHPCS results in PR + run: cs2pr ./phpcs-report.xml diff --git a/.travis.yml b/.travis.yml index 4d0b53e..1d0ea01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ cache: php: - 8.0 +- 7.4 - 7.3 - 7.2 - 7.1 @@ -19,8 +20,6 @@ php: jobs: fast_finish: true include: - - php: 7.4 - env: PHPCS=1 - php: 7.0 dist: xenial - php: 5.6 @@ -50,5 +49,3 @@ script: - echo $TRAVIS_PHP_VERSION - composer lint - ./vendor/bin/phpunit -- if [[ "$TRAVIS_PHP_VERSION" == "5.3" || "$TRAVIS_PHP_VERSION" == "7.4" ]]; then composer validate --no-check-all; fi -- if [[ $PHPCS == "1" ]]; then composer check-cs; fi diff --git a/README.md b/README.md index 1ed37be..792de82 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![CS](https://github.com/Yoast/whip/actions/workflows/cs.yml/badge.svg)](https://github.com/Yoast/whip/actions/workflows/cs.yml) + # whip A WordPress package to nudge users to upgrade their software versions (starting with PHP)