-
Notifications
You must be signed in to change notification settings - Fork 6
/
action.yml
131 lines (119 loc) · 4.69 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
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'
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
wp-env run cli wp cli info
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"
# Debugging information
wp-env run cli wp plugin list
wp-env run cli wp plugin list-checks
wp-env run cli wp plugin list-check-categories
# 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;
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' || '' }}
- 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 }}