Skip to content

Commit

Permalink
Enable automated JS checks (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion committed Sep 26, 2023
1 parent e6dfab3 commit e36d885
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
changed-php: ${{ steps.filter.outputs.php }}
changed-php_files: ${{ steps.filter.outputs.php_files }}
changed-json: ${{ steps.filter.outputs.json }}
changed-js: ${{ steps.filter.outputs.js }}
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -97,6 +98,58 @@ jobs:

#-----------------------------------------------------------------------------------------------------------------------

lint-js:
name: 'Lint: JS'
needs: pre-run
# only run for changed .php files AND when it is a pull_request
# because 'github.base_ref' will not be available on push
if: needs.pre-run.outputs.changed-js == 'true' && github.base_ref != null
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/[email protected]
with:
# use the same version like WordPress/gutenberg
node-version: '16'
cache: npm

- name: Install Node dependencies
run: npm ci
env:
CI: true

- name: Validate package.json
run: npm run lint:pkg-json

- name: Detect ESLint coding standard violations
if: >
github.event.pull_request.head.repo.fork == true ||
github.event.pull_request.user.login == 'dependabot[bot]'
run: npm run lint:js

- name: Generate ESLint coding standard violations report
# Prevent generating the ESLint report if PR is from a fork or authored by Dependabot.
if: >
! ( github.event.pull_request.head.repo.fork == true ||
github.event.pull_request.user.login == 'dependabot[bot]' )
run: npm run lint:js:report
continue-on-error: true

- name: Annotate code linting results
# The action cannot annotate the PR when run from a PR fork or was authored by Dependabot.
if: >
! ( github.event.pull_request.head.repo.fork == true ||
github.event.pull_request.user.login == 'dependabot[bot]' )
uses: ataylorme/[email protected]
with:
repo-token: '${{ secrets.BOT_TOKEN }}'
report-json: 'lint-js-report.json'

#-----------------------------------------------------------------------------------------------------------------------

lint-php:
name: 'Lint: PHP'
needs: pre-run
Expand Down

0 comments on commit e36d885

Please sign in to comment.