A GitHub action to run Plugin Check against your plugin.
Results are posted as file annotations.
See action.yml
- uses: wordpress/plugin-check-action@v1with:
# Personal access token (PAT) used to comment on pull requests.# Not currently used.## [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)## Default: ${{ github.token }}repo-token: ''# Build directory of your plugin.# Defaults to current directory / repository root.## Default: './'build-dir: ''# List of checks to run.# Each check should be separated with new lines.# Examples: i18n_usage, file_type, late_escaping.# By default, all checks are run.## Default: ''checks: ''# List of checks to exclude from running.# Each check should be separated with new lines.# Examples: i18n_usage, file_type, late_escaping.# Applies after the `checks` input.## Default: ''exclude-checks: ''# List of error codes to ignore.# Each error code should be separated with new lines.# Examples: textdomain_mismatch, WordPress.Security.EscapeOutput.OutputNotEscaped.## Default: ''ignore-codes: ''# List of categories to limit checks to.# Each category should be separated with new lines.# Examples: general, security# By default, checks in all categories are run.## Default: ''categories: ''# List of files (file paths) to exclude from checks.# Each file should be separated with new lines.## Default: ''exclude-files: ''# List of directories to exclude from checks.# Each directory should be separated with new lines.## Default: ''exclude-directories: ''# Whether to ignore warnings reported by Plugin Check.## Default: falseignore-warnings: ''# Whether to ignore errors reported by Plugin Check.## Default: falseignore-errors: ''# Whether to include experimental checks.## Default: trueinclude-experimental: ''# WordPress version to use. Supports "latest" or "trunk".## Default: latestwp-version: ''# Severity level.## Default: ''severity: ''# Error severity level.## Default: ''error-severity:
# Warning severity level.## Default: ''warning-severity:
# Include errors with lower severity than the threshold as other type.## Default: ''include-low-severity-errors: ''# Include warnings with lower severity than the threshold as other type.## Default: ''include-low-severity-warnings: ''# Slug to override the default.## Default: ''slug:
# Treat everything as an error.## Default: falsestrict: ''The simplest way to get up and running with your plugin.
Add a workflow (.github/workflows/build-test.yml):
name: 'build-test'on: # rebuild any PRs and main branch changespull_request:
push:
branches:
- main
- 'releases/*'jobs:
test:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v3
- name: Run plugin checkuses: wordpress/plugin-check-action@v1The basic example above covers many use cases, but sometimes plugins can be a bit more complex and involve some sort of build process. Also, if you already use tools like PHPCS, you might want to skip the PHPCS-based checks from Plugin Check but focus on the ones that are more useful for you.
steps:
- name: Checkoutuses: actions/checkout@v3# Here's where you would run your custom build process# ...# ...
- name: Build pluginrun: npm run build
- name: Run plugin checkuses: wordpress/plugin-check-action@v1with:
build-dir: './my-awesome-plugin'exclude-directories: 'prefixed_vendor_dir,another_dir_to_ignore'categories: | performance accessibilityA common build step involves the wp dist-archive command.
In combination with Plugin Check it could be used like this:
steps:
- name: Checkoutuses: actions/checkout@v3# Here's where you would run your custom build process# ...# ...
- name: Setup PHPuses: shivammathur/setup-php@v2with:
php-version: latestcoverage: nonetools: wp-cli
- name: Install latest version of dist-archive-commandrun: wp package install wp-cli/dist-archive-command:@stable
- name: Build pluginrun: | wp dist-archive . ./my-awesome-plugin.zip mkdir tmp-build unzip my-awesome-plugin.zip -d tmp-build - name: Run plugin checkuses: wordpress/plugin-check-action@v1.0.6with:
build-dir: './tmp-build/my-awesome-plugin'At the time of writing, the following checks exist:
i18n_usagecode_obfuscationdirect_db_queriesenqueued_scripts_in_footerenqueued_scripts_sizeenqueued_styles_scopefile_typelate_escapinglocalhostno_unfiltered_uploadsperformant_wp_query_paramsplugin_header_text_domainplugin_readmeplugin_review_phpcsplugin_updatertrademarks
At the time of writing, the following categories exist:
accessibilitygeneralperformanceplugin_reposecurity