diff --git a/.github/workflows/ci-lint-js.yml b/.github/workflows/ci-lint-js.yml index 53e0694..5609a55 100644 --- a/.github/workflows/ci-lint-js.yml +++ b/.github/workflows/ci-lint-js.yml @@ -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 @@ -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 @@ -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" diff --git a/.github/workflows/wp-ci.yml b/.github/workflows/wp-ci.yml index faba23d..4391a80 100644 --- a/.github/workflows/wp-ci.yml +++ b/.github/workflows/wp-ci.yml @@ -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 @@ -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: diff --git a/README.md b/README.md index f3f8a2b..233831d 100644 --- a/README.md +++ b/README.md @@ -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) | diff --git a/examples/ci-lint-js.yml b/examples/ci-lint-js.yml index 813993c..a768fcd 100644 --- a/examples/ci-lint-js.yml +++ b/examples/ci-lint-js.yml @@ -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