Skip to content

Commit 271ad63

Browse files
authored
Avoid wp-env silent startup failures when loading Plugin Check (#590)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 097ee50 commit 271ad63

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

action.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ runs:
111111
run: |
112112
touch .wp-env.json
113113
> .wp-env.json
114-
echo "{ \"core\": $WP_VERSION, \"port\": 8880, \"testsPort\": 8881, \"plugins\": [ \"https://downloads.wordpress.org/plugin/plugin-check.zip\" ], \"mappings\": { \"wp-content/plugins/$PLUGIN_SLUG\": \"$PLUGIN_DIR\" } }" >> .wp-env.json
114+
echo "{ \"core\": $WP_VERSION, \"port\": 8880, \"testsPort\": 8881, \"mappings\": { \"wp-content/plugins/$PLUGIN_SLUG\": \"$PLUGIN_DIR\" } }" >> .wp-env.json
115115
116116
npm -g --no-fund i @wordpress/env
117117
shell: bash
@@ -124,7 +124,9 @@ runs:
124124
timeout_minutes: 10
125125
max_attempts: 3
126126
shell: bash
127-
command: wp-env start --update
127+
command: |
128+
wp-env start --update
129+
wp-env run cli wp cli info
128130
129131
- name: Run Plugin Check
130132
run: |
@@ -146,6 +148,16 @@ runs:
146148
147149
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"
148150
151+
echo "::group::Install Plugin Check"
152+
153+
if wp-env run cli wp plugin is-installed plugin-check; then
154+
wp-env run cli wp plugin activate plugin-check
155+
else
156+
wp-env run cli wp plugin install plugin-check --activate
157+
fi
158+
159+
echo "::endgroup::"
160+
149161
echo "::group::Debugging information"
150162
wp-env run cli wp cli info
151163
wp-env run cli wp plugin list

src/action.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { readFileSync } from 'node:fs';
3+
import { join } from 'node:path';
4+
5+
const actionYml = readFileSync(join(__dirname, '..', 'action.yml'), 'utf8');
6+
7+
describe('action.yml', () => {
8+
it('does not preload plugin-check from a download URL', () => {
9+
expect(actionYml).not.toContain('plugin-check.zip');
10+
expect(actionYml).toContain('wp plugin install plugin-check --activate');
11+
});
12+
13+
it('verifies wp-env after starting it', () => {
14+
expect(actionYml).toMatch(
15+
/command:\s*\|\s*wp-env start --update\s+wp-env run cli wp cli info/,
16+
);
17+
});
18+
});

0 commit comments

Comments
 (0)