Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1e0b484
Run unit tests only for plugins with changes
ShyamGadde Jan 23, 2025
d5e614d
Add spaces to avoid problems with partial matches
ShyamGadde Jan 23, 2025
0bc67df
Test all plugins when commits added to trunk
ShyamGadde Jan 23, 2025
cbce9b4
Test all plugins when non-plugin files are changed
ShyamGadde Jan 23, 2025
76a48cf
Trigger tests for dependent plugins on changes to OD
ShyamGadde Jan 23, 2025
d098b38
Check for duplicates in the plugins array for good measure
ShyamGadde Jan 23, 2025
020cce3
Fix Git diff listing files not changed by PR
ShyamGadde Jan 23, 2025
eb4dad0
Fix error with merge base resolution
ShyamGadde Jan 23, 2025
bea1bc0
Use tj-actions/changed-files for determining changed files
ShyamGadde Jan 30, 2025
3c66be3
Refactor logic to determine changes to config files
ShyamGadde Jan 30, 2025
fd07a0c
Simplify changed plugins detection
ShyamGadde Jan 30, 2025
fa1a433
Remove debug print statement
ShyamGadde Jan 30, 2025
11949ac
Fix array expansion to avoid SC2199 warning
ShyamGadde Feb 3, 2025
1033ad7
Test all plugins on changes to PHPUnit bootstrap file
ShyamGadde Feb 3, 2025
af6f8ff
Add PHPUnit bootstrap file to list of paths to trigger this workflow
ShyamGadde Feb 3, 2025
90a5ab7
Rename PLUGIN_DEPENDENCIES to PLUGIN_DEPENDENTS for clarity
ShyamGadde Feb 4, 2025
5323c60
Merge branch 'trunk' into update/skip-unnecessary-plugin-tests
ShyamGadde Feb 4, 2025
8917216
Restore EOF EOL
ShyamGadde Feb 4, 2025
8713f45
Remove deprecated Codecov configuration
ShyamGadde Feb 5, 2025
f89cf3e
Merge branch 'trunk' into update/skip-unnecessary-plugin-tests
ShyamGadde Feb 6, 2025
7aff9b2
Revert "Remove deprecated Codecov configuration"
ShyamGadde Feb 6, 2025
27cd4d0
Merge branch 'trunk' into update/skip-unnecessary-plugin-tests
ShyamGadde Feb 10, 2025
0be7a66
Show only patch coverage in PR comment
ShyamGadde Feb 10, 2025
6b34020
Limit Project coverage status checks to only the trunk
ShyamGadde Feb 10, 2025
e21ec9e
Use condensed variants of header, files and footer in the PR comment
ShyamGadde Feb 10, 2025
db41189
Reduce patch coverage threshold to 20 percent
ShyamGadde Feb 10, 2025
9c8c17e
Merge branch 'trunk' into update/skip-unnecessary-plugin-tests
ShyamGadde Mar 18, 2025
93dbf21
Enable carryforward flag for partial testing setup
ShyamGadde Mar 18, 2025
c1c5b11
Implement tokenless coverage report uploads for forks
ShyamGadde Mar 19, 2025
12210f8
Merge branch 'trunk' into update/skip-unnecessary-plugin-tests
ShyamGadde Jan 13, 2026
bc5cfe9
Fix indentation in codecov.yml
ShyamGadde Jan 13, 2026
264add9
Pin changed-files GH action to SHA
ShyamGadde Jan 13, 2026
7066ece
Merge branch 'trunk' into update/skip-unnecessary-plugin-tests
westonruter Jan 16, 2026
3a30efb
Add view-transitions to codecov.yml
westonruter Jan 17, 2026
e9596f9
Alphabetize 3a30efb1f48447398f7f9c7e927785b224a49936
westonruter Jan 17, 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
147 changes: 109 additions & 38 deletions .github/workflows/php-test-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- '**/package.json'
- 'package-lock.json'
- 'phpunit.xml.dist'
- 'tools/phpunit/bootstrap.php'
- 'composer.json'
- 'composer.lock'
pull_request:
Expand All @@ -24,6 +25,7 @@ on:
- '**/package.json'
- 'package-lock.json'
- 'phpunit.xml.dist'
- 'tools/phpunit/bootstrap.php'
- 'composer.json'
- 'composer.lock'
types:
Expand Down Expand Up @@ -61,6 +63,55 @@ jobs:
steps:
- uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # 0.12.1
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@e0021407031f5be11a464abee9a0776171c79891 # v47.0.1
with:
dir_names: true # Output unique changed directories.
dir_names_max_depth: 2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This limits the directory output to a maximum depth of 2. For example, plugins/<plugin-name>/tests will be returned as plugins/<plugin-name>.
Since dir_names: true ensures only unique directories are listed, combining it with dir_names_max_depth: 2 allows us to extract a clean list of changed plugin names. This avoids additional logic in the next step for determining modified plugins.

