Skip to content

Commit

Permalink
update the eslint workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi committed Jun 11, 2024
1 parent bc8a514 commit 3915944
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 24 deletions.
87 changes: 63 additions & 24 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,91 @@ jobs:
eslint:
name: eslint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup node version and npm cache
uses: actions/setup-node@v3
- uses: actions/checkout@v4

- name: Setup node v16 and npm cache
uses: actions/setup-node@v4
with:
node-version: 14
cache: 'npm'
node-version-file: .nvmrc
cache: npm

- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm install
- name: eslint
uses: icrawl/action-eslint@v1
run: npm ci --no-optional

- name: Get updated JS files
id: changed-files
uses: tj-actions/changed-files@v42
with:
custom-glob: assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
files: |
**/*.js
**/*.json
- name: Run JS linting
run: |
if [[ "${{ steps.changed-files.outputs.any_changed }}" == 'true' && "${{ github.event_name }}" == "pull_request" ]]; then
npx wp-scripts lint-js ${{ steps.changed-files.outputs.all_changed_files }}
elif [[ "${{ github.event_name }}" == "push" ]]; then
npm run lint:js
fi
phpcs:
name: phpcs
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"
- name: Prepare composer cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer:v2, cs2pr
- name: composer install
run: composer install --ignore-platform-reqs
- name: Check PHPCS standard
run: ./vendor/bin/phpcs -i
tools: composer:v2

- name: Install dependencies
run: composer install

- name: Get updated PHP files
id: changed-files
uses: tj-actions/changed-files@v42
with:
files: |
**/*.php
- name: PHPCS check
id: phpcs
run: ./vendor/bin/phpcs . --runtime-set testVersion 7.4- --report-checkstyle=${RUNNER_TEMP}/phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr --graceful-warnings ${RUNNER_TEMP}/phpcs-report.xml
run: |
if [[ "${{ steps.changed-files.outputs.any_changed }}" == 'true' && "${{ github.event_name }}" == "pull_request" ]]; then
./vendor/bin/phpcs ${{ steps.changed-files.outputs.all_changed_files }} -s --runtime-set testVersion 7.4-
elif [[ "${{ github.event_name }}" == "push" ]]; then
./vendor/bin/phpcs . -s --runtime-set testVersion 7.4-
fi
vipcs:
name: vipcs
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: VIPCS check
uses: 10up/wpcs-action@stable
with:
enable_warnings: true
standard: 'WordPress-VIP-Go'
excludes: 'tests'
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.21.1

0 comments on commit 3915944

Please sign in to comment.