Skip to content

Commit be28fa7

Browse files
committed
v1.1.0
1 parent a922c39 commit be28fa7

6 files changed

Lines changed: 102 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,14 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
php-tests:
18-
name: PHP 8.2 / CodeIgniter 4.3
17+
floor:
18+
name: PHP 8.2 / CodeIgniter 4.3.8
1919
runs-on: ubuntu-latest
2020

2121
steps:
2222
- name: Checkout code
2323
uses: actions/checkout@v4
2424

25-
- name: Checkout local Perfbase PHP SDK
26-
uses: actions/checkout@v4
27-
with:
28-
repository: perfbaseorg/php-sdk
29-
path: lib-php-sdk-src
30-
31-
- name: Link sibling SDK checkout
32-
run: ln -s "$GITHUB_WORKSPACE/lib-php-sdk-src" "$GITHUB_WORKSPACE/../lib-php-sdk"
33-
3425
- name: Set up PHP
3526
uses: shivammathur/setup-php@v2
3627
with:
@@ -50,3 +41,31 @@ jobs:
5041

5142
- name: Run PHPUnit
5243
run: composer run test -- --coverage-text
44+
45+
upper-bound:
46+
name: PHP 8.4 / CodeIgniter 4.7.2
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
53+
- name: Set up PHP
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: '8.4'
57+
coverage: none
58+
tools: composer
59+
extensions: pcntl
60+
61+
- name: Pin CodeIgniter 4.7.2
62+
run: composer require --no-update codeigniter4/framework:4.7.2
63+
64+
- name: Install dependencies
65+
run: composer update --prefer-dist --no-progress --no-interaction
66+
67+
- name: Run PHPStan
68+
run: composer run phpstan
69+
70+
- name: Run PHPUnit
71+
run: composer run test -- --no-coverage --do-not-fail-on-risky

.github/workflows/compatibility.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ jobs:
3838
- name: Checkout code
3939
uses: actions/checkout@v4
4040

41-
- name: Checkout local Perfbase PHP SDK
42-
uses: actions/checkout@v4
43-
with:
44-
repository: perfbaseorg/php-sdk
45-
path: lib-php-sdk-src
46-
47-
- name: Link sibling SDK checkout
48-
run: ln -s "$GITHUB_WORKSPACE/lib-php-sdk-src" "$GITHUB_WORKSPACE/../lib-php-sdk"
49-
5041
- name: Set up PHP
5142
uses: shivammathur/setup-php@v2
5243
with:

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Not supported in v1:
4141
- PHP `>=8.2 <8.5`
4242
- CodeIgniter `^4.3.8`
4343
- Perfbase PHP extension
44-
- `perfbase/php-sdk` `1.0.0`
44+
- `perfbase/php-sdk` `^1.0`
4545

4646
Optional:
4747

