Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7ff6d3a
chore: Update output messages in CI workflow to include repository na…
Infinite-Null Apr 1, 2026
619b966
chore: Enhance CI workflow by adding node version retrieval and cachi…
Infinite-Null Apr 1, 2026
879022c
chore: Add cache miss message for npm ci in CI workflow
Infinite-Null Apr 1, 2026
2c0cebf
chore: Simplify CI workflow by removing redundant cache miss messages…
Infinite-Null Apr 1, 2026
8c06563
chore: Add test placeholder to test
Infinite-Null Apr 1, 2026
5f8656b
chore: Test by removing checks for changed GHA workflows in lint and …
Infinite-Null Apr 1, 2026
b267cb2
chore: Update CI conditions to include checks for changed GHA workflo…
Infinite-Null Apr 1, 2026
354cd08
chore: Change cache key for testing
Infinite-Null Apr 2, 2026
258c479
chore: Revert cache key format for node modules in CI workflow
Infinite-Null Apr 2, 2026
19945c3
feat: Add composite action for reusable Node.js setup with caching
Infinite-Null Apr 3, 2026
0a18a64
chore: consolidate job-skip notices into pre-run summary step
Infinite-Null Apr 3, 2026
7e5372e
chore: Add workflow_dispatch
Infinite-Null Apr 3, 2026
0b6ff76
chore: Remove `workflow_dispatch`
Infinite-Null Apr 3, 2026
c3a0810
chore: Remove GHA workflow count from job triggers and outputs
Infinite-Null Apr 3, 2026
6d4526d
chore: Update IGNORE_PATH_REGEX to also allow .github/actions through
Infinite-Null Apr 3, 2026
6c3bdd4
chore: Fix regex
Infinite-Null Apr 3, 2026
b11a751
chore: Add test placeholder to README
Infinite-Null Apr 5, 2026
c654b05
chore: Remove redundant test placeholder from README
Infinite-Null Apr 5, 2026
ba1ea5e
chore: Test CI
Infinite-Null Apr 5, 2026
1adb6f9
fix: Correct typo in external dependencies comment
Infinite-Null Apr 5, 2026
1c49d2c
fix: Remove cache option from setup-node action
Infinite-Null Apr 5, 2026
a752c33
fix: Correct typo in external dependencies comment
Infinite-Null Apr 5, 2026
b5f479d
fix: Add missing newline at end of README.md
Infinite-Null Apr 5, 2026
73b4428
fix: Update cache condition for Node dependencies installation
Infinite-Null Apr 7, 2026
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
29 changes: 29 additions & 0 deletions .github/actions/setup-node-with-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Setup Node with Cache'
description: 'Sets up Node.js and caches node_modules'

runs:
using: 'composite'
steps:
- name: Setup Node
uses: actions/setup-node@v6.2.0
with:
node-version-file: '.nvmrc'

- name: Get node version
id: node
run: echo "version=$(node -v)" >> $GITHUB_OUTPUT
shell: bash

- name: Cache node_modules
id: node_modules
uses: actions/cache@v5.0.3
with:
path: '**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json', '**/.npmrc') }}-${{ steps.node.outputs.version }}

- name: Install Node dependencies
if: steps.node_modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
shell: bash
env:
CI: true
131 changes: 47 additions & 84 deletions .github/workflows/test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ jobs:
name: 'Pre run'
runs-on: ubuntu-latest
outputs:
changed-file-count: ${{ steps.determine-file-counts.outputs.count }}
changed-css-count: ${{ steps.determine-file-counts.outputs.css-count }}
changed-js-count: ${{ steps.determine-file-counts.outputs.js-count }}
changed-php-count: ${{ steps.determine-file-counts.outputs.php-count }}
changed-gha-workflow-count: ${{ steps.determine-file-counts.outputs.gha-workflow-count }}

steps:
- name: Checkout including last 2 commits
Expand Down Expand Up @@ -64,92 +62,84 @@ jobs:
CSS_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.s?css|package\.json|package-lock\.json" "$MODIFIED_FILES")
JS_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.(js|snap)|package\.json|package-lock\.json" "$MODIFIED_FILES")
PHP_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.php|composer\.(json|lock)|phpstan\.neon\.dist" "$MODIFIED_FILES")
GHA_WORKFLOW_COUNT=$(node .github/bin/determine-modified-files-count.js "(\.github\/workflows\/.+\.yml)" "$MODIFIED_FILES")
GHA_WORKFLOW_COUNT=$(node .github/bin/determine-modified-files-count.js "(\.github\/(workflows|actions)\/.+\.yml)" "$MODIFIED_FILES")

echo "Changed file count: $MODIFIED_FILES_DATA"
echo "Changed CK theme CSS file count: $CSS_FILE_COUNT"
echo "Changed CK theme JS file count: $JS_FILE_COUNT"
echo "Changed CK theme PHP file count: $PHP_FILE_COUNT"
echo "Changed GHA workflow count: $GHA_WORKFLOW_COUNT"

