Skip to content

Commit 1a9f100

Browse files
authored
Update CONTRIBUTING (#2016)
1 parent 10f7ba7 commit 1a9f100

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ improving the documentation,
88
submitting bug reports and feature requests or writing code.
99

1010
## Repository structure
11-
The `master` branch is considered unstable, and it's compatible with Elasticsearch master. Unless you are patching an issue, new features should always be sent to the `master` branch, in case of a bugfix, it depends if the bug affects all the release lines.<br/>
11+
The `main` branch is considered unstable, and it's compatible with Elasticsearch main. Unless you are patching an issue, new features should always be sent to the `main` branch, in case of a bugfix, it depends if the bug affects all the release lines.<br/>
1212
There is a branch for every supported release line, such as `7.x` or `6.x`. We release bugfixes as soon as possible, while minor and major releases are published at the same time of the Elastic Stack.
1313

1414
Usually for every release line there will be a *published* version and a *next* version. Eg: the `7.x` branch contains the version published on npm, and bugfixes should be sent there, while `7.2` *(assuming that 7.1.x is released)* contains the next version, and new features should be sent there.
@@ -31,7 +31,7 @@ Once your changes are ready to submit for review:
3131
1. Test your changes
3232

3333
Run the test suite to make sure that nothing is broken.
34-
Usually run `npm test` is enough, our CI will take care of running the integration test. If you want to run the integration test yourself, see the *Testing* section below.
34+
Usually running `npm test` is enough; our CI will take care of running the integration tests. If you want to run the integration tests yourself, see [the *Testing* section](#testing) below.
3535

3636
2. Submit a pull request
3737

@@ -58,36 +58,50 @@ Once your changes are ready to submit for review:
5858

5959
### Code generation
6060

61-
The entire content of the API folder is generated as well as the `docs/reference.asciidoc` file.<br/>
62-
If you want to run the code generation you should run the following command:
63-
```sh
64-
node scripts/generate --tag <tag name>
65-
# or
66-
node scripts/generate --branch <branch name>
67-
```
68-
Then you should copy the content of `api/generated.d.ts` into the `index.d.ts` file *(automate this step would be a nice pr!)*.
61+
The entire content of the `src/api/` directory is automatically generated from [the Elasticsearch specification](https://github.com/elastic/elasticsearch-specification), as is the `docs/reference.asciidoc` file.
62+
This code generation is done using a separate repository that is not currently available to the public.
63+
64+
If you find discrepancies between this client's API code and what you see when actually interacting with an Elasticsearch API, you can open a pull request here to fix it.
65+
For API fixes, it's likely a change will need to be made to the specification as well, to ensure your fix is not undone by the code generation process.
66+
We will do our best to make sure this is addressed when reviewing and merging your changes.
67+
68+
PRs to improve the specification are also welcome!
69+
It is implemented in TypeScript, so JavaScript devs should be able to understand it fairly easily.
70+
Spec fixes are particularly helpful, as they will be reflected in ALL official Elasticsearch clients, not just this one.
6971

7072
### Testing
71-
There are different test scripts, usually during development you only need to run `npm test`, but if you want you can run just a part of the suite, following you will find all the testing scripts and what they do.
73+
74+
There are a few different test scripts.
75+
Usually during development you only need to run `npm test`, but if you want you can run just a part of the suite:
7276

7377
| Script | Description |
7478
|---|---|
7579
| `npm run test:unit` | Runs the content of the `test/unit` folder. |
76-
| `npm run test:behavior` | Runs the content of the `test/behavior` folder. |
77-
| `npm run test:types` | Runs the content of the `test/types` folder. |
78-
| `npm run test:unit -- --cov --coverage-report=html` | Runs the content of the `test/unit` folder and calculates the code coverage. |
79-
| `npm run test:integration` | Runs the integration test runner.<br/>*Note: it requires a living instance of Elasticsearch.* |
80-
| `npm run lint` | Run the [linter](https://standardjs.com/). |
81-
| `npm run lint:fix` | Fixes the lint errors. |
82-
| `npm test` | Runs lint, unit, behavior, and types test. |
80+
| `npm run test:coverage-100` | Runs unit tests enforcing 100% coverage. |
81+
| `npm run test:coverage-report` | Runs unit tests and generates an `lcov` coverage report. |
82+
| `npm run test:coverage-ui` | Runs unit tests and generates an HTML coverage report. |
83+
| `npm run test:integration` | Runs the integration test runner.<br/>**Note: requires a living instance of Elasticsearch.** |
84+
| `npm run lint` | Run the [linter](https://github.com/standard/ts-standard). |
85+
| `npm run lint:fix` | Fixes linter errors. |
86+
| `npm run license-checker` | Checks that all dependencies have acceptable open source licenses. |
87+
88+
| `npm test` | Runs `lint` and `test:unit`. |
8389

8490
#### Integration test
85-
The integration test are generated on the fly by the runner you will find inside `test/integration`, once you execute it, it will clone the Elasticsearch repository and checkout the correct version to grab the [OSS yaml files](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/test) and the [Elastic licensed yaml files](https://github.com/elastic/elasticsearch/tree/master/x-pack/plugin/src/test/resources/rest-api-spec/test) that will be used for generating the test.
8691

87-
Usually this step is executed by CI since it takes some time, but you can easily run this yourself! Just follow this steps:
88-
1. Boot an Elasticsearch instance, you can do that by running `./scripts/es-docker.sh` or `./scripts/es-docker-platinum.sh`, the first one will work only with the OSS APIs, while the second will work also with the Elastic licensed APIs;
89-
1. If you are running the OSS test, you should use `npm run test:integration`, otherwise use `TEST_ES_SERVER=https://elastic:changeme@localhost:9200 npm run test:integration`. You can also pass a `-b` parameter if you want the test to bail out at the first failure: `npm run test:integration -- -b`;
90-
1. Grab a coffee, it will take some time ;)
92+
The integration tests are generated on the fly by the runner you will find inside `test/integration`.
93+
Once you execute it, it will fetch the [YAML REST test files](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test) from our artifacts API.
94+
These are used to generate the integration tests.
95+
96+
Usually this step is executed by CI since it takes some time, but you can easily run this yourself!
97+
Just follow this steps:
98+
1. Boot a fresh Elasticsearch instance, which can be done in a Docker container by running `STACK_VERSION=8.10.0 DETACH=true .buildkite/run-elasticsearch.sh`, where `STACK_VERSION` and `DETACH` environment variables can be adjusted to your needs. A `TEST_SUITE` env var can also be set to `free` or `platinum`, and defaults to `free`.
99+
1. Run `npm run test:integration` to run the whole suite, or `npm run test:integration -- --bail` to stop after the first failure.
100+
1. Grab a coffee, it will take some time. ;)
101+
102+
This suite is very large, and not all tests will pass.
103+
This is fine.
104+
This suite is mostly used to identify notable changes in success/fail rate over time as we make changes to the client.
91105

92106
### Releasing
93107

0 commit comments

Comments
 (0)