You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use cargo make
This commit adds a Makefile.toml including tasks to
help with the development of the project.
Update CONTRIBUTING.md to detail typical cargo make
usage.
* Remove rustfmt-nighly crate
This commit removes the use of rustfmt-nightly crate
and instead invokes the format task with cargo make
to format generated code.
This change allows all projects to compile and
run on rust stable channel
Cargo make is used to define and configure a set of tasks, and run them as a flow. This helps with performing actions
33
+
such as starting an Elasticsearch instance for integration tests
34
+
35
+
Cargo make can be installed with
36
+
37
+
```sh
38
+
cargo install --force cargo-make
39
+
```
40
+
41
+
### Cargo make
42
+
43
+
Cargo make is used to define and configure a set of tasks, and run them as a flow. To see all of the tasks defined
23
44
24
45
```sh
25
-
cargo run -p api_generator
46
+
cargo make --list-all-steps
26
47
```
27
48
28
-
from the repository root directory, and follow the prompts. The minimum REST API spec version compatible with the
29
-
generator is `v7.4.0`.
49
+
The `Elasticsearch` category of steps are specifically defined for this project and are defined in
50
+
[Makefile.toml](Makefile.toml).
30
51
31
-
The api_generator makes heavy use of the [`syn`](https://docs.rs/syn/1.0.5/syn/) and [`quote`](https://docs.rs/quote/1.0.2/quote/) crates to generate Rust code from the REST API specs.
32
-
The `quote!` macro is particularly useful as it accepts Rust code that can include placeholder tokens (prefixed with `#`)
33
-
that will be interpolated during expansion. Unlike procedural macros, the token stream returned by the `quote!` macro
34
-
can be `to_string()`'ed and written to disk, and this is used to create much of the client scaffolding.
52
+
- Build all packages
53
+
54
+
```sh
55
+
cargo make build
56
+
```
57
+
58
+
- Generate client from REST specs
59
+
60
+
```sh
61
+
cargo make generate-api
62
+
```
63
+
64
+
- Run Elasticsearch package tests
65
+
66
+
Optionally pass
67
+
68
+
-`STACK_VERSION`: Elasticsearch version like `7.9.0` or can be
69
+
a snapshot release like `7.x-SNAPSHOT`
70
+
71
+
```sh
72
+
cargo make test --env STACK_VERSION=<e.g. 7.9.0>
73
+
```
74
+
75
+
- Run YAML tests
76
+
77
+
Optionally pass
35
78
36
-
### elasticsearch
79
+
-`STACK_VERSION`: Elasticsearch version like `7.9.0` or can be
80
+
a snapshot release like `7.x-SNAPSHOT`
81
+
-`TEST_SUITE`: Elasticsearch distribution of `oss` or `xpack`
82
+
83
+
```sh
84
+
cargo make test-yaml --env STACK_VERSION=<e.g. 7.9.0> --env TEST_SUITE=<xpack or oss>
85
+
```
37
86
38
-
The client package crate. The client exposes all Elasticsearch APIs as associated functions, either on
87
+
### Packages
88
+
89
+
The workspace contains the following packages:
90
+
91
+
-#### `elasticsearch`
92
+
93
+
The client package crate. The client exposes all Elasticsearch APIs as associated functions, either on
39
94
the root client, `Elasticsearch`, or on one of the _namespaced clients_, such as `Cat`, `Indices`, etc. The _namespaced clients_
40
95
are based on the grouping of APIs within the [Elasticsearch](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec) and [X-Pack](https://github.com/elastic/elasticsearch/tree/master/x-pack/plugin/src/test/resources/rest-api-spec/api) REST API specs from which much of the client is generated.
41
96
All API functions are `async` only, and can be `await`ed.
42
97
98
+
-#### `api_generator`
99
+
100
+
A small executable that downloads REST API specs from GitHub and generates much of the client package from the specs.
101
+
The minimum REST API spec version compatible with the generator is `v7.4.0`.
102
+
103
+
The `api_generator` package makes heavy use of the [`syn`](https://docs.rs/syn/1.0.5/syn/) and [`quote`](https://docs.rs/quote/1.0.2/quote/) crates to generate Rust code from the REST API specs.
104
+
The `quote!` macro is particularly useful as it accepts Rust code that can include placeholder tokens (prefixed with `#`)
105
+
that will be interpolated during expansion. Unlike procedural macros, the token stream returned by the `quote!` macro
106
+
can be `to_string()`'ed and written to disk, and this is used to create much of the client scaffolding.
107
+
108
+
-#### `yaml_test_runner`
109
+
110
+
A small executable that downloads YAML tests from GitHub and generates client tests from the YAML tests. The
111
+
version of YAML tests to download are determined from the commit hash of a running Elasticsearch instance.
112
+
113
+
The `yaml_test_runner` package can be run with `cargo test` to run the generated client tests.
114
+
43
115
### Design principles
44
116
45
117
1. Generate as much of the client as feasible from the REST API specs
@@ -75,18 +147,7 @@ The required toolchain for packages in the workspace are controlled
75
147
by a `rust-toolchain` file in the root of each package.
76
148
77
149
`elasticsearch` package compiles and runs with rust stable.
78
-
79
-
`elasticsearch` tests incorporate testing the examples
0 commit comments