Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions %plugin_name%.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Plugin Name: %plugin_name%
* Plugin URI: %plugin_uri%
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/harness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Harness

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions: {}

jobs:
harness:
uses: Pollora/harness/.github/workflows/template.yml@v0.1.11
with:
mode: enforce
permissions:
contents: read
14 changes: 7 additions & 7 deletions bin/ci/check-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function test(string $name, callable $fn): void

try {
$result = $fn();
} catch (\Throwable $e) {
} catch (Throwable $e) {
echo " \033[31m✗\033[0m {$name} — {$e->getMessage()}\n";
$failed++;

Expand All @@ -97,7 +97,7 @@ function run(string $command): array
$process = proc_open($command.' 2>&1', $descriptors, $pipes);

if (! is_resource($process)) {
throw new \RuntimeException("could not run: {$command}");
throw new RuntimeException("could not run: {$command}");
}

$out = stream_get_contents($pipes[1]) ?: '';
Expand All @@ -112,7 +112,7 @@ function wpEval(string $php): string
$result = run('wp eval '.escapeshellarg($php));

if ($result['code'] !== 0) {
throw new \RuntimeException("wp eval failed: {$result['out']}");
throw new RuntimeException("wp eval failed: {$result['out']}");
}

return $result['out'];
Expand Down Expand Up @@ -176,14 +176,14 @@ function ensureActiveTheme(): void
.' --theme-version=1.0.0 --no-interaction');

if ($scaffold['code'] !== 0) {
throw new \RuntimeException("could not scaffold a theme: {$scaffold['out']}");
throw new RuntimeException("could not scaffold a theme: {$scaffold['out']}");
}

$installed = array_values(array_filter(explode("\n", run('wp theme list --field=name')['out'])));
}

if ($installed === []) {
throw new \RuntimeException('the site still has no theme after scaffolding one');
throw new RuntimeException('the site still has no theme after scaffolding one');
}

$active = run('wp theme list --status=active --field=name')['out'];
Expand All @@ -195,7 +195,7 @@ function ensureActiveTheme(): void
$activated = run('wp theme activate '.escapeshellarg($installed[0]));

if ($activated['code'] !== 0) {
throw new \RuntimeException("could not activate {$installed[0]}: {$activated['out']}");
throw new RuntimeException("could not activate {$installed[0]}: {$activated['out']}");
}
}

Expand All @@ -210,7 +210,7 @@ function pluginsDirectory(): string
$path = wpEval('echo WP_PLUGIN_DIR;');

if ($path === '' || ! is_dir($path)) {
throw new \RuntimeException("WP_PLUGIN_DIR is {$path}, which does not exist");
throw new RuntimeException("WP_PLUGIN_DIR is {$path}, which does not exist");
}

return $path;
Expand Down
2 changes: 1 addition & 1 deletion bin/replacements.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* placeholder the scaffolder does not substitute": a key that disappears here
* or a token that appears in the template without a key both fail it.
*
* @return array<string, string> placeholder => a plausible substituted value
* @return array<string, string> placeholder => a plausible substituted value
*/
function scaffolderReplacements(string $name = 'my-plugin'): array
{
Expand Down
6 changes: 3 additions & 3 deletions bin/tests/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function scaffoldedPluginFile(): string
$source = pluginPath('%plugin_name%.php');

if (! is_file($source)) {
throw new \RuntimeException('the template has no %plugin_name%.php — the main file was renamed');
throw new RuntimeException('the template has no %plugin_name%.php — the main file was renamed');
}

$replacements = scaffolderReplacements(TEST_SLUG);
Expand Down Expand Up @@ -131,7 +131,7 @@ function checkRegistrationGuard(): void

return str_starts_with($result['out'], 'pollora_register:plugin:'.TEST_SLUG)
? true
: "expected pollora_register:plugin:".TEST_SLUG.", got '{$result['out']}'";
: 'expected pollora_register:plugin:'.TEST_SLUG.", got '{$result['out']}'";
});

test('Framework >= 13.32: does not also call the registrar', function () {
Expand All @@ -151,7 +151,7 @@ function checkRegistrationGuard(): void

return str_starts_with($result['out'], 'registrar::register:'.TEST_SLUG)
? true
: "expected registrar::register:".TEST_SLUG.", got '{$result['out']}'";
: 'expected registrar::register:'.TEST_SLUG.", got '{$result['out']}'";
});

test('Neither is available: leaves the plugin unregistered, without a fatal', function () {
Expand Down
2 changes: 1 addition & 1 deletion bin/tests/contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
const CODE_NAMES = ['pollora-demo-plugin', 'PolloraDemoPlugin', 'pollora_demo_plugin', 'POLLORA_DEMO_PLUGIN'];

/**
* @return array<int, string> every shipped file, repository-relative
* @return array<int, string> every shipped file, repository-relative
*/
function shippedFiles(): array
{
Expand Down
5 changes: 2 additions & 3 deletions bin/tests/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* A check returns true (pass), or a string explaining the failure. There is no
* skip: a check that cannot fail is the defect this suite exists to prevent.
*/

final class Results
{
public static int $passed = 0;
Expand All @@ -35,7 +34,7 @@ function test(string $name, callable $fn): void
{
try {
$result = $fn();
} catch (\Throwable $e) {
} catch (Throwable $e) {
echo " \033[31m✗\033[0m {$name} — {$e->getMessage()}\n";
Results::$failed++;

Expand Down Expand Up @@ -99,7 +98,7 @@ function phpRun(string $code): array
if (! is_resource($process)) {
unlink($file);

throw new \RuntimeException('could not start a PHP process');
throw new RuntimeException('could not start a PHP process');
}

$out = stream_get_contents($pipes[1]) ?: '';
Expand Down
Loading