Skip to content

Commit 32e6672

Browse files
committed
Added the CONTRIBUTING guide with the @generated info
1 parent 22ffead commit 32e6672

File tree

2 files changed

+96
-13
lines changed

2 files changed

+96
-13
lines changed

CONTRIBUTING.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
- `PYTHON_VERSION`: Version of Python to use, defaults to `3.9`
21+
- `TEST_SUITE`: Connection class to use, defaults to `Urllib3HttpConnection`
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+
72+
3. Rebase your changes.
73+
Update your local repository with the most recent code from the main
74+
elasticsearch-php repository, and rebase your branch on top of the latest branch.
75+
If you want to propose a change in the latest version, you need to use the `main`
76+
branch. If you are proposing for `8.x` version you should use the latest
77+
minor branch (e.g. `8.17`). If want to propose a change for the oldest versions
78+
you need to use the `7.17` or `6.8.x` branches. Remember, we support only the latest
79+
minor of the previous majour. For instance, if the latest version is `8.x` we
80+
support the last minor of `7.x` (i.e. `7.17`).
81+
We prefer your changes to be squashed into a single commit for easier
82+
backporting.
83+
84+
4. Submit a pull request. Push your local changes to your forked copy of the
85+
repository and submit a pull request. In the pull request, describe what your
86+
changes do and mention the number of the issue where discussion has taken
87+
place, eg “Closes #123″. Please consider adding or modifying tests related to
88+
your changes.
89+
90+
Then sit back and wait. There will probably be a discussion about the pull
91+
request and, if any changes are needed, we would love to work with you to get
92+
your pull request merged into elasticsearch-php.
93+
94+
Thanks in advance for all your future contributions!

README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,8 @@ You can checkout the
180180

181181
## Contribute 🚀
182182

183-
We welcome contributors to the project. Before you begin, some useful info...
184-
185-
- If you want to contribute to this project you need to subscribe to a
186-
[Contributor Agreement](https://www.elastic.co/contributor-agreement).
187-
- Before opening a pull request, please create an issue to
188-
[discuss the scope of your proposal](https://github.com/elastic/elasticsearch-php/issues).
189-
- If you want to send a PR for version `8.0` please use the `8.0` branch, for
190-
`8.1` use the `8.1` branch and so on.
191-
- Never send PR to `master` unless you want to contribute to the development
192-
version of the client (`master` represents the next major version).
193-
- Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/).
194-
If you are not familiar with PHPUnit you can have a look at the
195-
[reference](https://phpunit.readthedocs.io/en/9.5/).
183+
We welcome contributors to the project. You can refer to the [CONTRIBUTING](CONTRIBUTING.md)
184+
guide for more information.
196185

197186
Thanks in advance for your contribution! :heart:
198187

0 commit comments

Comments
 (0)