files_yaml: |
plugins:
- 'plugins/**'
config:
- '.github/workflows/php-test-plugins.yml'
- '.wp-env.json'
- '**/package.json'
- 'package-lock.json'
- 'phpunit.xml.dist'
- 'tools/phpunit/bootstrap.php'
- 'composer.json'
- 'composer.lock'
- name: Get changed plugins
id: changed-plugins
run: |
if [[ "${{ github.event_name }}" == "push" || "${{ steps.changed-files.outputs.config_any_changed }}" == "true" ]]; then
ALL_CHANGED_PLUGINS=($(ls plugins))
echo "all_changed_plugins=${ALL_CHANGED_PLUGINS[*]}" >> $GITHUB_OUTPUT
exit 0
fi
Comment on lines +87 to +91
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The condition checks if github.event_name equals "push" but doesn't verify which branch was pushed to. According to the workflow trigger configuration, pushes can occur on both "trunk" and "release/**" branches. The description states "All tests will run for all plugins when commits are added to the trunk branch", but this condition will run all tests for any push, including release branches. Consider adding a branch check to ensure this behavior only applies to trunk pushes if that's the intended behavior.

Copilot uses AI. Check for mistakes.

declare -a ALL_CHANGED_PLUGINS=()
for DIR in ${{ steps.changed-files.outputs.plugins_all_changed_files }}; do
PLUGIN_NAME=$(basename "$DIR")
ALL_CHANGED_PLUGINS+=("$PLUGIN_NAME")
done

# Define and add plugin dependents (e.g., changes to Optimization Detective should trigger its dependents).
declare -A PLUGIN_DEPENDENTS=(
["optimization-detective"]="embed-optimizer image-prioritizer"
)
for PLUGIN in "${ALL_CHANGED_PLUGINS[@]}"; do
if [[ -n "${PLUGIN_DEPENDENTS[$PLUGIN]}" ]]; then
for DEP in ${PLUGIN_DEPENDENTS[$PLUGIN]}; do
if [[ ! " ${ALL_CHANGED_PLUGINS[*]} " =~ " ${DEP} " ]]; then
ALL_CHANGED_PLUGINS+=("$DEP")
fi
done
fi
done

Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The shell script doesn't handle the case where no plugins have changed. If ALL_CHANGED_PLUGINS is empty, the subsequent for loops in the test execution steps will fail silently or produce errors. Add a check to ensure at least one plugin needs testing, or exit early with a message if no plugins changed.

