Skip to content
Open
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
13 changes: 13 additions & 0 deletions .github/workflows/ci-lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ on:
description: "Run `npm run lint:package-json` before ESLint."
type: boolean
default: true
typecheck-command:
description: "Shell command that type-checks the whole project after ESLint, e.g. 'npm run typecheck'. Leave empty to skip it."
type: string
default: ""
working-dir:
description: "Working directory for monorepos."
type: string
Expand Down Expand Up @@ -86,6 +90,7 @@ jobs:
cache-dependency-path: ${{ inputs.working-dir != '.' && format('{0}/package-lock.json', inputs.working-dir) || '' }}

- name: Install npm dependencies
id: install
run: npm ci

- name: Validate package.json
Expand Down Expand Up @@ -143,3 +148,11 @@ jobs:

bash -eo pipefail -c "$LINT_COMMAND"
fi

# Runs even when ESLint failed, so one run reports both.
- name: Type-check
if: ${{ !cancelled() && steps.install.outcome == 'success' && inputs.typecheck-command != '' }}
shell: bash
env:
TYPECHECK_COMMAND: ${{ inputs.typecheck-command }}
run: bash -eo pipefail -c "$TYPECHECK_COMMAND"
5 changes: 5 additions & 0 deletions .github/workflows/wp-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ on:
description: "Shell command that runs ESLint on the files passed to it, to lint only the changed JS files. Leave empty to always lint the whole project."
type: string
default: ""
typecheck-command:
description: "Shell command that type-checks the whole project in lint-js after ESLint, e.g. 'npm run typecheck'. Leave empty to skip it."
type: string
default: ""
phpcs-command:
description: "PHPCS binary path or custom command. Leave empty for ci-lint-php.yml's default."
type: string
Expand Down Expand Up @@ -293,6 +297,7 @@ jobs:
node-version: ${{ inputs.node-version }}
lint-command: ${{ inputs.lint-js-command }}
lint-files-command: ${{ inputs.lint-js-files-command }}
typecheck-command: ${{ inputs.typecheck-command }}
working-dir: ${{ needs.validate-inputs.outputs.working-dir }}

lint-php:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ you can copy as-is.
| [`wp-ci.yml`](.github/workflows/wp-ci.yml) | CI orchestrator. One call per unit; routes to the right jobs for `project-type` | [example](examples/wp-ci.yml) |
| [`ci-detect-changes.yml`](.github/workflows/ci-detect-changes.yml) | Buckets changed files, exposes per-type counts and file lists | [example](examples/ci-detect-changes.yml) |
| [`ci-lint-css.yml`](.github/workflows/ci-lint-css.yml) | Stylelint | [example](examples/ci-lint-css.yml) |
| [`ci-lint-js.yml`](.github/workflows/ci-lint-js.yml) | ESLint + optional `package.json` validation | [example](examples/ci-lint-js.yml) |
| [`ci-lint-js.yml`](.github/workflows/ci-lint-js.yml) | ESLint + optional `package.json` validation and type-check | [example](examples/ci-lint-js.yml) |
| [`ci-lint-php.yml`](.github/workflows/ci-lint-php.yml) | PHPCS with `cs2pr` annotations + optional PHPStan | [example](examples/ci-lint-php.yml) |
| [`ci-test-js.yml`](.github/workflows/ci-test-js.yml) | Jest | [example](examples/ci-test-js.yml) |
| [`ci-test-php.yml`](.github/workflows/ci-test-php.yml) | PHPUnit, via `@wordpress/env` or standalone | [example](examples/ci-test-php.yml) |
Expand Down
1 change: 1 addition & 0 deletions examples/ci-lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ jobs:
lint-command: npm run lint:js
lint-files-command: npm run lint:js:files
validate-package-json: true
typecheck-command: npm run typecheck
Loading