DE-178815 Modernize CI: unstick runner, upgrade to PHP 8.2/8.4, green the suite - #41
DE-178815 Modernize CI: unstick runner, upgrade to PHP 8.2/8.4, green the suite#41jzajac-nice wants to merge 15 commits into
Conversation
GitHub retired the ubuntu-20.04 hosted runner image, so jobs requesting runs-on: ubuntu-20.04 queue indefinitely with no runner assigned. Switch to ubuntu-latest so CI is picked up again. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
actions/cache@v2 is hard-failed by GitHub, which surfaced once jobs stopped queueing. Bump cache and checkout to v4 and codecov to v4. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the retired PHP 7.2-8.1 matrix legs. PHPUnit now runs on 8.2 and 8.4; coding-style and PHPStan gates run on 8.2. Old legs no longer install anyway (aws/aws-sdk-php requires php >=8.1). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
php-cs-fixer 3.8.0 refuses to run on PHP 8.2. Match upstream ruflin/Elastica's pin (3.84.0), which supports up to PHP 8.4. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch docker/php/Dockerfile from php:7.2-fpm-alpine to the shared BrandEmbassy ECR php:8.2-debian-bullseye base (mirrors docker repo's platform-backend-dev/xdebug-8.2), so local dev matches the org toolchain and PHP version. Composer and required extensions come from the base. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Local gate run on PHP 8.2 — CI failures are pre-existing branch state, not the version bumpI reproduced all three gates locally on PHP 8.2 (company
These are version-independent ( What this PR does (CI/docker infra only): unstick the runner, bump retired actions, upgrade the matrix to PHP 8.2 + 8.4, bump php-cs-fixer, and base the local dev container on the company PHP 8.2 image. Follow-up commits incoming to fix the tests + code so the gates go green. 🤖 Generated with Claude Code |
The OpenSearch refactor made apiVersion (and a document-type resolver / logger) required constructor/method params but left callers and tests out of sync. Thread them through: - Client::__construct: accept array|string $config (DSN string was rejected by the array type-hint); return real bool from shouldLog*() - Bulk\Response: accept the apiVersion the caller already passes - tests: pass ApiVersion + resolver / logger to AbstractDocument, UpdateDocument, Connection::getTransportObject, ResultSet, the builders and MultiBuilder - drop the now-unmatched phpstan-baseline ignore Local gates on PHP 8.2: PHPUnit unit 565/0/0, PHPStan 0 errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mechanical reformat only, no logic changes. The CS gate now runs php-cs-fixer 3.84 (matching upstream ruflin/Elastica); its evolving @Symfony/@PhpCsFixer rulesets reformat files that were clean under the old pinned 3.8.0. Produced by 'php-cs-fixer fix --allow-risky=yes'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
symfony/phpunit-bridge fails the suite on direct deprecations, which were masked by the earlier test errors: - AwsAuthV4: GuzzleHttp\choose_handler() -> Utils::chooseHandler() (deprecated since guzzle 7.1), triggered 3x by AwsAuthV4Test - DocumentTest: assertObjectNotHasAttribute() -> property_exists() (assertObjectNotHasProperty() only exists in PHPUnit 10) Local PHPUnit unit now exits 0 (565 tests, OK). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two more ubuntu-latest (24.04) consequences that surfaced once jobs ran: - Setup Elasticsearch used docker-compose (v1), removed from 24.04 -> use the docker compose v2 plugin - composer-normalize's bundled composer rejected the ghs_ token that setup-php injects; it needs no GitHub auth, so drop the token first Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marc-mabe/php-enum was out of alphabetical order in require; move it up so composer-normalize passes. Pre-existing, exposed now that CI runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
docker compose v2 derives the project name from the CWD, so the network became elastica_elastic while the health-check curl targets the hardcoded docker_elastic (v1 derived the project from the compose files' docker/ dir). Pin --project-name=docker to restore docker_elastic. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The functional tests' ES 7.15.2 docker cluster starts fine on 20.04 but the containers crash on ubuntu-latest (24.04). Pin the phpunit job to the supported 22.04; cs/phpstan stay on ubuntu-latest. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
getApiVersion() read the apiVersion config without a default, so a Client built outside ClientFactory (e.g. the functional tests' _getClient()) returned null and violated the int return type (481 functional errors). Mirror getDocumentTypeResolver()'s defaulting; 7 is the assumed default across the code (resolver -> Type::DOC). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Unrelated to the PHP upgrade, exposed once functional tests ran: - GeoBoundsTest: use assertEqualsWithDelta for geo_point coords, whose precision is inherently lossy (37.782438984140754 vs ...141) - ClientFunctionalTest testLogger/testLoggerOnFailure: the log message gained path/tags/timing in commit 3d7aace but these asserts still expected the bare prefix; match with stringStartsWith (timing varies) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The request/response context keys are now gated behind LOG_REQUEST_BODY / LOG_RESPONSE_BODY (commit 3d7aace); the default LOG_BASIC omits them, so the test asserted keys that were never present. Set the logging mode so the test verifies its original intent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Critical CI, PHP/Guzzle compatibility, API compatibility, and Docker usability issues remain unresolved.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Modernizes CI for PHP 8.2/8.4 and synchronizes API-version handling across client, bulk, and result-set code.
Changes:
- Upgrades runners, actions, Docker Compose, PHP tooling, and local development images.
- Propagates API-version and document-type context through builders and bulk actions.
- Updates tests, deprecations, formatting, PHPStan configuration, and precision assertions.
File summaries
| File | Reviewed changes |
|---|---|
tests/UtilTest.php |
Updates escaping tests and annotations. |
tests/Transport/TransportBenchmarkTest.php |
Reorders test annotations. |
tests/Transport/HttpTest.php |
Passes API version to result builders. |
tests/Transport/GuzzleTest.php |
Updates Guzzle checks and builder calls. |
tests/Transport/AbstractTransportTest.php |
Refactors transport provider tests. |
tests/Script/ScriptTest.php |
Reorders data-provider annotations. |
tests/Script/ScriptIdTest.php |
Reorders data-provider annotations. |
tests/Script/ScriptFieldsTest.php |
Normalizes hit access syntax. |
tests/ResultTest.php |
Normalizes query expressions. |
tests/ResultSet/ProcessingBuilderTest.php |
Supplies API version to builder tests. |
tests/ResultSet/ChainProcessorTest.php |
Supplies API version to result sets. |
tests/ResultSet/BuilderTest.php |
Supplies API version to builders. |
tests/QueryTest.php |
Repositions the invalid-value provider. |
tests/Query/WildcardTest.php |
Normalizes annotation formatting. |
tests/Processor/UppercaseProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/TrimProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/SplitProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/SortProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/RenameProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/LowercaseProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/JoinProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/DotExpanderProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/DateProcessorTest.php |
Normalizes hit assertions. |
tests/Processor/ConvertProcessorTest.php |
Normalizes hit assertions. |
tests/Multi/MultiBuilderTest.php |
Adds API-version propagation coverage. |
tests/Exception/PartialShardFailureExceptionTest.php |
Passes API version to result builders. |
tests/Exception/Connection/GuzzleExceptionTest.php |
Updates Guzzle detection. |
tests/Exception/AbstractExceptionTest.php |
Normalizes namespace matching. |
tests/DocumentTest.php |
Replaces a deprecated PHPUnit assertion. |
tests/ConnectionTest.php |
Supplies logger and retry settings. |
tests/Connection/Strategy/EmptyStrategy.php |
Removes redundant documentation. |
tests/ClientFunctionalTest.php |
Updates logging expectations. |
tests/BulkTest.php |
Supplies API and type-resolver context. |
tests/Bulk/ResponseSetTest.php |
Reorganizes the response provider. |
tests/Bulk/Action/UpdateDocumentTest.php |
Supplies action context. |
tests/Bulk/Action/AbstractDocumentTest.php |
Supplies action context. |
tests/Aggregation/TopHitsTest.php |
Repositions the source provider. |
tests/Aggregation/SumBucketTest.php |
Applies formatting updates. |
tests/Aggregation/StatsTest.php |
Applies formatting updates. |
tests/Aggregation/SamplerTest.php |
Normalizes annotations. |
tests/Aggregation/GeoBoundsTest.php |
Adds floating-point tolerances. |
tests/Aggregation/ExtendedStatsTest.php |
Applies formatting updates. |
tests/Aggregation/DiversifiedSamplerTest.php |
Normalizes annotations. |
tests/Aggregation/CumulativeSumTest.php |
Applies formatting updates. |
tests/Aggregation/CardinalityTest.php |
Reorganizes providers. |
tests/Aggregation/AvgBucketTest.php |
Applies formatting updates. |
src/Util.php |
Normalizes string escaping. |
src/Transport/Http.php |
Applies retry-code formatting. |
src/Transport/Guzzle.php |
Normalizes stream handling. |
src/Transport/AwsAuthV4.php |
Updates handler selection; Guzzle 6 compatibility remains unresolved. |
src/Transport/AbstractTransport.php |
Applies comparison formatting. |
src/Suggest/Phrase.php |
Removes redundant documentation. |
src/Suggest.php |
Updates exception documentation. |
src/Snapshot.php |
Updates exception documentation. |
src/ServerConfiguration.php |
Normalizes declaration formatting. |
src/Search.php |
Updates API documentation. |
src/Script/ScriptId.php |
Removes redundant documentation. |
src/Script/Script.php |
Removes redundant documentation. |
src/Script/AbstractScript.php |
Removes redundant documentation. |
src/ResultSet/ChainProcessor.php |
Removes redundant documentation. |
src/ResultSet.php |
Updates API-version checks and documentation. |
src/Result.php |
Simplifies documentation. |
src/Rescore/Query.php |
Updates query type documentation. |
src/RequestCounterInterface.php |
Normalizes strict-types formatting. |
src/RequestCounter.php |
Normalizes strict-types formatting. |
src/Request.php |
Updates exception documentation. |
src/QueryBuilder/Facade.php |
Simplifies return documentation. |
src/QueryBuilder/DSL/Query.php |
Clarifies nullable parameter documentation. |
src/QueryBuilder/DSL/Aggregation.php |
Normalizes declaration formatting. |
src/Query/Simple.php |
Removes redundant documentation. |
src/Query/Script.php |
Removes redundant documentation. |
src/Query/QueryString.php |
Removes redundant documentation. |
src/Query/MultiMatch.php |
Simplifies parameter documentation. |
src/Query/MoreLikeThis.php |
Removes redundant documentation. |
src/Query/MatchQuery.php |
Simplifies parameter documentation. |
src/Query/MatchPhrase.php |
Simplifies parameter documentation. |
src/Query/InnerHits.php |
Removes redundant documentation. |
src/Query/Ids.php |
Removes redundant documentation. |
src/Query/HasParent.php |
Removes redundant documentation. |
src/Query/HasChild.php |
Removes redundant documentation. |
src/Query/GeoShapeProvided.php |
Removes redundant documentation. |
src/Query/GeoShapePreIndexed.php |
Formats constructor; PHP 7 syntax compatibility remains unresolved. |
src/Query/GeoPolygon.php |
Removes redundant documentation. |
src/Query/FunctionScore.php |
Normalizes declarations and documentation. |
src/Query/Common.php |
Removes redundant documentation. |
src/Query/BoolQuery.php |
Removes redundant documentation. |
src/Query/AbstractGeoDistance.php |
Removes redundant documentation. |
src/Processor/SetProcessor.php |
Simplifies parameter documentation. |
src/Pipeline.php |
Normalizes PHPStan annotations. |
src/Param.php |
Simplifies documentation. |
src/Multi/ResultSet.php |
Removes redundant iterator documentation. |
src/Multi/MultiBuilder.php |
Normalizes builder formatting. |
src/Mapping.php |
Simplifies return documentation. |
src/Index.php |
Normalizes imports and formatting. |
src/Exception/RequestEntityTooLargeException.php |
Normalizes Throwable qualification. |
src/Exception/NotFoundException.php |
Normalizes constructor formatting. |
src/ElasticSearchVersion.php |
Normalizes strict-types formatting. |
src/Elasticsearch/Endpoints/Update.php |
Qualifies array helper usage. |
src/Document.php |
Simplifies magic-method documentation. |
src/CustomOptions.php |
Normalizes strict-types formatting. |
src/Connection/Strategy/StrategyFactory.php |
Normalizes strategy class construction. |
src/Connection/Strategy/Simple.php |
Removes redundant documentation. |
src/Connection/Strategy/RoundRobin.php |
Removes redundant documentation. |
src/Connection/Strategy/CallbackStrategy.php |
Removes redundant documentation. |
src/Connection/ConnectionPool.php |
Normalizes exception qualification. |
src/Connection.php |
Updates configuration documentation. |
src/Cluster/Settings.php |
Simplifies parameter documentation. |
src/Cluster/InvalidClusterConfigurationException.php |
Normalizes exception declarations. |
src/Cluster/ClusterConfigurationProvider.php |
Normalizes helper usage. |
src/Cluster/ClusterConfigurationNotFoundException.php |
Normalizes exception declarations. |
src/Cluster/ClusterConfigurationFromParametersParser.php |
Normalizes parsing and exception handling. |
src/Cluster/ClusterConfiguration.php |
Normalizes constructor formatting. |
src/ClientFactory.php |
Normalizes client factory formatting. |
src/ClientConfiguration.php |
Simplifies documentation. |
src/Client.php |
Supports DSN configs, typed logging flags, and API defaults. |
src/Bulk/ResponseSet.php |
Removes redundant iterator documentation. |
src/Bulk/Response.php |
Adds API-version storage; constructor compatibility remains unresolved. |
src/Bulk/Action/UpdateDocument.php |
Removes redundant documentation. |
src/Bulk/Action/IndexDocument.php |
Removes redundant imports and documentation. |
src/Bulk/Action/DeleteDocument.php |
Removes redundant imports and documentation. |
src/Bulk/Action/AbstractDocument.php |
Threads API and type-resolver context. |
src/Bulk/Action.php |
Normalizes closure typing and documentation. |
src/Aggregation/WeightedAvg.php |
Clarifies nullable parameter documentation. |
src/Aggregation/Traits/MissingTrait.php |
Simplifies documentation. |
src/Aggregation/ScriptedMetric.php |
Applies constructor formatting. |
src/Aggregation/ReverseNested.php |
Removes redundant documentation. |
src/Aggregation/AbstractSimpleAggregation.php |
Removes redundant documentation. |
phpstan-baseline.neon |
Removes an obsolete baseline suppression. |
docker/php/Dockerfile |
Migrates to PHP 8.2; private image access and bind-mount permissions remain unresolved. |
composer.json |
Normalizes dependency ordering. |
.github/workflows/continuous-integration.yaml |
Updates runners, actions, PHP matrix, and Compose; Codecov configuration and declared PHP compatibility remain unresolved. |
Review details
Suppressed comments (1)
docker/php/Dockerfile:6
- This makes the local PHP container depend on a private company ECR image, so contributors or CI without that AWS registry access cannot run the documented Docker-based development/test setup. Keep a publicly pullable default base image, or make this registry image an explicit opt-in build argument rather than the only
FROMtarget.
FROM 563770389081.dkr.ecr.eu-west-1.amazonaws.com/php:8.2-debian-bullseye
- Files reviewed: 131/131 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| - '8.2' | ||
| - '8.4' |
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: build/coverage/unit-coverage.xml,build/coverage/functional-coverage.xml |
| * @param array|string $responseData | ||
| */ | ||
| public function __construct($responseData, Action $action, string $opType) | ||
| public function __construct($responseData, Action $action, string $opType, int $apiVersion) |
| string $indexedId, | ||
| string $indexedIndex, | ||
| string $indexedPath | ||
| string $indexedPath, |
| { | ||
| if (!$persistent || !self::$_guzzleClientConnection) { | ||
| $stack = HandlerStack::create(GuzzleHttp\choose_handler()); | ||
| $stack = HandlerStack::create(GuzzleHttp\Utils::chooseHandler()); |
| # Allow php to run with an | ||
| RUN adduser phpuser -u 1000 -D -g "" | ||
| USER phpuser | ||
| USER www-data |
|
Superseded by #42, which rebuilds the same work with clean history and no bulk restyle — the coding-style gate stays on php-cs-fixer 3.8.0 (run under PHP 8.1, lint-only), so the ~111-file 3.84 reformat is gone while the test matrix moves to PHP 8.2/8.4. |
Description: Modernize the CI workflow (runner, actions, PHP 8.2/8.4) and fix the code/tests so the whole suite is green
Possible impact: CI/CD (GitHub Actions), local dev docker, Client apiVersion handling, Bulk/ResultSet builders, test suite
Summary
The pipelines on the
opensearchbranch were stuck queueing forever on the retiredubuntu-20.04runner. Unsticking them exposed a cascade of further breakage (retired actions, droppeddocker-compose, the in-flight OpenSearch apiVersion refactor left callers/tests out of sync, stale linter/tool pins). This PR fixes the whole chain and takes the suite from all-red / never-running to green.Built with Claude Code.
CI / infrastructure
ubuntu-20.04(removed by GitHub) →ubuntu-latest; the PHPUnit job pinsubuntu-22.04because the ES 7.15.2 docker cluster crashes on 24.04.actions/cache@v2(hard-failed by GitHub) +checkout@v2+codecov@v2→ v4.docker-compose(v1, gone from the new image) →docker composev2, with--project-name=dockerso thedocker_elasticnetwork name still matches the health-check.ghs_token setup-php injects (its bundled composer rejects it; normalize needs no auth).PHP 8.2 / 8.4
7.2–8.1→8.2+8.4; coding-style and PHPStan gates on8.2.php-cs-fixer3.8.0→3.84.0(3.8 refuses to run on 8.2; matches upstream ruflin).docker/php/Dockerfile).Code / test fixes (OpenSearch apiVersion refactor sync)
Client: acceptarray|string $config(DSN string was rejected by thearrayhint); realboolfromshouldLog*();getApiVersion()defaults toAPI_VERSION_7(was returningnull→TypeErroroutsideClientFactory).Bulk\Response: accept theapiVersionthe caller already passed.apiVersion/ document-type resolver / logger through the affected tests (AbstractDocument,UpdateDocument,Connection::getTransportObject,ResultSet, the builders,MultiBuilder,BulkTest).GuzzleHttp\choose_handler()→Utils::chooseHandler();assertObjectNotHasAttribute→property_exists).testLogger/testLoggerOnFailurestale expectations after the slow-request-logging feature.php-cs-fixer 3.84formatting (isolated commit) and normalizedcomposer.json.Test Plan