Suggested change
if [[ ${#ALL_CHANGED_PLUGINS[@]} -eq 0 ]]; then
echo "No changed plugins detected; skipping plugin tests."
echo "all_changed_plugins=" >> $GITHUB_OUTPUT
exit 0
fi

Copilot uses AI. Check for mistakes.
ALL_CHANGED_PLUGINS=($(echo "${ALL_CHANGED_PLUGINS[@]}" | tr ' ' '\n' | sort | tr '\n' ' '))
echo "all_changed_plugins=${ALL_CHANGED_PLUGINS[*]}" >> $GITHUB_OUTPUT
- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
Expand Down Expand Up @@ -93,50 +144,70 @@ jobs:
- name: Running single site unit tests
run: |
if [ "${{ matrix.coverage }}" == "true" ]; then
npm run test-php:performance-lab -- -- -- --coverage-clover=./single-site-reports/coverage-performance-lab.xml
npm run test-php:auto-sizes -- -- -- --coverage-clover=./single-site-reports/coverage-auto-sizes.xml
npm run test-php:dominant-color-images -- -- -- --coverage-clover=./single-site-reports/coverage-dominant-color-images.xml
npm run test-php:embed-optimizer -- -- -- --coverage-clover=./single-site-reports/coverage-embed-optimizer.xml
npm run test-php:image-prioritizer -- -- -- --coverage-clover=./single-site-reports/coverage-image-prioritizer.xml
npm run test-php:optimization-detective -- -- -- --coverage-clover=./single-site-reports/coverage-optimization-detective.xml
npm run test-php:speculation-rules -- -- -- --coverage-clover=./single-site-reports/coverage-speculation-rules.xml
npm run test-php:view-transitions -- -- -- --coverage-clover=./single-site-reports/coverage-view-transitions.xml
npm run test-php:web-worker-offloading -- -- -- --coverage-clover=./single-site-reports/coverage-web-worker-offloading.xml
npm run test-php:webp-uploads -- -- -- --coverage-clover=./single-site-reports/coverage-webp-uploads.xml
for PLUGIN in ${{ steps.changed-plugins.outputs.all_changed_plugins }}; do
npm run test-php:$PLUGIN -- -- -- --coverage-clover=./single-site-reports/coverage-$PLUGIN.xml
done
Comment on lines +147 to +149
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The script uses unquoted variable expansion in the for loops (${{ steps.changed-plugins.outputs.all_changed_plugins }}), which could cause issues if plugin names contain spaces or special characters. While plugin names in this repository don't have spaces, it's a best practice to quote these expansions for robustness.

Copilot uses AI. Check for mistakes.
else
npm run test-php
for PLUGIN in ${{ steps.changed-plugins.outputs.all_changed_plugins }}; do
npm run test-php:$PLUGIN
done
fi
- name: Running multisite unit tests
run: |
if [ "${{ matrix.coverage }}" == "true" ]; then
npm run test-php-multisite:performance-lab -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-performance-lab.xml
npm run test-php-multisite:auto-sizes -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-auto-sizes.xml
npm run test-php-multisite:dominant-color-images -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-dominant-color-images.xml
npm run test-php-multisite:embed-optimizer -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-embed-optimizer.xml
npm run test-php-multisite:image-prioritizer -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-image-prioritizer.xml
npm run test-php-multisite:optimization-detective -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-optimization-detective.xml
npm run test-php-multisite:speculation-rules -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-speculation-rules.xml
npm run test-php-multisite:view-transitions -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-view-transitions.xml
npm run test-php-multisite:web-worker-offloading -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-web-worker-offloading.xml
npm run test-php-multisite:webp-uploads -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-webp-uploads.xml
for PLUGIN in ${{ steps.changed-plugins.outputs.all_changed_plugins }}; do
npm run test-php-multisite:$PLUGIN -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-$PLUGIN.xml
done
else
npm run test-php-multisite
for PLUGIN in ${{ steps.changed-plugins.outputs.all_changed_plugins }}; do
npm run test-php-multisite:$PLUGIN
done
fi
- name: Upload single site coverage reports to Codecov
- name: Download Codecov CLI
if: ${{ matrix.coverage == true }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./single-site-reports
flags: single
name: ${{ matrix.php }}-single-site-coverage
fail_ci_if_error: true
- name: Upload multisite coverage reports to Codecov
run: |
# Create a temporary directory for GPG operations
mkdir -p .gpg

curl https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --homedir .gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://cli.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpg --homedir .gpg --no-default-keyring --keyring trustedkeys.gpg --verify codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x codecov
Comment on lines +166 to +178
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The codecov CLI verification steps create a .gpg directory but don't clean it up afterward. This could leave sensitive keyring files on the runner. Add a cleanup step or use the system's default GPG directory instead.

Copilot uses AI. Check for mistakes.
- name: Upload coverage reports to Codecov
if: ${{ matrix.coverage == true }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./multisite-reports
flags: multisite
name: ${{ matrix.php }}-multisite-coverage
fail_ci_if_error: true
run: |
# Build common arguments for all uploads
cc_args=()
cc_args+=(--fail-on-error)
cc_args+=(--disable-search)
cc_args+=(--git-service github)
cc_args+=(--gcov-executable "gcov")

# Add SHA for PRs
if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
cc_args+=(--sha "${{ github.event.pull_request.head.sha }}")
fi

# Handle authentication differently for forks vs. internal PRs
if [ -n "${{ github.event.pull_request.head.repo.full_name }}" ] && \
[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "::notice::Processing PR from fork - using tokenless upload with branch override."
cc_args+=(--branch "${{ github.event.pull_request.head.label }}")
else
echo "::notice::Processing internal PR or push - using token."
cc_args+=(--token "${{ secrets.CODECOV_TOKEN }}")
fi

# Upload reports for each changed plugin
for PLUGIN in ${{ steps.changed-plugins.outputs.all_changed_plugins }}; do
echo "::group::Uploading coverage for plugin: $PLUGIN"
./codecov upload-coverage "${cc_args[@]}" \
--file ./single-site-reports/coverage-$PLUGIN.xml \
--file ./multisite-reports/coverage-multisite-$PLUGIN.xml \
--flag $PLUGIN \
--name $PLUGIN-coverage
Comment on lines +207 to +211
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The codecov upload command assumes that coverage files exist for all changed plugins, but if a test execution fails for any plugin, the corresponding coverage file won't be generated. This will cause the upload to fail with --fail-on-error. Consider checking if files exist before attempting to upload them, or handle missing files gracefully.

Suggested change
./codecov upload-coverage "${cc_args[@]}" \
--file ./single-site-reports/coverage-$PLUGIN.xml \
--file ./multisite-reports/coverage-multisite-$PLUGIN.xml \
--flag $PLUGIN \
--name $PLUGIN-coverage
single_site_report="./single-site-reports/coverage-$PLUGIN.xml"
multisite_report="./multisite-reports/coverage-multisite-$PLUGIN.xml"
files=()
if [ -f "$single_site_report" ]; then
files+=(--file "$single_site_report")
else
echo "::warning::Single-site coverage report not found for plugin '$PLUGIN' at '$single_site_report'."
fi
if [ -f "$multisite_report" ]; then
files+=(--file "$multisite_report")
else
echo "::warning::Multisite coverage report not found for plugin '$PLUGIN' at '$multisite_report'."
fi
if [ ${#files[@]} -eq 0 ]; then
echo "::warning::No coverage reports found for plugin '$PLUGIN'. Skipping Codecov upload for this plugin."
echo "::endgroup::"
continue
fi
./codecov upload-coverage "${cc_args[@]}" "${files[@]}" \
--flag "$PLUGIN" \
--name "$PLUGIN-coverage"

Copilot uses AI. Check for mistakes.
echo "::endgroup::"
done
42 changes: 41 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,48 @@ coverage:
target: auto
threshold: 80%
base: auto
branches:
- trunk
informational: true
patch:
default:
threshold: 80%
threshold: 20%
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The patch threshold was lowered from 80% to 20%, which is a significant decrease that could allow code with poor test coverage to be merged. This change should be documented in the PR description or reconsidered, as it represents a substantial reduction in code quality standards.

Suggested change
threshold: 20%
threshold: 80%

Copilot uses AI. Check for mistakes.
informational: true
comment:
hide_comment_details: true
hide_project_coverage: false
show_carryforward_flags: true
Copy link
Contributor Author

@ShyamGadde ShyamGadde Mar 19, 2025

Choose a reason for hiding this comment

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

@westonruter Would you prefer that we display the carried forward flags in the PR comment, as shown below, or would you rather exclude them?

image

Ref: https://docs.codecov.com/docs/carryforward-flags#advanced-configuring-carryforward-flags-in-the-code-host

Copy link
Member

Choose a reason for hiding this comment

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

I suppose it doesn't hurt to include?

flag_management:
default_rules:
carryforward: true
individual_flags:
- name: auto-sizes
paths:
- plugins/auto-sizes/
- name: dominant-color-images
paths:
- plugins/dominant-color-images/
- name: embed-optimizer
paths:
- plugins/embed-optimizer/
- name: image-prioritizer
paths:
- plugins/image-prioritizer/
- name: optimization-detective
paths:
- plugins/optimization-detective/
- name: performance-lab
paths:
- plugins/performance-lab/
- name: speculation-rules
paths:
- plugins/speculation-rules/
- plugins/web-worker-offloading/
- name: view-transitions
paths:
- plugins/view-transitions/
- name: web-worker-offloading
paths:
- name: webp-uploads
paths:
- plugins/webp-uploads/
Loading