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
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ jobs:
continue-on-error: true # Since we expect it to always fail for the test plugin.
with:
build-dir: 'tests/fixtures/plugin-with-dependencies'

- name: Run plugin check (strict)
uses: ./
continue-on-error: true # Since we expect it to always fail for the test plugin.
with:
build-dir: 'tests/fixtures/plugin-with-dependencies'
ignore-errors: true
strict: true
47 changes: 43 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,34 @@ inputs:
description: 'WordPress version to use'
required: false
default: 'latest'
severity:
description: 'Severity level'
required: false
default: ''
error-severity:
description: 'Error severity level'
required: false
default: ''
warning-severity:
description: 'Warning severity level'
required: false
default: ''
include-low-severity-errors:
description: 'Include errors with lower severity than the threshold as other type.'
required: false
default: ''
include-low-severity-warnings:
description: 'Include warnings with lower severity than the threshold as other type.'
required: false
default: ''
slug:
description: 'Slug to override the default'
required: false
default: ''
strict:
description: 'Treat everything as an error'
required: false
default: 'false'
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -76,8 +104,6 @@ runs:

npm -g --no-fund i @wordpress/env
wp-env start --update

wp-env run cli wp cli info
shell: bash
env:
WP_VERSION: ${{ inputs.wp-version == 'trunk' && '"WordPress/WordPress#master"' || 'null' }}
Expand All @@ -89,12 +115,16 @@ runs:
CATEGORIES="${CATEGORIES//$'\n'/,}"
EXCLUDE_FILES="${EXCLUDE_FILES//$'\n'/,}"
EXCLUDE_DIRS="${EXCLUDE_DIRS//$'\n'/,}"
ADDITIONAL_ARGS="$CHECKS $EXCLUDE_CHECKS $CATEGORIES $IGNORE_WARNINGS $IGNORE_ERRORS $INCLUDE_EXPERIMENTAL $EXCLUDE_FILES $EXCLUDE_DIRS"
ADDITIONAL_ARGS="$CHECKS $EXCLUDE_CHECKS $CATEGORIES $IGNORE_WARNINGS $IGNORE_ERRORS $INCLUDE_EXPERIMENTAL $EXCLUDE_FILES $EXCLUDE_DIRS $SEVERITY $ERROR_SEVERITY $WARNING_SEVERITY $INCLUDE_LOW_SEVERITY_ERRORS $INCLUDE_LOW_SEVERITY_WARNINGS $SLUG"

# Debugging information
echo "::group::Debugging information"
wp-env run cli wp cli info
wp-env run cli wp plugin list
wp-env run cli wp plugin list-checks
wp-env run cli wp plugin list-check-categories
echo "::endgroup::"

echo "::group::Install dependencies"

# List all dependencies
wp-env run cli wp plugin get $PLUGIN_SLUG --field=requires_plugins
Expand All @@ -107,6 +137,8 @@ runs:
# Install all dependencies first.
wp-env run cli wp plugin install --activate $DEPENDENCIES
fi;

echo "::endgroup::"

wp-env run cli wp plugin activate $PLUGIN_SLUG

Expand All @@ -122,10 +154,17 @@ runs:
IGNORE_WARNINGS: ${{ inputs.ignore-warnings == 'true' && '--ignore-warnings' || '' }}
IGNORE_ERRORS: ${{ inputs.ignore-errors == 'true' && '--ignore-errors' || '' }}
INCLUDE_EXPERIMENTAL: ${{ inputs.include-experimental == 'true' && '--include-experimental' || '' }}
SEVERITY: ${{ inputs.severity && format('--severity={0}', inputs.severity) || '' }}
ERROR_SEVERITY: ${{ inputs.error-severity && format('--error-severity={0}', inputs.error-severity) || '' }}
WARNING_SEVERITY: ${{ inputs.warning-severity && format('--warning-severity={0}', inputs.warning-severity) || '' }}
INCLUDE_LOW_SEVERITY_ERRORS: ${{ inputs.include-low-severity-errors == 'true' && '--include-low-severity-errors' || '' }}
INCLUDE_LOW_SEVERITY_WARNINGS: ${{ inputs.include-low-severity-warnings == 'true' && '--include-low-severity-warnings' || '' }}
SLUG: ${{ inputs.slug && format('--slug={0}', inputs.slug) || '' }}

- name: Process results
run: |
node ${{ github.action_path }}/dist/index.js ${{ runner.temp }}/plugin-check-results.txt
shell: bash
env:
INPUT_REPO_TOKEN: ${{ inputs.repo-token }}
STRICT: ${{ inputs.strict }}
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ for (let i = 0; i < fileContents.length - 1; i++) {
const fileName = line.split('FILE: ')[1];
const results: Result[] = JSON.parse(fileContents[++i]) || [];

if (results.length > 0 && process.env.STRICT === 'true') {
process.exitCode = 1;
}

for (const result of results) {
if (result.type === 'ERROR') {
process.exitCode = 1;
}
const func = result.type === 'ERROR' ? error : warning;
const func =
result.type === 'ERROR' || process.env.STRICT === 'true'
? error
: warning;
func(result.message, {
title: result.code,
file: fileName,
Expand Down