-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (151 loc) · 6.07 KB
/
Copy pathci.yml
File metadata and controls
175 lines (151 loc) · 6.07 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
php-lint:
name: PHP lint (${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Lint PHP files
run: php tools/lint-php.php
unit-tests:
name: PHPUnit (${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '8.2'
- '8.3'
- '8.4'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
- name: Validate Composer metadata
run: composer validate --strict
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Run PHPUnit
run: composer test
plugin-check:
name: WordPress Plugin Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build runtime plugin directory
run: |
mkdir -p plugin-check-build/mikesoft-teamvault
rsync -a ./ plugin-check-build/mikesoft-teamvault/ \
--exclude='.git' \
--exclude='.github' \
--exclude='.gitignore' \
--exclude='.phpunit.cache' \
--exclude='.wordpress-org' \
--exclude='AGENTS.md' \
--exclude='CONTRIBUTING.md' \
--exclude='README.md' \
--exclude='SECURITY.md' \
--exclude='composer.json' \
--exclude='composer.lock' \
--exclude='docs' \
--exclude='plugin-check-build' \
--exclude='tests' \
--exclude='tools' \
--exclude='vendor'
# Plugin Check is run inline instead of via wordpress/plugin-check-action@v1.
# That action injects plugin-check as a URL plugin in .wp-env.json, which triggers an
# upstream @wordpress/env bug on the ubuntu-24.04 runner image (Node 24.16 / libuv
# 1.52.1): wp-env exits 0 without starting Docker, so the check reports
# "Environment not initialized". Installing plugin-check via WP-CLI after wp-env start
# avoids the broken URL-download path. See WordPress/plugin-check-action#579.
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Configure wp-env (no URL plugins)
run: |
PLUGIN_DIR="$(realpath plugin-check-build/mikesoft-teamvault)"
printf '{ "core": null, "plugins": [], "mappings": { "wp-content/plugins/mikesoft-teamvault": "%s" } }\n' "$PLUGIN_DIR" > .wp-env.json
cat .wp-env.json
npm -g --no-fund install @wordpress/env
- name: Start wp-env
uses: nick-fields/retry@v4
with:
timeout_minutes: 10
max_attempts: 3
shell: bash
command: wp-env start --update
- name: Run WordPress Plugin Check
run: |
wp-env run cli wp cli info
wp-env run cli wp plugin install plugin-check --activate
wp-env run cli wp plugin activate mikesoft-teamvault
set +e
wp-env run cli wp plugin check mikesoft-teamvault \
--format=json --slug=mikesoft-teamvault \
--require=./wp-content/plugins/plugin-check/cli.php > "$RUNNER_TEMP/pc.json"
CHECK_EXIT=$?
set -e
echo "wp plugin check exit: $CHECK_EXIT"
echo "----- Plugin Check results -----"
cat "$RUNNER_TEMP/pc.json" || true
echo ""
RESULTS="$RUNNER_TEMP/pc.json" CHECK_EXIT="$CHECK_EXIT" node <<'NODE'
const fs = require('fs');
let raw = '';
try { raw = fs.readFileSync(process.env.RESULTS, 'utf8'); } catch (e) {}
const checkExit = parseInt(process.env.CHECK_EXIT || '0', 10);
const trimmed = raw.trim();
// With --format=json WP-CLI still prints a plain "Success: ... No errors found." line
// (not a JSON array) when there are no findings. Treat that as a pass.
if (/no errors found/i.test(trimmed) || /^success:/i.test(trimmed)) {
console.log(trimmed || 'Plugin Check: no issues.');
process.exit(0);
}
if (trimmed === '') {
if (checkExit !== 0) { console.error('Plugin Check produced no output and exited ' + checkExit + ' — treating as failure.'); process.exit(2); }
console.log('Plugin Check: no issues.'); process.exit(0);
}
let data;
try { data = JSON.parse(trimmed); } catch (e) { console.error('Plugin Check output is neither a success message nor valid JSON — the check did not run correctly:'); console.error(trimmed.slice(0, 1000)); process.exit(2); }
let items = Array.isArray(data) ? data : [];
if (!Array.isArray(data) && data && typeof data === 'object') {
for (const k in data) { if (Array.isArray(data[k])) items = items.concat(data[k]); }
}
const errs = items.filter((x) => x && String(x.type || '').toUpperCase() === 'ERROR');
const warns = items.filter((x) => x && String(x.type || '').toUpperCase() === 'WARNING');
console.log('Plugin Check: ' + errs.length + ' error(s), ' + warns.length + ' warning(s).');
for (const e of errs.slice(0, 50)) { console.log('ERROR ' + (e.code || '') + ' ' + (e.file || '') + ':' + (e.line || '') + ' ' + (e.message || '')); }
if (errs.length > 0) { console.error('::error::WordPress Plugin Check reported ' + errs.length + ' error(s).'); process.exit(1); }
console.log('Plugin Check passed (no errors).');
NODE