echo "::set-output name=count::$MODIFIED_FILES_DATA"
echo "::set-output name=css-count::$CSS_FILE_COUNT"
echo "::set-output name=js-count::$JS_FILE_COUNT"
echo "::set-output name=php-count::$PHP_FILE_COUNT"
echo "::set-output name=gha-workflow-count::$GHA_WORKFLOW_COUNT"
echo "Changed ${{ github.event.repository.name }} CSS file count: $CSS_FILE_COUNT"
echo "Changed ${{ github.event.repository.name }} JS file count: $JS_FILE_COUNT"
echo "Changed ${{ github.event.repository.name }} PHP file count: $PHP_FILE_COUNT"
echo "Changed GHA workflow/actions count: $GHA_WORKFLOW_COUNT"

echo "css-count=$CSS_FILE_COUNT" >> $GITHUB_OUTPUT
echo "js-count=$JS_FILE_COUNT" >> $GITHUB_OUTPUT
echo "php-count=$PHP_FILE_COUNT" >> $GITHUB_OUTPUT
env:
# Ignore Paths:
# - .github/
# - !.github/workflows
# - !.github/actions
# - .wordpress-org/
# - docs/
IGNORE_PATH_REGEX: \.github\/(?!workflows)|\.wordpress-org\/|docs\/
IGNORE_PATH_REGEX: \.github\/(?!workflows)(?!actions)|\.wordpress-org\/|docs\/

- name: Summarize skipped jobs
run: |
SKIPPED=()

[[ "${{ steps.determine-file-counts.outputs.css-count }}" -le 0 ]] && SKIPPED+=("lint-css")
[[ "${{ steps.determine-file-counts.outputs.js-count }}" -le 0 ]] && SKIPPED+=("lint-js" "unit-tests-js" "build-prod")
[[ "${{ steps.determine-file-counts.outputs.php-count }}" -le 0 ]] && SKIPPED+=("lint-php" "unit-test-php")

if [[ ${#SKIPPED[@]} -gt 0 ]]; then
echo "The following jobs will be skipped as no relevant files were changed:"
for JOB in "${SKIPPED[@]}"; do
echo " - $JOB"
done
else
echo "All jobs will run."
fi

lint-css:
needs: pre-run
if: needs.pre-run.outputs.changed-css-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
if: needs.pre-run.outputs.changed-css-count > 0
name: 'Lint CSS'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v6.2.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- name: Setup Node with cache
uses: ./.github/actions/setup-node-with-cache

- name: Detect coding standard violations (stylelint)
run: npm run lint:css

lint-js:
needs: pre-run
if: needs.pre-run.outputs.changed-js-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
if: needs.pre-run.outputs.changed-js-count > 0
name: 'Lint JS'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v6.2.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- name: Setup Node with cache
uses: ./.github/actions/setup-node-with-cache

- name: Detect coding standard violations (eslint)
run: npm run lint:js

unit-tests-js:
needs: pre-run
if: needs.pre-run.outputs.changed-js-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
if: needs.pre-run.outputs.changed-js-count > 0
name: 'Run JS unit tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v6.2.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- name: Setup Node with cache
uses: ./.github/actions/setup-node-with-cache

- name: Run unit tests
run: npm run test:js
Expand All @@ -158,7 +148,7 @@ jobs:

lint-php:
needs: pre-run
if: needs.pre-run.outputs.changed-php-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
if: needs.pre-run.outputs.changed-php-count > 0
name: 'Lint PHP'
runs-on: ubuntu-latest
steps:
Expand All @@ -174,7 +164,7 @@ jobs:

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Configure Composer cache
uses: actions/cache@v5.0.3
Expand All @@ -183,6 +173,7 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction --no-scripts

Expand All @@ -193,62 +184,34 @@ jobs:
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings

unit-test-php:
needs: pre-run
if: needs.pre-run.outputs.changed-php-count > 0
name: "PHP Unit test"
runs-on: ubuntu-latest
needs: pre-run
steps:
# Note: The repeated `needs.pre-run.outputs.changed-php-count > 0` checks would be avoided if a step could short-
# circuit per <https://github.com/actions/runner/issues/662>. The reason why the if statement can't be put on the
# job as a whole is because the name is variable based on the matrix, and if the condition is not met then the
# name won't be interpolated in order to match the required jobs set up in branch protection.
- name: Notice
if: needs.pre-run.outputs.changed-php-count > 0
run: echo "No PHP files were changed in CK theme so no PHP unit tests will run"

- name: Checkout
if: needs.pre-run.outputs.changed-php-count > 0
uses: actions/checkout@v6

- name: Setup Node
if: needs.pre-run.outputs.changed-php-count > 0
uses: actions/setup-node@v6.2.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install Node dependencies
if: needs.pre-run.outputs.changed-php-count > 0
run: npm ci --ignore-scripts
env:
CI: true
- name: Setup Node with cache
uses: ./.github/actions/setup-node-with-cache

- name: Start WP environment
if: needs.pre-run.outputs.changed-php-count > 0
run: npm run wp-env start

- name: Run tests
if: ${{ needs.pre-run.outputs.changed-php-count > 0 }}
run: npm run test:php

build-prod:
needs: pre-run
if: needs.pre-run.outputs.changed-js-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0 || needs.pre-run.outputs.changed-css-count > 0
if: needs.pre-run.outputs.changed-js-count > 0 || needs.pre-run.outputs.changed-css-count > 0
name: 'Build production'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v6.2.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- name: Setup Node with cache
uses: ./.github/actions/setup-node-with-cache

- name: Build production
id: build
Expand Down