Skip to content

Merge pull request #1265 from 10up/tweak/readme #1363

Merge pull request #1265 from 10up/tweak/readme

Merge pull request #1265 from 10up/tweak/readme #1363

Workflow file for this run

name: Linting
env:
COMPOSER_VERSION: "2"
COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache"
on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop
jobs:
eslint:
name: eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use desired version of NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Cache Node
uses: actions/cache@v4
with:
path: |
node_modules
~/.cache
~/.npm
key: ${{ hashFiles('package-lock.json') }}
- name: Check versions
run: npm -v; node -v
- name: npm install
run: npm install
- name: Generate linting report
run: npm run lint:js -- --output-file eslint-report.json --format json
continue-on-error: true
- name: Annotate code linting results
uses: ataylorme/[email protected]
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
report-json: 'eslint-report.json'
- name: Update summary
run: |
npm_config_yes=true npx github:10up/eslint-json-to-md --path ./eslint-report.json --output ./eslint-report.md
cat eslint-report.md >> $GITHUB_STEP_SUMMARY
if: ${{ failure() }}
phpcs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**/*.php
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2, cs2pr
coverage: none
- name: Install dependencies
run: composer install
- name: Test all files
if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/trunk' }}
run: ./vendor/bin/phpcs . --report-full --report-checkstyle=./.github/phpcs-report.xml
- name: Test changed files
if: ${{ steps.changed-files.outputs.any_changed == 'true' && github.ref != 'refs/heads/develop' && github.ref != 'refs/heads/trunk' }}
run: ./vendor/bin/phpcs ${{ steps.changed-files.outputs.all_changed_files }} --report-full --report-checkstyle=./.github/phpcs-report.xml --runtime-set testVersion 7.4-
- name: Show PHPCS results in PR
if: ${{ always() }}
run: cs2pr ./.github/phpcs-report.xml