Skip to content

Commit 22d65e5

Browse files
authored
Updated CONTRIBUTING.md (#794)
As titled, also renamed the script files for a better DX.
1 parent fb73b4b commit 22d65e5

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +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.
35-
If you want to run them on your own, you should spin up and Elasticsearch instance via the scripts that you
36-
can find inside the `scripts` folder, and then run `npm run test:integration`.<br/>
37-
If you want to run the integration test for the Elastic licensed APIs, you should run the `platinum` script, and
38-
then run `TEST_ES_SERVER=https://elastic:changeme@localhost:9200 npm run test:integration`.
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.
3935

4036
2. Submit a pull request
4137

@@ -60,6 +56,39 @@ Once your changes are ready to submit for review:
6056
but we'll do our best to dedicate it the attention it deserves.
6157
Your effort is much appreciated!
6258

59+
### Code generation
60+
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!)*.
69+
70+
### 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.
72+
73+
| Script | Description |
74+
|---|---|
75+
| `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. |
83+
84+
#### 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.
86+
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 ;)
91+
6392
### Releasing
6493

6594
If you have access to make releases, the process is as follows:

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"test:behavior": "tap test/behavior/*.test.js -J -t 300",
2222
"test:integration": "tap test/integration/index.js -T --harmony --no-esm",
2323
"test:types": "tsc --project ./test/types/tsconfig.json",
24-
"test:benchmarks": "nanobench test/benchmarks/*.bench.js",
2524
"test:coverage": "nyc npm run test:unit && nyc report --reporter=text-lcov > coverage.lcov && codecov",
2625
"lint": "standard",
2726
"lint:fix": "standard --fix",
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/utils/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
'use strict'
2121

22-
const generate = require('./generate')
22+
const generate = require('./generateApis')
2323
const generateRequestTypes = require('./generateRequestTypes')
2424
const cloneAndCheckout = require('./clone-es')
25-
const genFactory = require('./genMain')
25+
const genFactory = require('./generateMain')
2626
const generateDocs = require('./generateDocs')
2727

2828
module.exports = {

0 commit comments

Comments
 (0)