Skip to content

Commit 6c7370d

Browse files
bors[bot]meili-botbidoubiwabrunoocasali
authored
Merge #293
293: Improve Docker configuration in the package r=bidoubiwa a=meili-bot _This PR is auto-generated._ Add a basic Docker configuration based on this [integration-guides issue](meilisearch/integration-guides#199). Co-authored-by: meili-bot <[email protected]> Co-authored-by: Charlotte Vermandel <[email protected]> Co-authored-by: Bruno Casali <[email protected]>
2 parents 09cb1cf + f417bbb commit 6c7370d

File tree

13 files changed

+499
-114
lines changed

13 files changed

+499
-114
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume
2727

2828
## Development Workflow
2929

30+
You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).
31+
32+
Example of running all the checks with docker:
33+
```bash
34+
docker-compose run --rm package bash -c "cargo test"
35+
```
36+
37+
To install dependencies:
38+
39+
```bash
40+
cargo build --release
41+
```
42+
3043
### Tests <!-- omit in toc -->
3144

3245
To run the tests, run:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct Movie {
102102

103103
fn main() { block_on(async move {
104104
// Create a client (without sending any request so that can't fail)
105-
let client = Client::new("http://localhost:7700", "masterKey");
105+
let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
106106

107107
// An index is where the documents are stored.
108108
let movies = client.index("movies");

docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: "3.8"
2+
3+
# remove this line if you don't need a volume to map your dependencies
4+
# Check how to cache the build
5+
volumes:
6+
cargo:
7+
8+
services:
9+
package:
10+
image: rust:1
11+
tty: true
12+
stdin_open: true
13+
working_dir: /home/package
14+
environment:
15+
- MEILISEARCH_HOST=http://meilisearch:7700
16+
- CARGO_HOME=/vendor/cargo
17+
depends_on:
18+
- meilisearch
19+
links:
20+
- meilisearch
21+
volumes:
22+
- ./:/home/package
23+
- cargo:/vendor/cargo
24+
25+
meilisearch:
26+
image: getmeili/meilisearch:latest
27+
ports:
28+
- "7700"
29+
environment:
30+
- MEILI_MASTER_KEY=masterKey
31+
- MEILI_NO_ANALYTICS=true

meilisearch-test-macro/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Before explaining its usage, we're going to see a simple test *before* this macr
1313
```rust
1414
#[async_test]
1515
async fn test_get_tasks() -> Result<(), Error> {
16-
let client = Client::new("http://localhost:7700", "masterKey");
16+
let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
1717

1818
let index = client
1919
.create_index("test_get_tasks", None)
@@ -36,7 +36,7 @@ async fn test_get_tasks() -> Result<(), Error> {
3636
```
3737

3838
I have multiple problems with this test:
39-
- `let client = Client::new("http://localhost:7700", "masterKey");`: This line is always the same in every test.
39+
- `let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);`: This line is always the same in every test.
4040
And if you make a typo on the http addr or the master key, you'll have an error.
4141
- `let index = client.create_index("test_get_tasks", None)...`: Each test needs to have an unique name.
4242
This means we currently need to write the name of the test everywhere; it's not practical.

meilisearch-test-macro/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ pub fn meilisearch_test(params: TokenStream, input: TokenStream) -> TokenStream
8383
// First we need to check if a client will be used and create it if it’s the case
8484
if use_client {
8585
outer_block.push(parse_quote!(
86-
let client = Client::new("http://localhost:7700", "masterKey");
86+
let MEILISEARCH_HOST = option_env!("MEILISEARCH_HOST").unwrap_or("http://localhost:7700");
87+
));
88+
outer_block.push(parse_quote!(
89+
let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
90+
));
91+
outer_block.push(parse_quote!(
92+
let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
8793
));
8894
}
8995

0 commit comments

Comments
 (0)