Skip to content

DE-178815 Modernize CI: unstick runner, upgrade to PHP 8.2/8.4, green the suite - #41

Closed
jzajac-nice wants to merge 15 commits into
opensearchfrom
DE-178815-fix-ci-runner-label
Closed

DE-178815 Modernize CI: unstick runner, upgrade to PHP 8.2/8.4, green the suite#41
jzajac-nice wants to merge 15 commits into
opensearchfrom
DE-178815-fix-ci-runner-label

Conversation

@jzajac-nice

@jzajac-nice jzajac-nice commented Sep 11, 2026

Copy link
Copy Markdown

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 opensearch branch were stuck queueing forever on the retired ubuntu-20.04 runner. Unsticking them exposed a cascade of further breakage (retired actions, dropped docker-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

  • Runner: ubuntu-20.04 (removed by GitHub) → ubuntu-latest; the PHPUnit job pins ubuntu-22.04 because the ES 7.15.2 docker cluster crashes on 24.04.
  • Actions: actions/cache@v2 (hard-failed by GitHub) + checkout@v2 + codecov@v2 → v4.
  • ES setup: docker-compose (v1, gone from the new image) → docker compose v2, with --project-name=docker so the docker_elastic network name still matches the health-check.
  • composer-normalize: drop the ghs_ token setup-php injects (its bundled composer rejects it; normalize needs no auth).

PHP 8.2 / 8.4

  • PHPUnit matrix 7.2–8.18.2 + 8.4; coding-style and PHPStan gates on 8.2.
  • php-cs-fixer 3.8.03.84.0 (3.8 refuses to run on 8.2; matches upstream ruflin).
  • Local dev container based on the shared company PHP 8.2 image (docker/php/Dockerfile).

Code / test fixes (OpenSearch apiVersion refactor sync)

  • Client: accept array|string $config (DSN string was rejected by the array hint); real bool from shouldLog*(); getApiVersion() defaults to API_VERSION_7 (was returning nullTypeError outside ClientFactory).
  • Bulk\Response: accept the apiVersion the caller already passed.
  • Threaded apiVersion / document-type resolver / logger through the affected tests (AbstractDocument, UpdateDocument, Connection::getTransportObject, ResultSet, the builders, MultiBuilder, BulkTest).
  • Removed a PHPUnit deprecation failure (GuzzleHttp\choose_handler()Utils::chooseHandler(); assertObjectNotHasAttributeproperty_exists).
  • Fixed pre-existing functional failures: geo-point float precision (delta), and testLogger / testLoggerOnFailure stale expectations after the slow-request-logging feature.
  • Applied php-cs-fixer 3.84 formatting (isolated commit) and normalized composer.json.

Test Plan

  • Coding style — green
  • PHPStan — green
  • PHPUnit unit — green (565 tests)
  • PHPUnit functional — verified locally (unit) + on CI; down from 481 errors → 0

jzajac-nice and others added 5 commits September 11, 2026 10:53
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>
@jzajac-nice

Copy link
Copy Markdown
Author

Local gate run on PHP 8.2 — CI failures are pre-existing branch state, not the version bump

I reproduced all three gates locally on PHP 8.2 (company php:8.2-debian-bullseye base) and they match CI exactly:

Gate Local (PHP 8.2) CI
PHPUnit (unit) 565 tests, 11 errors, 3 failures 11E / 3F
PHPStan 36 errors 36
Coding style (php-cs-fixer 3.84) violations in ≥8 src/ files same

These are version-independent (ArgumentCountError / TypeError fail on any PHP) and pre-date this PR — they were just invisible while CI was stuck queueing on the retired ubuntu-20.04 runner. Root cause is the in-flight OpenSearch refactor leaving callers/tests out of sync with new required constructor/method params (ResultSet, AbstractDocument::create, UpdateDocument, Connection::getTransportObject, MultiBuilder, DefaultBuilder), plus a wrong array type-hint and int-instead-of-bool returns in Client, plus style.

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

jzajac-nice and others added 10 commits September 11, 2026 11:37
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>
@jzajac-nice jzajac-nice changed the title DE-178815 Fix stuck CI: replace removed ubuntu-20.04 runner label DE-178815 Modernize CI: unstick runner, upgrade to PHP 8.2/8.4, green the suite Sep 11, 2026
@jzajac-nice
jzajac-nice marked this pull request as ready for review September 11, 2026 10:55
Copilot AI lite review requested due to automatic review settings September 11, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 FROM target.
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.

Comment on lines +40 to +41
- '8.2'
- '8.4'
Comment on lines +94 to 96
uses: codecov/codecov-action@v4
with:
files: build/coverage/unit-coverage.xml,build/coverage/functional-coverage.xml
Comment thread src/Bulk/Response.php
* @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());
Comment thread docker/php/Dockerfile
# Allow php to run with an
RUN adduser phpuser -u 1000 -D -g ""
USER phpuser
USER www-data
@jzajac-nice

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants