-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Backfilled data script #28
Changes from 13 commits
73d0fea
ee01a7c
b706931
4522cf3
a19372e
5522f0f
c7085bd
41d7c32
ccc2e7c
e3ef278
11f8f48
26d094b
5273516
2253098
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,17 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume | |
|
||
To run this project, you will need: | ||
|
||
- Node >= 12 | ||
- Node >= 14 && node <= 17 | ||
- Npm >= v7 | ||
- A google account | ||
- Latest version of `firebase-tools` the Firebase CLI: | ||
``` bash | ||
npm install -g firebase-tools | ||
``` | ||
``` bash | ||
yarn global add firebase-tools | ||
``` | ||
Add the directory for the commands of the packages installed globally in yarn, to access of firebase binary: | ||
bidoubiwa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` bash | ||
export PATH="$(yarn global bin):$PATH" | ||
``` | ||
|
||
### Setup <!-- omit in toc --> | ||
|
||
|
@@ -54,21 +58,25 @@ firebase --open-sesame extdev | |
``` | ||
Install dependencies: | ||
``` bash | ||
npm run install:functions | ||
yarn install:functions | ||
``` | ||
Build the project: | ||
``` bash | ||
npm run build | ||
yarn build | ||
``` | ||
Launch Meilisearch instance: | ||
``` bash | ||
docker pull getmeili/meilisearch:latest # Fetch the latest version of Meilisearch image from Docker Hub | ||
docker run -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics=true | ||
curl -L https://install.meilisearch.com | sh # download Meilisearch | ||
./meilisearch --master-key=masterKey --no-analytics # run Meilisearch | ||
``` | ||
Launch emulator: | ||
``` bash | ||
firebase ext:dev:emulators:start --test-params=test-params-example.env --import=dataset --project=name-of-the-project | ||
``` | ||
or just | ||
``` bash | ||
yarn emulator | ||
``` | ||
The emulator runs with environment parameters found in `test-params-example.env` and with a provided dataset found in `/dataset`. | ||
|
||
Once it is running, open the emulator in a browser at the following address: http://localhost:4000 | ||
|
@@ -80,20 +88,62 @@ NB: If you want to change your Meilisearch credentials or the plugins options yo | |
Each PR should pass the tests and the linter to be accepted. | ||
|
||
```bash | ||
curl -L https://install.meilisearch.com | sh # download Meilisearch | ||
./meilisearch --master-key=masterKey --no-analytics # run Meilisearch | ||
|
||
# Tests | ||
npm run test | ||
yarn test | ||
|
||
# Tests in watch mode | ||
npm run test:watch | ||
yarn test:watch | ||
|
||
# Linter | ||
npm run lint | ||
yarn lint | ||
|
||
# Linter with fixing | ||
npm run lint:fix | ||
yarn lint:fix | ||
|
||
# Build the project | ||
npm run build | ||
yarn build | ||
``` | ||
|
||
### Run the backfilled-data script | ||
|
||
Run the import script using [`npx` (the Node Package Runner)](https://www.npmjs.com/package/npx). | ||
- Set up credentials. The import script uses the application's default credentials to communicate with Firebase. Please follow the instructions [generate a private key file for your service account](https://firebase.google.com/docs/admin/setup#initialize-sdk). | ||
|
||
- Run the import script interactively using `npx` and run ONE of the following commands: | ||
- Run interactively: | ||
```bash | ||
npx firestore-meilisearch | ||
``` | ||
|
||
- Or run non-interactively with paramaters: | ||
```bash | ||
npx firestore-meilisearch \ | ||
--project <project_id> \ | ||
--source-collection-path <collection_name> \ | ||
--index <index_uid> \ | ||
--batch-size <100/default=300> \ | ||
--host <host_address> \ | ||
--api-key <api_key> \ | ||
--non-interactive | ||
``` | ||
**Note**: The `--batch-size` and `--query-collection-group` arguments are optional. To see its usage, run the above command with `--help`. | ||
|
||
- Run the project for development: | ||
Launch Meilisearch instance: | ||
``` bash | ||
curl -L https://install.meilisearch.com | sh # download Meilisearch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw that earlier 👀 😄 |
||
./meilisearch --master-key=masterKey --no-analytics # run Meilisearch | ||
``` | ||
Launch the watcher on the project: | ||
``` bash | ||
yarn watch | ||
``` | ||
Launch the watcher on the script. You have to modify the informations of the playground script by your own parameters inside the `package.json` file: | ||
``` bash | ||
yarn playground | ||
``` | ||
|
||
## Git Guidelines | ||
|
@@ -139,7 +189,26 @@ _[Read more about this](https://github.com/meilisearch/integration-guides/blob/m | |
|
||
### How to Publish the Release <!-- omit in toc --> | ||
|
||
WIP | ||
⚠️ Before doing anything, make sure you got through the guide about [Releasing an Integration](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md). | ||
|
||
1. Make a PR modifying the files [`package.json`](/package.json), [`package.json` in functions directory](/functions/package.json) and the [`extension.yaml`](/extension.yaml) with the right version. | ||
|
||
```yaml | ||
"version": "X.X.X", | ||
``` | ||
|
||
2. Test the extension by installing it on Firestore database: | ||
```bash | ||
firebase ext:install . --project=meilisearch-e2fe1 | ||
``` | ||
|
||
3. Publish the extension by run the following command in the root of the extension directory: | ||
```bash | ||
firebase ext:dev:publish meilisearch/firestore-meilisearch --project=meilisearch-e2fe1 | ||
``` | ||
**Note**: `meilisearch` is the publisher id and `meilisearch-e2fe1` is the publish project id for this extension. | ||
|
||
Once the changes are merged on `main`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-go/releases): on this page, click on `Edit` (related to the draft release) > update the description (be sure you apply [these recommandations](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md#writting-the-release-description)) > when you are ready, click on `Publish release`. | ||
|
||
<hr> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,28 @@ describe('extensions process', () => { | |
test('adaptDocument with fields not set', () => { | ||
mockedGetFieldsToIndex.mockReturnValueOnce([]) | ||
const snapshot = firebaseMock.firestore.makeDocumentSnapshot( | ||
defaultDocument, | ||
'docs/1' | ||
defaultDocument.document, | ||
`docs/${defaultDocument.id}` | ||
) | ||
expect(adaptDocument(defaultDocument.id, snapshot)).toStrictEqual( | ||
defaultDocument | ||
|
||
expect(adaptDocument(defaultDocument.id, snapshot)).toStrictEqual({ | ||
_firestore_id: defaultDocument.id, | ||
...defaultDocument.document, | ||
}) | ||
}) | ||
|
||
test('adaptDocument with fields not set and with id field in document', () => { | ||
mockedGetFieldsToIndex.mockReturnValueOnce([]) | ||
const snapshot = firebaseMock.firestore.makeDocumentSnapshot( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could apply the http://xunitpatterns.com/Four%20Phase%20Test.html in these tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made some changes is this better? |
||
{ id: '12345', ...defaultDocument.document }, | ||
`docs/${defaultDocument.id}` | ||
) | ||
|
||
expect(adaptDocument(defaultDocument.id, snapshot)).toStrictEqual({ | ||
_firestore_id: defaultDocument.id, | ||
id: '12345', | ||
...defaultDocument.document, | ||
}) | ||
}) | ||
|
||
test('adaptDocument with fields set', () => { | ||
|
@@ -33,14 +49,15 @@ describe('extensions process', () => { | |
'release_date', | ||
]) | ||
const snapshot = firebaseMock.firestore.makeDocumentSnapshot( | ||
defaultDocument, | ||
'docs/1' | ||
defaultDocument.document, | ||
`docs/${defaultDocument.id}` | ||
) | ||
|
||
expect(adaptDocument(defaultDocument.id, snapshot)).toStrictEqual({ | ||
id: defaultDocument.id, | ||
title: defaultDocument.title, | ||
overview: defaultDocument.overview, | ||
release_date: defaultDocument.release_date, | ||
_firestore_id: defaultDocument.id, | ||
title: defaultDocument.document.title, | ||
overview: defaultDocument.document.overview, | ||
release_date: defaultDocument.document.release_date, | ||
}) | ||
}) | ||
}) | ||
|
@@ -54,6 +71,7 @@ describe('extensions process', () => { | |
}) | ||
test('adaptValues a geo point value', () => { | ||
const geoPoint = new firestore.GeoPoint(48.866667, 2.333333) | ||
|
||
expect(adaptValues('_geo', geoPoint)).toStrictEqual([ | ||
'_geo', | ||
{ | ||
|
@@ -67,6 +85,7 @@ describe('extensions process', () => { | |
}) | ||
test('adaptValues a wrong geo point value', () => { | ||
const geoPoint = new firestore.GeoPoint(48.866667, 2.333333) | ||
|
||
expect(adaptValues('wrong_geo', geoPoint)).toStrictEqual([ | ||
'wrong_geo', | ||
geoPoint, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason to change? 😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no particular opinion on the matter but all js repo use yarn by default so ... I change it