Skip to content

Instantly share code, notes, and snippets.

@mnapoli
Last active October 22, 2021 17:13
Show Gist options
  • Save mnapoli/7eb3ab685c1faf0ece00c8d94e951da0 to your computer and use it in GitHub Desktop.
Save mnapoli/7eb3ab685c1faf0ece00c8d94e951da0 to your computer and use it in GitHub Desktop.
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/[email protected]
        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