-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathaction.yml
More file actions
227 lines (202 loc) · 8.14 KB
/
Copy pathaction.yml
File metadata and controls
227 lines (202 loc) · 8.14 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
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-codes:
description: 'Error codes to ignore'
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@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version: '24'
- 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"
# Check if .wp-env.json exists in the plugin directory before we create one
if [ -f "$PLUGIN_DIR/.wp-env.json" ]; then
echo "WP_ENV_JSON_EXISTS=true" >> "$GITHUB_ENV"
else
echo "WP_ENV_JSON_EXISTS=false" >> "$GITHUB_ENV"
fi
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, \"mappings\": { \"wp-content/plugins/$PLUGIN_SLUG\": \"$PLUGIN_DIR\" } }" >> .wp-env.json
npm -g --no-fund i @wordpress/env
shell: bash
env:
WP_VERSION: ${{ inputs.wp-version == 'trunk' && '"WordPress/WordPress#master"' || 'null' }}
- name: Start wp-env
uses: nick-fields/retry@v4
with:
timeout_minutes: 10
max_attempts: 3
shell: bash
command: |
wp-env start --update
wp-env run cli wp cli info
- 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'/,}"
IGNORE_CODES="${IGNORE_CODES//$'\n'/,}"
# Only exclude .wp-env.json if it was created by this action (didn't exist before)
if [ "$WP_ENV_JSON_EXISTS" = "false" ]; then
if [ -n "$EXCLUDE_FILES" ]; then
EXCLUDE_FILES="--exclude-files=${EXCLUDE_FILES#--exclude-files=},.wp-env.json"
else
EXCLUDE_FILES="--exclude-files=.wp-env.json"
fi
fi
ADDITIONAL_ARGS="$CHECKS $EXCLUDE_CHECKS $CATEGORIES $IGNORE_CODES $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::Install Plugin Check"
if wp-env run cli wp plugin is-installed plugin-check; then
wp-env run cli wp plugin activate plugin-check
else
wp-env run cli wp plugin install plugin-check --activate
fi
echo "::endgroup::"
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
echo "::group::Run Plugin Check"
# 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
cat ${{ runner.temp }}/plugin-check-results.txt
echo "::endgroup::"
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_CODES: ${{ inputs.ignore-codes && format('--ignore-codes={0}', inputs.ignore-codes) || '' }}
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 }}
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: ${{ always() }}
with:
name: plugin-check-results${{ inputs.slug && format('-{0}', inputs.slug) || '' }}
path: ${{ runner.temp }}/plugin-check-results.txt
if-no-files-found: ignore