-
-
Notifications
You must be signed in to change notification settings - Fork 492
Running in GitHub Actions
Lucas Bustamante edited this page Jun 24, 2022
·
23 revisions
You can run PHPCS automatically whenever a new commit is pushed to your repository using GitHub actions, just follow these simple steps:
- Considering that your plugin is hosted in GitHub.
- Considering you are already running PHPCS locally using
./vendor/bin/phpcs
. - Considering that you have a
.phpcs.xml.dist
file in your root directory. (If not, tweak the last line of the workflow below) - Create the folder
.github/workflows/phpcs
on the root of your GitHub repository - Create the file
.github/workflows/phpcs.yml
- Place this content inside of it:
name: PHPCS checks
on:
push
jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Composer install
run: composer install
- name: Run PHPCS checks
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}:/app" \
--workdir "/app" \
php:7-cli \
bash -c "php -d memory_limit=1G /app/vendor/bin/phpcs -s --standard=/app/.phpcs.xml.dist"
Expected folder structure for this to work:
./plugin-foo
├── .github
│ └── workflows
│ └── phpcs.yml
├── vendor
│ └── bin
│ └── phpcs
├── .phpcs.xml.dist # PHPCS configuration file
└── composer.lock # Composer.lock file with PHPCS
Here's an example of a repository using this setup: https://github.com/Luc45/phpcs-ci-example