Skip to content

Merge pull request #867 from newfold-labs/dependabot/npm_and_yarn/dev… #1310

Merge pull request #867 from newfold-labs/dependabot/npm_and_yarn/dev…

Merge pull request #867 from newfold-labs/dependabot/npm_and_yarn/dev… #1310

Workflow file for this run

name: Lint
on:
push:
branches:
- 'main'
- 'develop'
paths:
- '**.php'
- 'package*.json'
- 'composer.*'
- 'phpcs.xml'
pull_request:
types:
- 'opened'
- 'synchronize'
- 'reopened'
- 'ready_for_review'
paths:
- '**.php'
- 'package*.json'
- 'composer.*'
- 'phpcs.xml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
env:
PHP_VERSION: '7.4' # Set a default PHP version for the job.
jobs:
phpcs:
name: Run PHP Code Sniffer
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
# User PHP 7.4 here for compatibility with the WordPress codesniffer rules.
- name: Setup PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
php-version: '${{ env.PHP_VERSION }}'
coverage: none
tools: cs2pr
# This date is used to ensure that the PHPCS cache is cleared at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"
- name: Cache PHPCS scan cache
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: '.cache/phpcs.json'
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-php-${{ env.PHP_VERSION }}-phpcs-cache-${{ hashFiles('**/composer.lock', 'phpcs.xml') }}
- name: Install Composer dependencies
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1
with:
composer-options: '--no-progress --optimize-autoloader --prefer-dist'
- name: Run PHP_CodeSniffer
id: phpcs-scan
run: vendor/bin/phpcs --report-full --cache=./.cache/phpcs.json --report-checkstyle=./.cache/phpcs-report.xml
- name: Show scan results in pull request
if: ${{ always() && steps.phpcs-scan.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-report.xml