@@ -57,7 +57,7 @@ Install the package:
5757
composer require perfbase/codeigniter4
5858
```
5959

60-
For monorepo development, this package is already configured to use the local sibling SDK checkout via the path repository in `composer.json`.
60+
This package resolves `perfbase/php-sdk` from Packagist by default. If you need to test against an unpublished SDK branch in a monorepo, add a temporary Composer repository override locally instead of assuming a built-in path repository.
6161

6262
## Quick Start
6363

@@ -188,9 +188,16 @@ The doctor checks:
188188

189189
If worker mode is detected, the doctor also prints a reminder to restart workers after config or deployment changes.
190190

191-
## Compatibility Testing
191+
## Verification and Compatibility Testing
192192

193-
Normal package CI stays on the declared support floor. Older CodeIgniter 4 minors should be tested explicitly.
193+
Required PR CI stays intentionally small:
194+
195+
- PHP `8.2` / CodeIgniter `4.3.8`
196+
- PHP `8.4` / CodeIgniter `4.7.2`
197+
198+
Manual compatibility probes cover the wider declared CodeIgniter 4 range and are used when validating the support floor or widening support claims.
199+
200+
If you run local `composer install` on PHP `8.4`, Composer may resolve a newer compatible CodeIgniter release than the declared floor. Use `bin/test-compat` or the manual compatibility workflow when you need to verify the floor explicitly.
194201

195202
### Local Docker Compatibility Probes
196203

@@ -204,7 +211,7 @@ bin/test-compat --php 8.2 --framework 4.6.5
204211

205212
Notes:
206213

207-
- The script mounts the parent `projects/` directory so the local sibling `lib-php-sdk` path repository continues to work inside the container.
214+
- The script uses Packagist dependency resolution, matching the published package behavior.
208215
- `--ignore-php-platform` is intended for floor exploration when the package's current declared PHP floor is higher than the probe target.
209216
- The script runs `composer update`, `composer run phpstan`, and `composer run test` inside the selected container image.
210217

bin/test-compat

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
77
WORKSPACE_ROOT="$(cd "${REPO_ROOT}/.." && pwd)"
88

99
PHP_VERSION="${PHP_VERSION:-8.2}"
10-
FRAMEWORK_VERSION="${FRAMEWORK_VERSION:-4.6.5}"
10+
FRAMEWORK_VERSION="${FRAMEWORK_VERSION:-4.3.8}"
1111
RUN_PHPSTAN=1
1212
RUN_TESTS=1
1313
REBUILD_IMAGE=1
@@ -19,7 +19,7 @@ Usage: bin/test-compat [options]
1919
2020
Options:
2121
--php <version> PHP version for the container image. Default: 8.2
22-
--framework <version> CodeIgniter framework version to install. Default: 4.6.5
22+
--framework <version> CodeIgniter framework version to install. Default: 4.3.8
2323
--skip-phpstan Skip PHPStan.
2424
--skip-tests Skip PHPUnit.
2525
--ignore-php-platform Run Composer with --ignore-platform-req=php.
@@ -74,12 +74,21 @@ IMAGE_TAG="perfbase-codeigniter4-compat:php-${PHP_VERSION//./-}"
7474
CONFIGURE_COMMAND="composer config audit.block-insecure false"
7575
REQUIRE_COMMAND="composer require --no-interaction --no-progress --no-update codeigniter4/framework:${FRAMEWORK_VERSION}"
7676
UPDATE_COMMAND="composer update --with-all-dependencies --prefer-dist --no-progress --no-interaction"
77+
TMP_WORKDIR="/tmp/lib-codeigniter4-compat-${PHP_VERSION//./-}-${FRAMEWORK_VERSION//./-}-$RANDOM"
7778

7879
if [[ "${IGNORE_PHP_PLATFORM}" -eq 1 ]]; then
7980
UPDATE_COMMAND="${UPDATE_COMMAND} --ignore-platform-req=php"
8081
fi
8182

82-
COMMANDS=("${CONFIGURE_COMMAND}" "${REQUIRE_COMMAND}" "${UPDATE_COMMAND} codeigniter4/framework")
83+
COMMANDS=(
84+
"rm -rf ${TMP_WORKDIR}"
85+
"cp -R /workspace/lib-codeigniter4 ${TMP_WORKDIR}"
86+
"cd ${TMP_WORKDIR}"
87+
"rm -rf vendor composer.lock .phpunit.cache"
88+
"${CONFIGURE_COMMAND}"
89+
"${REQUIRE_COMMAND}"
90+
"${UPDATE_COMMAND}"
91+
)
8392

8493
if [[ "${RUN_PHPSTAN}" -eq 1 ]]; then
8594
COMMANDS+=("composer run phpstan")

src/Runtime/PerfbaseCommands.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010
class PerfbaseCommands extends Commands
1111
{
1212
/**
13+
* Mirrors CodeIgniter's Commands::run() behavior as closely as possible
14+
* while adding Perfbase-specific lifecycle events. If the supported
15+
* framework floor changes, compare this method against the upstream
16+
* implementation again before modifying it.
17+
*
1318
* @param array<int|string, string|null> $params
19+
* @return int|void
1420
*/
1521
public function run(string $command, array $params)
1622
{
1723
if (!$this->verifyCommand($command, $this->commands)) {
18-
return EXIT_ERROR;
24+
return;
1925
}
2026

2127
$className = $this->commands[$command]['class'];

tests/Unit/Runtime/PerfbaseCommandsTest.php

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,44 @@
1212

1313
final class PerfbaseCommandsTest extends TestCase
1414
{
15-
public function testRunReturnsErrorForUnknownCommand(): void
15+
public function testRunMatchesNativeBehaviorForUnknownCommand(): void
1616
{
17-
$commands = new PerfbaseCommands(service('logger'));
17+
$commands = new class (service('logger')) extends PerfbaseCommands {
18+
public bool $verifyCalled = false;
19+
20+
public function verifyCommand(string $command, array $commands): bool
21+
{
22+
$this->verifyCalled = true;
23+
24+
return false;
25+
}
26+
};
27+
$nativePreCalled = false;
28+
$nativePostCalled = false;
29+
$perfbasePreCalled = false;
30+
$perfbasePostCalled = false;
1831

19-
self::assertSame(EXIT_ERROR, $commands->run('missing:command', []));
32+
Events::on('pre_command', static function () use (&$nativePreCalled): void {
33+
$nativePreCalled = true;
34+
});
35+
Events::on('post_command', static function () use (&$nativePostCalled): void {
36+
$nativePostCalled = true;
37+
});
38+
Events::on('perfbase_pre_command', static function () use (&$perfbasePreCalled): void {
39+
$perfbasePreCalled = true;
40+
});
41+
Events::on('perfbase_post_command', static function () use (&$perfbasePostCalled): void {
42+
$perfbasePostCalled = true;
43+
});
44+
45+
$result = $commands->run('missing:command', []);
46+
47+
self::assertTrue($commands->verifyCalled);
48+
self::assertTrue($result === null);
49+
self::assertFalse($nativePreCalled);
50+
self::assertFalse($nativePostCalled);
51+
self::assertFalse($perfbasePreCalled);
52+
self::assertFalse($perfbasePostCalled);
2053
}
2154

2255
public function testRunPreservesNativeEventsAndAddsPerfbaseEventsForSuccess(): void
@@ -71,9 +104,13 @@ public function testRunDoesNotTriggerNativePostCommandOnFailure(): void
71104
],
72105
]);
73106

107+
$nativePreCalled = false;
74108
$nativePostCalled = false;
75109
$perfbasePostArgs = null;
76110

111+
Events::on('pre_command', static function () use (&$nativePreCalled): void {
112+
$nativePreCalled = true;
113+
});
77114
Events::on('post_command', static function () use (&$nativePostCalled): void {
78115
$nativePostCalled = true;
79116
});
@@ -86,6 +123,7 @@ public function testRunDoesNotTriggerNativePostCommandOnFailure(): void
86123
try {
87124
$commands->run('test:fail', []);
88125
} finally {
126+
self::assertTrue($nativePreCalled);
89127
self::assertFalse($nativePostCalled);
90128
self::assertIsArray($perfbasePostArgs);
91129
self::assertSame('test:fail', $perfbasePostArgs[0]);

0 commit comments

Comments
 (0)