Task/composer required package installs update #1607
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHP Composer, Codesniffer, and Static Analysis | |
on: pull_request | |
jobs: | |
sniff: | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
matrix: | |
operating-system: [ ubuntu-latest ] | |
php-versions: [ '8.0' ] | |
env: | |
cache_version: 0 # increment to flush all caches | |
php_extensions: tokenizer, xmlwriter, simplexml | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Add GitHub oAuth | |
env: | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: composer config --global github-oauth.github.com $TOKEN | |
- name: Detect File Changes | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
list-files: shell | |
filters: | | |
wpcontent: | |
- added|modified: 'wp-content/plugins/core/**/*.php' | |
- added|modified: 'wp-content/themes/core/**/*.php' | |
- added|modified: 'wp-content/mu-plugins/**/*.php' | |
- name: Set up PHP extension cache | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
id: cache-php-extensions | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.php_extensions }} | |
key: ${{ matrix.operating-system }}-${{ env.cache_version }}-php-extensions-${{ matrix.php-versions }} | |
- name: Cache PHP extensions | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.cache-php-extensions.outputs.dir }} | |
key: ${{ steps.cache-php-extensions.outputs.key }} | |
restore-keys: ${{ steps.cache-php-extensions.outputs.key }} | |
- name: Set up PHP | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.php_extensions }} | |
coverage: none | |
env: | |
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Validate composer.json and composer.lock | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
run: composer validate | |
- name: Configure composer | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
run: echo "${{ secrets.COMPOSER_ENV }}" > .env | |
- name: Install composer dependencies | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
uses: ramsey/composer-install@v2 | |
with: | |
composer-options: "--prefer-dist --no-progress --optimize-autoloader" | |
- name: PHPCS | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
run: ./vendor/bin/phpcs --standard=./phpcs.xml.dist ${{ steps.filter.outputs.wpcontent_files }} | |
- name: Static Analysis | |
if: ${{ steps.filter.outputs.wpcontent == 'true' }} | |
run: ./vendor/bin/phpstan --memory-limit=-1 |