-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaction.yml
170 lines (157 loc) · 6.37 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: 'WordPress Plugin Check'
description: 'Test your WordPress plugin with Plugin Check'
author: 'Pascal Birchler'
branding:
color: 'blue'
icon: 'trending-up'
inputs:
repo-token:
description: 'The GITHUB_TOKEN secret'
required: false
default: ${{ github.token }}
build-dir:
description: 'Build directory'
required: false
default: './'
checks:
description: 'Only run specific checks'
required: false
default: ''
exclude-checks:
description: 'Checks to exclude'
required: false
default: ''
categories:
description: 'Limit checks to specific categories'
required: false
default: ''
exclude-files:
description: 'Exclude certain files from checks'
required: false
default: ''
exclude-directories:
description: 'Exclude certain directories from checks'
required: false
default: ''
ignore-warnings:
description: 'Ignore warnings'
required: false
default: 'false'
ignore-errors:
description: 'Ignore errors'
required: false
default: 'false'
include-experimental:
description: 'Include experimental checks'
required: false
default: 'false'
wp-version:
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:
- name: Set up Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: '20'
- name: Set PLUGIN_DIR
run: |
PLUGIN_DIR=$(realpath "$BUILD_DIR")
echo "PLUGIN_DIR=$PLUGIN_DIR" >> "$GITHUB_ENV"
PLUGIN_SLUG=$(basename $PLUGIN_DIR)
echo "PLUGIN_SLUG=$PLUGIN_SLUG" >> "$GITHUB_ENV"
shell: bash
env:
BUILD_DIR: ${{ inputs.build-dir }}
- name: Setup wp-env
run: |
touch .wp-env.json
> .wp-env.json
echo "{ \"core\": $WP_VERSION, \"port\": 8880, \"testsPort\": 8881, \"plugins\": [ \"https://downloads.wordpress.org/plugin/plugin-check.latest-stable.zip\" ], \"mappings\": { \"wp-content/plugins/$PLUGIN_SLUG\": \"$PLUGIN_DIR\" } }" >> .wp-env.json
npm -g --no-fund i @wordpress/env
wp-env start --update
shell: bash
env:
WP_VERSION: ${{ inputs.wp-version == 'trunk' && '"WordPress/WordPress#master"' || 'null' }}
- name: Run Plugin Check
run: |
CHECKS="${CHECKS//$'\n'/,}"
EXCLUDE_CHECKS="${EXCLUDE_CHECKS//$'\n'/,}"
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 $SEVERITY $ERROR_SEVERITY $WARNING_SEVERITY $INCLUDE_LOW_SEVERITY_ERRORS $INCLUDE_LOW_SEVERITY_WARNINGS $SLUG"
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
DEPENDENCIES=$(wp-env run cli wp plugin get $PLUGIN_SLUG --field=requires_plugins | tr ',' ' ')
if [ -z "$DEPENDENCIES" ]; then
echo "Plugin has no dependencies"
else
echo "Installing plugin dependencies: $DEPENDENCIES"
# 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
# Run Plugin Check
wp-env run cli wp plugin check $PLUGIN_SLUG --format=json $ADDITIONAL_ARGS --require=./wp-content/plugins/plugin-check/cli.php > ${{ runner.temp }}/plugin-check-results.txt
shell: bash
env:
CHECKS: ${{ inputs.checks && format('--checks={0}', inputs.checks) || '' }}
EXCLUDE_CHECKS: ${{ inputs.exclude-checks && format('--exclude-checks={0}', inputs.exclude-checks) || '' }}
CATEGORIES: ${{ inputs.categories && format('--categories={0}', inputs.categories) || '' }}
EXCLUDE_FILES: ${{ inputs.exclude-files && format('--exclude-files={0}', inputs.exclude-files) || '' }}
EXCLUDE_DIRS: ${{ inputs.exclude-directories && format('--exclude-directories={0}', inputs.exclude-directories) || '' }}
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 }}