Skip to content

Commit f3ac19d

Browse files
committed
Merge remote-tracking branch 'origin/main' into 9.0
2 parents 9c83e2d + 62d4bb5 commit f3ac19d

File tree

99 files changed

+8878
-6343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+8878
-6343
lines changed

.buildkite/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG PHP_VERSION=8.0-cli
1+
ARG PHP_VERSION=8.4-cli
22
FROM php:${PHP_VERSION}
33

44
WORKDIR /usr/src/app
@@ -39,4 +39,4 @@ RUN composer install --no-progress > /dev/null
3939

4040
COPY . .
4141

42-
CMD ["bash", ".buildkite/yaml-tests.sh"]
42+
CMD ["bash", ".buildkite/yaml-tests.sh"]

.buildkite/pipeline.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ steps:
77
env:
88
PHP_VERSION: "{{ matrix.php }}"
99
TEST_SUITE: "{{ matrix.suite }}"
10-
STACK_VERSION: 8.16.0-SNAPSHOT
10+
STACK_VERSION: 9.0.0-SNAPSHOT
11+
BRANCH_CLIENT_TESTS: 9.0
1112
matrix:
1213
setup:
1314
suite:
14-
- "free"
1515
- "platinum"
1616
php:
17+
- "8.4-cli"
1718
- "8.3-cli"
1819
- "8.2-cli"
1920
- "8.1-cli"
20-
- "8.0-cli"
21-
- "7.4-cli"
2221
command: ./.buildkite/run-tests
2322
artifact_paths: "*.xml"

.buildkite/run-repository.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ script_path=$(dirname $(realpath -s $0))
99
source $script_path/functions/imports.sh
1010
set -euo pipefail
1111

12-
PHP_VERSION=${PHP_VERSION-8.2-cli}
12+
PHP_VERSION=${PHP_VERSION-8.4-cli}
1313
ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"}
1414
elasticsearch_container=${elasticsearch_container-}
1515

@@ -18,6 +18,7 @@ echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m"
1818
echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m"
1919
echo -e "\033[34;1mINFO:\033[0m CONTAINER ${elasticsearch_container}\033[0m"
2020
echo -e "\033[34;1mINFO:\033[0m PHP_VERSION ${PHP_VERSION}\033[0m"
21+
echo -e "\033[34;1mINFO:\033[0m BRANCH_CLIENT_TESTS ${BRANCH_CLIENT_TESTS}\033[0m"
2122

2223
echo -e "\033[1m>>>>> Build docker container >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
2324

@@ -40,7 +41,8 @@ docker run \
4041
--env TEST_SUITE=${TEST_SUITE} \
4142
--env PHP_VERSION=${PHP_VERSION} \
4243
--env ELASTICSEARCH_URL=${ELASTICSEARCH_URL} \
44+
--env BRANCH_CLIENT_TESTS=${BRANCH_CLIENT_TESTS} \
4345
--ulimit nofile=65535:65535 \
4446
--name elasticsearch-php \
4547
--rm \
46-
elastic/elasticsearch-php
48+
elastic/elasticsearch-php

.buildkite/yaml-tests.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/usr/bin/env bash
22

3-
# Checkout the YAML test from Elasticsearch tag
4-
php util/RestSpecRunner.php
3+
# Clone the elasticsearch-clients-tests repository
4+
git clone -b ${BRANCH_CLIENT_TESTS} https://github.com/elastic/elasticsearch-clients-tests.git tests/elasticsearch-clients-tests
55

6-
# Generate the YAML tests for PHPUnit
7-
php util/build_tests.php
6+
# Build the YAML tests
7+
php tests/build_es_tests.php tests/elasticsearch-clients-tests/tests stack tests/Yaml
88

99
# Run YAML tests
10-
vendor/bin/phpunit -c "phpunit-yaml-${TEST_SUITE}-tests.xml"
10+
vendor/bin/phpunit -c "phpunit-yaml-stack-tests.xml"
11+
12+
# Remove Yaml tests
13+
rm -rf tests/Yaml
14+
15+
# Remove elasticsearch-clients-tests folder
16+
rm -rf tests/elasticsearch-clients-tests
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: PHP integration tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test
8+
runs-on: ${{ matrix.os }}
9+
10+
strategy:
11+
matrix:
12+
php-version: [8.1, 8.2, 8.3, 8.4]
13+
os: [ubuntu-latest]
14+
es-version: [9.0.0-SNAPSHOT]
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Use PHP ${{ matrix.php-version }}
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php-version }}
24+
extensions: yaml, zip, curl
25+
coverage: none
26+
env:
27+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Get composer cache directory
30+
id: composercache
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
32+
- name: Cache dependencies
33+
uses: actions/cache@v4
34+
with:
35+
path: ${{ steps.composercache.outputs.dir }}
36+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
37+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-
38+
39+
- name: Install dependencies
40+
run: |
41+
composer install --prefer-dist
42+
43+
- name: Run Elasticsearch using start-local
44+
run: |
45+
curl -fsSL https://elastic.co/start-local | sh -s -- -v ${{ matrix.es-version }} -esonly
46+
47+
- name: Integration tests
48+
run: |
49+
source elastic-start-local/.env
50+
ELASTICSEARCH_URL="http://elastic:${ES_LOCAL_PASSWORD}@localhost:9200" TEST_SUITE="free" composer run-script integration-test

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHP test
1+
name: PHP tests
22

