Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .github/workflows/image-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Compress Images
on:
pull_request:
# Run Image Actions when the WordPress.org assets (banners, icons, screenshots) are added or changed.
# See https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths for reference.
paths:
- '.wordpress-org/**.jpg'
- '.wordpress-org/**.jpeg'
- '.wordpress-org/**.png'
- '.wordpress-org/**.webp'
permissions:
contents: read

jobs:
build:
# Only run on Pull Requests within the same repository, and not from forks.
if: github.event.pull_request.head.repo.full_name == github.repository
name: calibreapp/image-actions
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Compress Images
uses: calibreapp/image-actions@cfe6ba91a2f0e9046d44e2088d002378daeb4a9c # main
with:
# The `GITHUB_TOKEN` is automatically generated by GitHub and scoped only to the repository that is currently running the action. By default, the action can’t update Pull Requests initiated from forked repositories.
# See https://docs.github.com/en/actions/reference/authentication-in-a-workflow and https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
githubToken: ${{ secrets.GITHUB_TOKEN }}
jpegQuality: '100'
jpegProgressive: false
pngQuality: '100'
webpQuality: '100'
63 changes: 63 additions & 0 deletions .github/workflows/js-css-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: JS and CSS Lint

on:
# Run on relevant pushes to select branches and on all relevant pull requests.
push:
branches:
- main
- develop
- 'release/[0-9]+.[0-9]+*'
- 'hotfix/[0-9]+.[0-9]+*'
paths:
- '**.js'
- '**.css'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/js-css-lint.yml'
pull_request:
paths:
- '**.js'
- '**.css'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/js-css-lint.yml'
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: 'Lint JS and CSS'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '22'
cache: 'npm'

# --ignore-scripts: nothing in the dependency tree needs to run code to lint,
# and it skips the husky `prepare` script.
- name: Install npm dependencies
run: npm ci --ignore-scripts

- name: Lint JS
run: npm run lint:js

- name: Lint CSS
if: ${{ always() }}
run: npm run lint:css
Empty file.
66 changes: 66 additions & 0 deletions .github/workflows/plugin-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'WordPress.org Plugin Check'
on: # rebuild any PRs and main branch changes
pull_request:

permissions:
contents: read

jobs:
test:
name: 'WordPress.org Plugin Check'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: '8.3'
coverage: none
# Use a release archive instead of the mutable latest-build URL.
tools: wp-cli:2.12.0
env:
fail-fast: true

# setup-php stores the ephemeral Actions token in ~/.composer/auth.json
# as a github-oauth credential. Composer rejects that token whenever it
# happens to contain a character its validator dislikes ("Your github
# oauth token for github.com contains invalid characters",
# composer#12076), so this step failed on roughly half of all runs
# depending on the token minted for that run.
#
# dist-archive-command is a PUBLIC package and needs no auth, so the
# fix is to delete the stored credential before installing. Clearing
# the env vars alone does NOT work — they are already empty here, and
# the credential lives on disk (verified in progress-planner run 31784727273).
#
# Do NOT switch to the WP-CLI nightly to dodge this: it reports as
# wp-cli 3.0.0-alpha, and every released dist-archive-command requires
# wp-cli ^2 / ^2.13, so the install cannot resolve against it.
#
# Pinned to v3.1.0 deliberately: newest release accepting wp-cli ^2.
# v3.2.x requires ^2.13, which has no stable release (latest is 2.12.0).
- name: Install latest version of dist-archive-command
run: |
rm -f "$(composer config --global home 2>/dev/null)/auth.json"
wp package install wp-cli/dist-archive-command:v3.1.0

# Builds the same file set that is deployed to WordPress.org (see .distignore).
- name: Build plugin
run: |
wp dist-archive . ./${{ github.event.repository.name }}.zip
mkdir plugin-check-build
unzip ${{ github.event.repository.name }}.zip -d plugin-check-build

# v1.1.7 fixed the wp-env silent-startup failure ("Environment not
# initialized. Run `wp-env start` first.") that broke this job on newer
# runner images; v1.1.9 fixes a bundle regression in v1.1.8. Because
# that fix landed upstream, @wordpress/env needs no version pin here.
# https://github.com/WordPress/plugin-check-action/pull/590
- name: Run plugin check
uses: wordpress/plugin-check-action@10857da14b6c2246d15402b3e69f777edcf8c12e # v1.1.9
with:
build-dir: './plugin-check-build/${{ github.event.repository.name }}'
97 changes: 97 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Test

on:
# Run on pushes to select branches and on all pull requests.
push:
branches:
- main
- develop
- 'release/[0-9]+.[0-9]+*'
- 'hotfix/[0-9]+.[0-9]+*'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
integration:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
# Lowest supported PHP and WordPress versions (see the plugin header).
- php_version: '7.4'
wp_version: '6.7'
multisite: false

- php_version: '8.2'
wp_version: 'latest'
multisite: false

- php_version: '8.4'
wp_version: 'latest'
multisite: true

name: "Integration Test: PHP ${{ matrix.php_version }} | WP ${{ matrix.wp_version }}${{ matrix.multisite == true && ' (+ ms)' || '' }}"

services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Install PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: ${{ matrix.php_version }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none

# The lock file is resolved for PHP 7.4. Let Composer pick the PHPUnit
# version that fits the PHP version of this job instead.
- name: "Composer: remove the PHP platform requirement"
run: composer config --unset platform.php

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Install Composer dependencies"
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
with:
# Force a `composer update` run.
dependency-versions: "highest"
# But make it selective.
composer-options: "yoast/wp-test-utils --with-dependencies"
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")

- name: Install WP
shell: bash
run: tests/bin/install-wp-tests.sh wordpress_tests root '' 127.0.0.1:3306 ${{ matrix.wp_version }}

- name: Run tests - single site
run: composer test

- name: Run tests - multisite
if: ${{ matrix.multisite == true }}
run: composer test
env:
WP_MULTISITE: 1
4 changes: 2 additions & 2 deletions aaa-option-optimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function aaa_option_optimizer_activation() {
* @return void
*/
function aaa_option_optimizer_deactivation() {
$aaa_option_value = get_option( 'option_optimizer' );
update_option( 'option_optimizer', $aaa_option_value, false );
// update_option() ignores the autoload argument when the value is unchanged, so set it directly.
wp_set_option_autoload( 'option_optimizer', false );
}

/**
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
"phpstan/phpstan": "^2.0",
"szepeviktor/phpstan-wordpress": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpcompatibility/php-compatibility": "^9.3"
"phpcompatibility/php-compatibility": "^9.3",
"yoast/wp-test-utils": "^1.2"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
},
"platform": {
"php": "7.4.33"
}
},
"scripts": {
Expand All @@ -40,6 +44,9 @@
"lint-known-plugins": [
"@php -r \"exit( intval( is_null( json_decode( file_get_contents( './known-plugins/known-plugins.json' ) ) ) ) );\""
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit"
],
"phpstan": [
"@php ./vendor/bin/phpstan analyse --memory-limit=2048M"
]
Expand Down
Loading
Loading