Skip to content

Commit

Permalink
Enable automated JS & CSS checks (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion authored Sep 26, 2023
2 parents 2ef4979 + fc06c9b commit df75c02
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 2 deletions.
88 changes: 87 additions & 1 deletion .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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 }}
changed-css: ${{ steps.filter.outputs.css }}
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -44,7 +46,8 @@ jobs:
- added|modified: '**/*.json'
yml:
- added|modified: '**/*.yml'
scss:
css:
- added|modified: '**/*.css'
- added|modified: '**/*.scss'
php:
- added|modified: '**/*.php'
Expand Down Expand Up @@ -97,6 +100,89 @@ jobs:

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

lint-css:
name: 'Lint: CSS'
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-css == '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 CSS coding standard violations
run: npm run lint:css

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

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ See the workflow running for the figuren.theater platform
| 18.|[ft-security](https://github.com/figuren-theater/ft-security)| [![Build, test & measure](https://github.com/figuren-theater/ft-security/actions/workflows/build-test-measure.yml/badge.svg)](https://github.com/figuren-theater/ft-security/actions/workflows/build-test-measure.yml) |
| 19.|[ft-seo](https://github.com/figuren-theater/ft-seo)| |
| 20.|[ft-site-editing](https://github.com/figuren-theater/ft-site-editing)| [![Build, test & measure](https://github.com/figuren-theater/ft-site-editing/actions/workflows/build-test-measure.yml/badge.svg)](https://github.com/figuren-theater/ft-site-editing/actions/workflows/build-test-measure.yml) |
| 21.| ├── [ft-network-block-editor](https://github.com/figuren-theater/ft-network-block-editor)| |
| 21.| ├── [ft-network-block-editor](https://github.com/figuren-theater/ft-network-block-editor)| [![Build, test & measure](https://github.com/figuren-theater/ft-network-block-editor/actions/workflows/build-test-measure.yml/badge.svg)](https://github.com/figuren-theater/ft-network-block-editor/actions/workflows/build-test-measure.yml) |
| 22.| └── [ft-network-block-patterns](https://github.com/figuren-theater/ft-network-block-patterns)| |
| 23.|[ft-themes](https://github.com/figuren-theater/ft-themes)| [![Build, test & measure](https://github.com/figuren-theater/ft-themes/actions/workflows/build-test-measure.yml/badge.svg)](https://github.com/figuren-theater/ft-themes/actions/workflows/build-test-measure.yml) |
| 24.|[ft-theming](https://github.com/figuren-theater/ft-theming)| [![Build, test & measure](https://github.com/figuren-theater/ft-theming/actions/workflows/build-test-measure.yml/badge.svg)](https://github.com/figuren-theater/ft-theming/actions/workflows/build-test-measure.yml) |
Expand Down

0 comments on commit df75c02

Please sign in to comment.