33
on: [push, pull_request]
44

@@ -9,9 +9,9 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
php-version: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
12+
php-version: [8.1, 8.2, 8.3, 8.4]
1313
os: [ubuntu-latest]
14-
es-version: [8.16-SNAPSHOT]
14+
es-version: [9.0.0-SNAPSHOT]
1515

1616
steps:
1717
- name: Checkout

.github/workflows/yaml_test.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: PHP YAML tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test
8+
runs-on: ${{ matrix.os }}
9+
10+
strategy:
11+
matrix:
12+
php-version: [8.1, 8.2, 8.3, 8.4]
13+
os: [ubuntu-latest]
14+
es-version: [9.0.0-SNAPSHOT]
15+
test-suite: [stack]
16+
branch-client-tests: ["9.0"]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Use PHP ${{ matrix.php-version }}
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-version }}
26+
extensions: yaml, zip, curl
27+
coverage: none
28+
env:
29+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Get composer cache directory
32+
id: composercache
33+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34+
- name: Cache dependencies
35+
uses: actions/cache@v4
36+
with:
37+
path: ${{ steps.composercache.outputs.dir }}
38+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
39+
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-
40+
41+
- name: Install dependencies
42+
run: |
43+
composer install --prefer-dist
44+
45+
- name: Run Elasticsearch using start-local
46+
run: |
47+
curl -fsSL https://elastic.co/start-local | sh -s -- -v ${{ matrix.es-version }} -esonly
48+
49+
- name: Build PHPUnit tests
50+
run: |
51+
git clone -b ${{ matrix.branch-client-tests }} https://github.com/elastic/elasticsearch-clients-tests.git tests/elasticsearch-clients-tests
52+
php tests/build_es_tests.php tests/elasticsearch-clients-tests/tests ${{ matrix.test-suite }} tests/Yaml
53+
54+
- name: YAML tests
55+
run: |
56+
source elastic-start-local/.env
57+
ELASTICSEARCH_URL="http://elastic:${ES_LOCAL_PASSWORD}@localhost:9200" TEST_SUITE="free" vendor/bin/phpunit -c "phpunit-yaml-${{ matrix.test-suite }}-tests.xml"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ util/cache/
2727
util/*.zip
2828
util/output/
2929
util/rest-spec
30+
elastic-start-local/
3031

3132
# Doctum docs generator
3233
/doctum.phar
@@ -35,6 +36,7 @@ util/doctum.phar
3536
# PHPUnit
3637
/phpunit.xml
3738
.phpunit.result.cache
39+
.phpunit.cache/
3840

3941
# Code coverage
4042
build

BREAKING_CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 9.0
2+
3+
- **Use of PHP 8.1+:** Starting from 9.0.0 the `elasticsearch-php` client requires PHP 8.1+.
4+
15
# 8.0
26

37
This major release is a complete new PHP client for Elasticsearch. We build it from scratch!

CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
## Release 9.0.0
2+
3+
- **Use of PHP 8.1+:** Starting from 9.0.0 the `elasticsearch-php` client requires PHP 8.1+.
4+
- **Compatibility with Elasticsearch 9.0:** All changes and additions to Elasticsearch APIs for its 9.0 release are reflected in this release.
5+
- **Serverless client merged in:** the `elastic/elasticsearch-serverless` client is being deprecated, and its functionality has been merged back into this client. This should have zero impact on the way the client works by default. If an endpoint is available in serverless, the PHP function will contains a `@group serverless` phpdoc attribute.
6+
If you try to use an endpoint that is not available in serverless you will get a `410` HTTP error with a message as follows:
7+
"this endpoint exists but is not available when running in serverless mode".
8+
The 9.0.0 client can recognize that it is communicating with a serverless instance if you are using a URL managed by Elastic (e.g. `*.elastic.cloud`).
9+
If you are using a proxy, the client will be able to recognize that the host is serverless from the first response. Alternatively, you can explicitly indicate that the host is serverless using the `Client::setServerless(true)` function (`false` by default).
10+
- **New transport library with PSR-18 cURL client as default:** we've removed the Guzzle dependency from the client. By default, the built-in cURL-based HTTP client will be used if no other PSR-18 compatible clients are detected. See release [9.0.0](https://github.com/elastic/elastic-transport-php/releases/tag/v9.0.0) of elastic-transport-php.
11+
12+
## Release 8.17.1
13+
14+
- Fix and improvements for PHPStan (rule level 5) #1442 (thanks @AJenbo)
15+
16+
## Release 8.17.0
17+
18+
- Updated the APIs to Elasticsearch [8.17.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.17.0.html)
19+
20+
## Release 8.16.0
21+
22+
- Updated the APIs to Elasticsearch [8.16.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.16.0.html)
23+
- Added the support of PHP 8.4 #1415 (thanks @ruudk)
24+
125
## Release 8.15.0
226

327
Updated the APIs to Elasticsearch [8.15.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/release-notes-8.15.0.html) and added the support of OpenTelemetry.

CONTRIBUTING.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Contributing to the PHP Elasticsearch Client
2+
3+
If you have a bugfix or new feature that you would like to contribute to
4+
elasticsearch-php, please find or open an issue about it first. Talk about what
5+
you would like to do. It may be that somebody is already working on it, or that
6+
there are particular issues that you should know about before implementing the
7+
change.
8+
9+
We enjoy working with contributors to get their code accepted. There are many
10+
approaches to fixing a problem and it is important to find the best approach
11+
before writing too much code.
12+
13+
## Running Elasticsearch locally
14+
15+
We've provided a script to start an Elasticsearch cluster of a certain version
16+
found at `.buildkite/run-elasticsearch.sh`.
17+
18+
There are several environment variables that control integration tests:
19+
20+
- `TEST_SUITE`: `free` or `platinum` for running Elasticsearch in different
21+
versions.
22+
- `STACK_VERSION`: Version of Elasticsearch to use. These should be
23+
the same as tags of `docker.elastic.co/elasticsearch/elasticsearch`
24+
such as `8.0.0-SNAPSHOT`, `7.x-SNAPSHOT`, etc. Defaults to the
25+
same `*-SNAPSHOT` version as the branch.
26+
27+
**NOTE: You don't need to run the live integration tests for all changes. If
28+
you don't have Elasticsearch running locally the integration tests will be skipped.**
29+
30+
## API Code Generation
31+
32+
All API methods in `src/Endpoints` and in `src/Traits/ClientEndpointsTrait.php` are
33+
automatically generated from the [Elasticsearch specification](https://github.com/elastic/elasticsearch-specification)
34+
and [rest-api-spec](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/api).
35+
36+
You can check if a PHP file has been generated searching for `@generated` tag
37+
in the source code (e.g. [here](https://github.com/elastic/elasticsearch-php/blob/main/src/Traits/ClientEndpointsTrait.php#L27)
38+
in the `ClientEndpointsTrait.php`).
39+
40+
Any changes to these files should be avoid, you can submit to the Elasticsearch
41+
specification project and will be imported the next time the client will be generated.
42+
The generator itself is currently a private project.
43+
44+
## Contributing Code Changes
45+
46+
The process for contributing to any of the Elasticsearch repositories is similar.
47+
48+
1. Please make sure you have signed the [Contributor License
49+
Agreement](http://www.elastic.co/contributor-agreement/). We are not
50+
asking you to assign copyright to us, but to give us the right to distribute
51+
your code without restriction. We ask this of all contributors in order to
52+
assure our users of the origin and continuing existence of the code. You only
53+
need to sign the CLA once.
54+
55+
2. Run the linter and test suite to ensure your changes do not break existing code.
56+
Run the last optional step only if you want to test your changes with the
57+
integration tests. You need to specify the `STACK_VERSION` of Elasticsearch (e.g.
58+
`8.17.0`), you can check the Elasticsearch versions [here](https://github.com/elastic/elasticsearch/releases).
59+
60+
```
61+
# Run PHPStan, see https://phpstan.org/
62+
$ composer run-script phpstan
63+
64+
# Run the unit tests
65+
$ composer run-script test
66+
67+
# Run the integration tests (optional)
68+
$ STACK_VERSION="8.17.0" .buildkite/run-tests
69+
```
70+
71+
3. Rebase your changes.
72+
Update your local repository with the most recent code from the main
73+
elasticsearch-php repository, and rebase your branch on top of the latest branch.
74+
If you want to propose a change in the latest version, you need to use the `main`
75+
branch. If you are proposing for `8.x` version you should use the latest
76+
minor branch (e.g. `8.17`). If want to propose a change for the oldest versions
77+
you need to use the `7.17` or `6.8.x` branches. Remember, we support only the latest
78+
minor of the previous majour. For instance, if the latest version is `8.x` we
79+
support the last minor of `7.x` (i.e. `7.17`).
80+
We prefer your changes to be squashed into a single commit for easier
81+
backporting.
82+
83+
4. Submit a pull request. Push your local changes to your forked copy of the
84+
repository and submit a pull request. In the pull request, describe what your
85+
changes do and mention the number of the issue where discussion has taken
86+
place, eg “Closes #123″. Please consider adding or modifying tests related to
87+
your changes.
88+
89+
Then sit back and wait. There will probably be a discussion about the pull
90+
request and, if any changes are needed, we would love to work with you to get
91+
your pull request merged into elasticsearch-php.
92+
93+
Thanks in advance for all your future contributions!

0 commit comments

Comments
 (0)