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
98 changes: 98 additions & 0 deletions .github/workflows/javascript-type-checking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: JavaScript Type Checking

on:
# JavaScript type checking was introduced in 7.0.0.
push:
branches:
- trunk
- '[7-9].[0-9]'
tags:
- '[7-9].[0-9]'
- '[7-9]+.[0-9].[0-9]+'
pull_request:
branches:
- trunk
- '[7-9].[0-9]'
paths:
# This workflow only scans JavaScript files.
- '**.js'
# These files configure npm. Changes could affect the outcome.
- 'package*.json'
- '.nvmrc'
# This file configures TypeScript. Changes could affect the outcome.
- 'tsconfig.json'
# This directory contains TypeScript definitions. Changes could affect the outcome.
- 'typings/**'
# Confirm any changes to relevant workflow files.
- '.github/workflows/javascript-type-checking.yml'
- '.github/workflows/reusable-javascript-type-checking.yml'
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}

jobs:
# Runs JavaScript type checking.
typecheck:
name: JavaScript type checking
uses: ./.github/workflows/reusable-javascript-type-checking.yml
permissions:
contents: read
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}

slack-notifications:
name: Slack Notifications
uses: ./.github/workflows/slack-notifications.yml
permissions:
actions: read
contents: read
needs: [ typecheck ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}

failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-24.04
permissions:
actions: write
needs: [ slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
contains( needs.*.result, 'cancelled' ) ||
contains( needs.*.result, 'failure' )
)

steps:
- name: Dispatch workflow run
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: `${context.runId}`,
}
});
2 changes: 1 addition & 1 deletion .github/workflows/phpstan-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
steps:
- name: Dispatch workflow run
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this hadn't been updated to match all of the other workflows.

with:
retries: 2
retry-exempt-status-codes: 418
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/reusable-javascript-type-checking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
##
# A reusable workflow that runs JavaScript Type Checking.
##
name: JavaScript Type Checking

on:
workflow_call:

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}

jobs:
# Runs JavaScript type checking.
#
# Violations are reported inline with annotations.
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header comment says “Violations are reported inline with annotations”, but this workflow currently just runs npm run typecheck:js without configuring a TypeScript problem matcher or converting output to an annotation format (like cs2pr is used for PHPStan). Either update the comment to reflect that annotations aren’t provided, or add a matcher/formatter so the claim is accurate.

Suggested change
# Violations are reported inline with annotations.
# Violations are reported in the workflow logs.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct. Inline annotations are working as seen in #11131 (comment)

#
# Performs the following steps:
# - Checks out the repository.
# - Sets up Node.js.
# - Logs debug information.
# - Installs npm dependencies.
# - Configures caching for TypeScript build info.
# - Runs JavaScript type checking.
# - Saves the TypeScript build info.
# - Ensures version-controlled files are not modified or deleted.
typecheck:
name: Run JavaScript type checking
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 20

steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Log debug information
run: |
npm --version
node --version

- name: Install npm dependencies
run: npm ci --ignore-scripts

- name: Cache TypeScript build info
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
*.tsbuildinfo
key: "ts-build-info-${{ github.run_id }}"
restore-keys: |
ts-build-info-

- name: Run JavaScript type checking
run: npm run typecheck:js

- name: "Save result cache"
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
if: ${{ !cancelled() }}
with:
path: |
*.tsbuildinfo
key: "ts-build-info-${{ github.run_id }}"

- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
13 changes: 13 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ module.exports = function(grunt) {
grunt.registerTask( 'precommit:js', [
'webpack:prod',
'jshint:corejs',
'typecheck:js',
'uglify:imgareaselect',
'uglify:jqueryform',
'uglify:moment',
Expand Down Expand Up @@ -2009,6 +2010,18 @@ module.exports = function(grunt) {

grunt.registerTask( 'test', 'Runs all QUnit and PHPUnit tasks.', ['qunit:compiled', 'phpunit'] );

grunt.registerTask( 'typecheck:js', 'Runs TypeScript type checking.', function() {
var done = this.async();

grunt.util.spawn( {
cmd: 'npm',
args: [ 'run', 'typecheck:js' ],
opts: { stdio: 'inherit' }
}, function( error ) {
done( ! error );
} );
} );

grunt.registerTask( 'phpstan', 'Runs PHPStan on the entire codebase.', function() {
var done = this.async();

Expand Down
Loading