Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ jobs:
os: ['macos-15', 'ubuntu-24.04', 'windows-2025']

include:
# Only generate annotations once.
# Only generate lint-js once.
- node: '24'
os: 'ubuntu-24.04'
annotations: true
lint-js: true
lint-css: true
exclude:
# On PRs: Only test Node 20 on Ubuntu and Windows
- event: 'pull_request'
Expand All @@ -52,6 +53,27 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

# This date is used to ensure that caches are cleared at least once every other.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: Get the date from 2 days ago
id: get-date
if: ${{ matrix.lint-js || matrix.lint-css }}
run: echo "date=$(/bin/date -u --date='2 days ago' "+%F")" >> "$GITHUB_OUTPUT"

- name: Configure caching for ESLint
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
if: ${{ matrix.lint-js }}
with:
path: .cache/eslint/.eslintcache
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-eslint-cache-${{ hashFiles('**/package.json', '**/.eslintignore', '**/.eslintrc.js', '**/.eslint.strict.js') }}

- name: Configure caching for Stylelint
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
if: ${{ matrix.lint-css }}
with:
path: .cache/.stylelintcache/
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-stylelint-cache-${{ hashFiles('**/package.json', '**/.stylelintignore', '**/.stylelintrc.json') }}

- name: Use desired version of Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
Expand Down Expand Up @@ -80,11 +102,11 @@ jobs:
run: npm run lint:tsconfig

- name: Lint JavaScript
if: ${{ matrix.annotations }}
if: ${{ matrix.lint-js }}
run: npm run lint:js -- --format compact

- name: Lint Styles
if: ${{ matrix.annotations }}
if: ${{ matrix.lint-css }}
run: npm run lint:css -- --formatter compact

- name: Type checking
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@
"format:php": "wp-env run --env-cwd='wp-content/plugins/gutenberg' cli composer run-script format",
"prelint:js": "npm run --if-present --workspaces prelint:js",
"lint": "concurrently \"npm run lint:lockfile\" \"npm run lint:tsconfig\" \"npm run lint:js\" \"npm run lint:pkg-json\" \"npm run lint:css\"",
"lint:css": "wp-scripts lint-style \"**/*.scss\" \"**/*.module.css\"",
"lint:css": "wp-scripts lint-style \"**/*.scss\" \"**/*.module.css\" --cache --cache-location .cache/.stylelintcache/",
"lint:css:fix": "npm run lint:css -- --fix",
"lint:js": "wp-scripts lint-js",
"lint:js": "wp-scripts lint-js --cache --cache-location .cache/eslint/.eslintcache",
"lint:js:fix": "npm run lint:js -- --fix",
"lint:lockfile": "node ./bin/validate-package-lock.js",
"lint:tsconfig": "node ./bin/validate-tsconfig.mjs",
Expand Down
Loading