Skip to content

Commit 3ede368

Browse files
meili-bors[bot]meili-botbidoubiwa
authored
Merge #1250
1250: 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]>
2 parents 2a9b6e0 + 5ef1de5 commit 3ede368

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
run: yarn test:env:node-ts
5151
- name: Run Browser env
5252
run: yarn test:env:browser
53-
5453
linter_check:
5554
runs-on: ubuntu-latest
5655
name: linter-check

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ To run this project, you will need:
4040

4141
### Setup
4242

43+
You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).
44+
45+
Example of running all the checks with docker:
46+
```bash
47+
docker-compose run --rm package bash -c "yarn install && yarn test && yarn lint"
48+
```
49+
50+
To install dependencies:
51+
4352
```bash
4453
yarn --dev
4554
```

docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "3.8"
2+
3+
services:
4+
package:
5+
image: node:16
6+
tty: true
7+
stdin_open: true
8+
working_dir: /home/package
9+
environment:
10+
- MEILISEARCH_HOST=http://meilisearch:7700
11+
depends_on:
12+
- meilisearch
13+
links:
14+
- meilisearch
15+
volumes:
16+
- ./:/home/package
17+
18+
meilisearch:
19+
image: getmeili/meilisearch:latest
20+
ports:
21+
- "7700"
22+
environment:
23+
- MEILI_MASTER_KEY=masterKey
24+
- MEILI_NO_ANALYTICS=true

tests/client_tests.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
config,
1414
MeiliSearch,
1515
BAD_HOST,
16+
HOST,
1617
} from './meilisearch-test-utils'
1718

1819
const indexNoPk = {
@@ -133,16 +134,18 @@ describe.each([
133134
}
134135
})
135136

136-
test(`${permission} key: host without HTTP should not throw Invalid URL Error`, async () => {
137-
const client = new MeiliSearch({ host: 'meilisearch:7700' })
138-
const health = await client.isHealthy()
139-
expect(health).toBe(false)
137+
test(`${permission} key: host without HTTP should not throw Invalid URL Error`, () => {
138+
const strippedHost = HOST.replace('http://', '')
139+
expect(() => {
140+
new MeiliSearch({ host: strippedHost })
141+
}).not.toThrow('The provided host is not valid.')
140142
})
141143

142-
test(`${permission} key: host without HTTP and port should not throw Invalid URL Error`, async () => {
143-
const client = new MeiliSearch({ host: 'meilisearch' })
144-
const health = await client.isHealthy()
145-
expect(health).toBe(false)
144+
test(`${permission} key: host without HTTP and port should not throw Invalid URL Error`, () => {
145+
const strippedHost = HOST.replace('http://', '').replace(':7700', '')
146+
expect(() => {
147+
new MeiliSearch({ host: strippedHost })
148+
}).not.toThrow('The provided host is not valid.')
146149
})
147150

148151
test(`${permission} key: Empty string host should throw an error`, () => {

tests/meilisearch-test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Config, EnqueuedDump } from '../src/types'
33

44
// testing
55
const MASTER_KEY = 'masterKey'
6-
const HOST = 'http://127.0.0.1:7700'
7-
const BAD_HOST = HOST.slice(0, -1) + `1`
6+
const HOST = process.env.MEILISEARCH_HOST || 'http://127.0.0.1:7700'
7+
const BAD_HOST = 'http://127.0.0.1:7701'
88

99
const config = {
1010
host: HOST,

0 commit comments

Comments
 (0)