Skip to content

Conversation

desrosj
Copy link
Member

@desrosj desrosj commented Jul 23, 2025

Proposed changes

This makes some follow up adjustments to the PHP linting workflow after #176.

The linting workflow currently tries to pass the list of edited files to the phpcs command. This is causing an issue because the list of files output by the earlier step is a space separated list with each file surrounded in single quotes. Enclosing the list in double quotes to guard against possible security vulnerabilities is making phpcs read it as one file name.

The step responsible for generating a list of modified files is also configured incorrectly causing all modified files to be passed resulting in the workflow always running. Because path filtering is being used at the workflow level for the push events, this third party action is not required (it has actually been archived and abandoned upstream).

If a pull request is required to make a change to the code base, It's reasonable to assume that the branch was free of violations prior to creation. Because of this, it's fine to run the scan on the whole project. However, there are a few modifications that can also be made for performance and effectiveness:

  • The The phpcs.xml file has been updated to accurately reflect the PHP and WordPress versions supported through the testVersion and minimum_supported_wp_version configuration settings, respectively.
  • By default, running phpcs will now scan all PHP files in the repository except those explicitly excluded through an <exclude-patter> in the phpcs.xml file (which have been expanded to avoid scanning the vendor and node_modules directories).
  • Caching between phpcs runs has been configured locally.
  • When run within GitHub Actions, the results of the scan will be cached using actions/cache. The cache is keyed by the hash of the composer.lock and phpcs.xml files which control the behavior of phpcs, but an additional date value is included to ensure the cache is flushed at least once a week if those files don't change.
  • Configuring Composer and installing dependencies is now handled by ramsey/composer-install, which handles caching and composer validate under the hood. Previously, there were unique steps in the linting workflow for this.
  • Path filtering for push and pull_request events has been expanded to also include files that may affect the results of phpcs.
  • Both path filtering and technote-space/get-diff-action are not required. The former has been archived, so removing this dependency is desired.
  • Errors produced by a phpcs scan are now displayed contextually as annotations within pull requests and commits.
  • Several warnings flagging unused variables have been addressed.

Type of Change

Production

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update
  • Refactoring / housekeeping (changes to files not directly related to functionality)

Development

  • Tests
  • Dependency update
  • Environment update / refactoring
  • Documentation Update

Visual

Checklist

  • I have read the CONTRIBUTING doc
  • I have viewed my change in a web-browser
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@desrosj desrosj self-assigned this Jul 23, 2025
@desrosj desrosj marked this pull request as ready for review July 23, 2025 21:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the PHP linting workflow by addressing configuration issues and improving performance. The main changes include updating PHPCS configuration, removing unused function parameters that were causing linting violations, and overhauling the GitHub Actions workflow to use modern caching strategies.

  • Updates PHP and WordPress version requirements in PHPCS configuration
  • Removes unused parameters from several functions to fix linting violations
  • Replaces problematic file-based linting with full project scans and improved caching

Reviewed Changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
phpcs.xml Updates PHP/WP versions, adds caching, expands exclusions and scan scope
inc/partners.php Removes unused $network_activation parameter from plugin_activated function
inc/base.php Removes unused $install_date parameter from bluehost_install_date_filter function
inc/GoogleSiteKit.php Removes unused $expiration and $transient parameters from transient handler
.github/workflows/lint.yml Overhauls workflow to use modern caching, removes deprecated actions, adds result annotations
.distignore Excludes new .cache directory from distribution

@desrosj desrosj merged commit 8e0996d into main Jul 23, 2025
33 of 63 checks passed
@desrosj desrosj deleted the fix/php-linting branch July 23, 2025 22:11
@circlecube circlecube added this to the August 6, 2025 Release milestone Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants