Skip to content

Instantly share code, notes, and snippets.

@mnapoli mnapoli/README.md

Last active Jul 16, 2020
Embed
What would you like to do?
PrettyCI migration

This page will help you run continuous integration for PHP CodeSniffer and PHP-CS-Fixer using GitHub Actions.

To setup GitHub Actions in your repository, create a .github/workflows/ci.yml file in your repository and commit it.

The content of that file depends on the tool you want to run, please read the examples below.

Note: the examples below are provided to get you started easily, it is possible you may need to adjust them to fit your project.

php-cs-fixer

If you do not use a custom standard, you can start from this example:

name: php-cs-fixer
on: [push, pull_request]

jobs:
  php-cs-fixer:
    name: php-cs-fixer
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: PHP-CS-Fixer
        uses: OskarStark/php-cs-fixer-ga@2.16.1.2
        with:
          args: --diff --dry-run

If you need to install a custom standard via composer.json:

name: php-cs-fixer
on: [push, pull_request]

jobs:
  php-cs-fixer:
    name: php-cs-fixer
    runs-on: ubuntu-latest
    steps:
      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: '7.4'
          extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
      - uses: actions/checkout@master
      - run: composer install --prefer-dist
      - run: ./vendor/bin/php-cs-fixer fix --diff --dry-run

PHP CodeSniffer

Make sure squizlabs/php_codesniffer is required in composer.json, then use this template:

name: phpcs
on: [push, pull_request]

jobs:
  phpcs:
    name: phpcs
    runs-on: ubuntu-latest
    steps:
      - name: Setup PHP
        uses: shivammathur/setup-php@v1
        with:
          php-version: '7.4'
          extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
      - uses: actions/checkout@master
      - run: composer install --prefer-dist
      - run: ./vendor/bin/phpcs src

What about .prettyci.composer.json

The .prettyci.composer.json can be removed after you move to GitHub Actions.

Remember to remove your project in the PrettyCI dashboard, else PrettyCI will still process it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.