Skip to content

Chore(deps-dev): Bump eslint from 8.56.0 to 9.11.1 #923

Chore(deps-dev): Bump eslint from 8.56.0 to 9.11.1

Chore(deps-dev): Bump eslint from 8.56.0 to 9.11.1 #923

Workflow file for this run

name: Test and Measure
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
pre-run:
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
# Fetch last 2 commits if it's not a PR, so that we can determine the list of modified files.
if: ${{ github.base_ref == null }}
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Checkout
# Do usual checkout if it's a PR.
if: ${{ github.base_ref != null }}
uses: actions/checkout@v4
- name: Fetch base branch
# Only fetch base ref if it's a PR.
if: ${{ github.base_ref != null }}
run: git fetch --depth=1 --no-tags origin ${{ github.base_ref }}
- name: Determine modified files for PR
if: ${{ github.base_ref != null }}
run: echo "MODIFIED_FILES=$(git diff --name-only FETCH_HEAD HEAD | base64 -w 0)" >> $GITHUB_ENV
- name: Determine modified files for commit
if: ${{ github.base_ref == null }}
run: echo "MODIFIED_FILES=$(git diff --name-only HEAD~1 HEAD | base64 -w 0)" >> $GITHUB_ENV
- id: determine-file-counts
name: Determine if modified files should make the workflow run continue
run: |
MODIFIED_FILES=$(echo "$MODIFIED_FILES" | base64 -d)
echo -e "Modified files:\n$MODIFIED_FILES\n"
MODIFIED_FILES_DATA=$(node .github/bin/determine-modified-files-count.js "$IGNORE_PATH_REGEX" "$MODIFIED_FILES" "all")
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")
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"
env:
# Ignore Paths:
# - .github/
# - !.github/workflows
# - .wordpress-org/
# - docs/
IGNORE_PATH_REGEX: \.github\/(?!workflows)|\.wordpress-org\/|docs\/
lint-css:
needs: pre-run
if: needs.pre-run.outputs.changed-css-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
name: 'Lint CSS'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- 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
name: 'Lint JS'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- 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
name: 'Run JS unit tests'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- name: Run unit tests
run: npm run test:js
env:
CI: true
lint-php:
needs: pre-run
if: needs.pre-run.outputs.changed-php-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
name: 'Lint PHP'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
tools: cs2pr
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Configure Composer cache
uses: actions/[email protected]
with:
path: ${{ steps.composer-cache.outputs.dir }}
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
- name: Validate composer.json
run: composer --no-interaction validate --no-check-all
- name: Detect coding standard violations (PHPCS)
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:
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@v4
- name: Setup Node
if: needs.pre-run.outputs.changed-php-count > 0
uses: actions/[email protected]
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: 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
name: 'Build production'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Node dependencies
run: npm ci --ignore-scripts
env:
CI: true
- name: Build production
id: build
run: npm run build:prod
env:
CI: true