Skip to content

Add meilisearch target version and logic#2035

Open
flevi29 wants to merge 22 commits intomeilisearch:mainfrom
flevi29:lock-meiliserach-version
Open

Add meilisearch target version and logic#2035
flevi29 wants to merge 22 commits intomeilisearch:mainfrom
flevi29:lock-meiliserach-version

Conversation

@flevi29
Copy link
Copy Markdown
Collaborator

@flevi29 flevi29 commented Sep 24, 2025

Pull Request

What does this PR do?

  • added a configuration file /.conf, readable both by Docker and Node.js, and adapted all code to use this configuration file
  • locks current targeted Meilisearch version, stores it in config file stated above
  • updated contribution guidelines describing how to update Meilisearch target version and more
  • CI/CD now uses docker-compose.yml instead of lengthy repetitive service descriptions
  • type check no longer builds the project unnecessarily
  • consolidated internal module imports using path aliases for improved maintainability
  • added test global setup file, that waits for Meilisearch client connection and provides environment variables for the tests to use
  • remove docekr-compose.yml "package" entry
    • it's meant to run the project without having Node.js installed locally, I believe it's not that useful and just adds noise to the project

Summary by CodeRabbit

  • New Features

    • health() now accepts optional extra request options for more flexible checks.
  • Chores

    • CI workflows and local dev scripts switched to Docker Compose and an external .conf for env.
    • Centralized test setup added for consistent test environment initialization.
    • Playground/dev tooling updated to read runtime credentials from config.
    • Internal import resolution consolidated via package manifest aliases.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 24, 2025

📝 Walkthrough

Walkthrough

Replaces GitHub Actions Meilisearch service containers with docker-compose + .conf for env; adds Vitest global setup that waits for Meilisearch health; moves test imports to #src aliases; updates playground and docker-compose to use injected env vars; minor API change: MeiliSearch.health(extraRequestInit?).

Changes

Cohort / File(s) Summary
CI Workflows
.github/workflows/meilisearch-prototype-tests.yml, .github/workflows/pre-release-tests.yml, .github/workflows/tests.yml
Removed services.meilisearch and meilisearch-version job; add steps that run docker compose --env-file .conf up -d before tests.
Docker & Env
docker-compose.yml, .conf
Removed package service; made meilisearch image tag, port and master key configurable via TARGET_VERSION, PORT, MASTER_KEY in .conf.
Project config & playground
package.json, playgrounds/javascript/package.json, playgrounds/javascript/vite.config.ts, playgrounds/javascript/src/meilisearch.ts, playgrounds/javascript/src/vite-env.d.ts
Added #src/* import mapping; updated playground scripts and Vite config to load .conf and inject __PORT__/__MASTER_KEY__; playground client uses injected values.
Core change
src/meilisearch.ts
Extended MeiliSearch.health() to accept optional extraRequestInit?: ExtraRequestInit.
Test setup & config
tests/setup/index.ts, vite.config.ts, tests/utils/meilisearch-test-utils.ts
Added Vitest global setup that loads .conf, validates env, instantiates client and polls client.health() (250ms interval, 6s timeout); Vite test config now uses globalSetup; test utils obtain PORT/MASTER_KEY via Vitest injection.
Tests — import migration (bulk)
tests/* (many files) — e.g. tests/*.test.ts, tests/utils/*
Migrated test imports from relative ../src/... to #src/...; adjusted tests to use injected PORT where applicable and minor setup changes (e.g., beforeAll for fetch in errors.test.ts).
Test utilities & assertions
tests/utils/assertions/*, tests/utils/meilisearch-test-utils.ts
Switched type imports to #src/index; removed some module-level exported clients and environment exports in favor of Vitest-provided values.
Docs
CONTRIBUTING.md
Updated local development instructions to require Docker and use docker compose --env-file .conf up -d; added guidance for targeting Meilisearch versions.

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI Workflow
  participant Docker as Docker Compose
  participant Meili as Meilisearch
  participant Vitest as Vitest GlobalSetup
  participant Tests as Test Runner

  CI->>Docker: run `docker compose --env-file .conf up -d`
  Docker-->>Meili: start Meilisearch (v${TARGET_VERSION}, ${PORT})
  Vitest->>Vitest: load `.conf` (MASTER_KEY, PORT)
  Vitest->>Meili: poll `client.health()` every 250ms (Abort after 6s)
  alt Meilisearch becomes healthy
    Meili-->>Vitest: health OK
    Vitest->>Tests: provide PORT/MASTER_KEY → Tests start
  else timeout / error
    Meili-->>Vitest: no response / error
    Vitest-->>Tests: throw connection unsuccessful error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled configs, found a clue,
Compose brought Meili back anew,
Tests now wait with patient cheer,
Aliases hop the imports near,
A tiny rabbit cheers: "All clear!" 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add meilisearch target version and logic' directly reflects the primary change: introducing a configuration mechanism to lock the Meilisearch version and adapt related code/CI to use it, which is the main objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.95%. Comparing base (e67674e) to head (64e5fdc).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2035   +/-   ##
=======================================
  Coverage   97.95%   97.95%           
=======================================
  Files          15       15           
  Lines         635      635           
  Branches      104      105    +1     
=======================================
  Hits          622      622           
  Misses         12       12           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@flevi29 flevi29 added the maintenance Issue about maintenance (CI, tests, refacto...) label Sep 24, 2025
@flevi29 flevi29 marked this pull request as ready for review March 19, 2026 17:31
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/pre-release-tests.yml (1)

19-35: ⚠️ Potential issue | 🔴 Critical

Critical: Missing meilisearch-version job and TARGET_VERSION not passed to Docker Compose.

Two issues will cause this workflow to fail:

  1. Line 23 declares needs: ["meilisearch-version"], but the meilisearch-version job is not defined in this workflow file. This will cause the workflow to fail immediately.

  2. Line 35 runs docker compose up -d without setting TARGET_VERSION. The docker-compose.yml expects this variable to construct the image tag (getmeili/meilisearch-enterprise:v${TARGET_VERSION}).

Compare with .github/workflows/meilisearch-prototype-tests.yml which correctly defines the meilisearch-version job and passes the version:

run: TARGET_VERSION=${{ needs.meilisearch-version.outputs.version }} docker compose up -d
🐛 Proposed fix

Either:

  1. Add the meilisearch-version job (similar to meilisearch-prototype-tests.yml) and pass TARGET_VERSION to docker compose, OR
  2. If pre-release tests should use a fixed version from .env.example, remove the needs: ["meilisearch-version"] line.

If using a dynamic version:

+  meilisearch-version:
+    runs-on: ubuntu-latest
+    outputs:
+      version: ${{ steps.grep-step.outputs.meilisearch_version }}
+    steps:
+      - uses: actions/checkout@v6
+      - name: Get pre-release Meilisearch version
+        id: grep-step
+        run: |
+          # Add logic to determine the pre-release version
+          echo "meilisearch_version=<VERSION>" >> $GITHUB_OUTPUT
+
   integration_tests:
     runs-on: ubuntu-latest
     if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'bump-meilisearch-v') || startsWith(github.base_ref, 'pre-release-beta')
     needs: ["meilisearch-version"]
...
       - name: Set up Meilisearch
-        run: docker compose up -d
+        run: TARGET_VERSION=${{ needs.meilisearch-version.outputs.version }} docker compose up -d
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pre-release-tests.yml around lines 19 - 35, The workflow's
integration_tests job references a missing job name ("meilisearch-version") and
fails to pass TARGET_VERSION into the Docker Compose step; update the workflow
by either (A) adding a meilisearch-version job that outputs the chosen version
and keep needs: ["meilisearch-version"], then change the "Set up Meilisearch"
step (the docker compose up -d run) to run as: TARGET_VERSION=${{
needs.meilisearch-version.outputs.version }} docker compose up -d, or (B) remove
needs: ["meilisearch-version"] and explicitly set TARGET_VERSION from a fixed
source (e.g., .env.example) before running docker compose; reference the
integration_tests job, the needs declaration, and the "Set up Meilisearch"
docker compose step when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/tests.yml:
- Around line 39-40: The CI currently runs "docker compose up -d" in the "Set up
Meilisearch" step but doesn't wait for the Meilisearch HTTP server to be ready,
causing race conditions; add an explicit readiness check immediately after that
step that polls Meilisearch's health endpoint (e.g., GET
http://localhost:7700/health) with a timeout/retry loop and exits non‑zero if
unchanged, or alternatively add a Docker healthcheck to the docker-compose
service and replace "docker compose up -d" with "docker compose up -d --wait" so
the next step (the test step) only runs once Meilisearch is healthy.

In `@CONTRIBUTING.md`:
- Around line 62-68: The CONTRIBUTING.md snippet doesn't explain how to select a
non-default Meilisearch version; update the doc block that currently describes
copying .env and running docker compose up to explicitly instruct contributors
to edit the TARGET_VERSION variable in the .env file to the desired Meilisearch
release before running docker compose up -d, and mention the .env/TARGET_VERSION
pairing so it's discoverable when targeting a non-default version.

In `@playgrounds/javascript/vite.config.ts`:
- Around line 4-5: After calling loadEnvFile("../../.env"), validate that
env.PORT and env.MASTER_KEY are defined (the symbols to check are env, PORT,
MASTER_KEY as used in the destructuring) and fail fast with a clear error if
either is missing; update the code around loadEnvFile and the destructuring so
you check (or assert) env.PORT and env.MASTER_KEY and throw or log a descriptive
error and exit (or throw) instead of allowing undefined values to be passed into
the Vite define replacements for __PORT__ and __MASTER_KEY__.

In `@tests/multi_modal_search.test.ts`:
- Around line 3-5: Replace the deprecated JSON import assertion by updating the
movies import in tests/multi_modal_search.test.ts: remove the old assert syntax
and use the Node.js 20+ import attributes form so the module is imported as a
JSON module (i.e., import the JSON as the movies symbol using the modern
import-attributes/assertion style compatible with the rest of the codebase and
runtime).

In `@tests/setup/index.ts`:
- Around line 5-13: After calling loadEnvFile(), validate that env.PORT and
env.MASTER_KEY are defined and non-empty before constructing host or new
Meilisearch; if either is missing throw or log a clear error (e.g., "Missing
required env var PORT/MASTER_KEY") so the failure is explicit. Locate the
validation near loadEnvFile() and perform the check on env.PORT and
env.MASTER_KEY prior to using them to build host or instantiate client so client
(the Meilisearch instance) is only created when configuration is valid.

---

Outside diff comments:
In @.github/workflows/pre-release-tests.yml:
- Around line 19-35: The workflow's integration_tests job references a missing
job name ("meilisearch-version") and fails to pass TARGET_VERSION into the
Docker Compose step; update the workflow by either (A) adding a
meilisearch-version job that outputs the chosen version and keep needs:
["meilisearch-version"], then change the "Set up Meilisearch" step (the docker
compose up -d run) to run as: TARGET_VERSION=${{
needs.meilisearch-version.outputs.version }} docker compose up -d, or (B) remove
needs: ["meilisearch-version"] and explicitly set TARGET_VERSION from a fixed
source (e.g., .env.example) before running docker compose; reference the
integration_tests job, the needs declaration, and the "Set up Meilisearch"
docker compose step when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c89aa74-7397-4bd2-bbb7-18f6f4a106a0

📥 Commits

Reviewing files that changed from the base of the PR and between e67674e and 5f6ce65.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (56)
  • .env.example
  • .github/actions/set-up-node/action.yml
  • .github/workflows/meilisearch-prototype-tests.yml
  • .github/workflows/pre-release-tests.yml
  • .github/workflows/tests.yml
  • CONTRIBUTING.md
  • docker-compose.yml
  • package.json
  • playgrounds/javascript/package.json
  • playgrounds/javascript/src/meilisearch.ts
  • playgrounds/javascript/src/vite-env.d.ts
  • playgrounds/javascript/vite.config.ts
  • src/meilisearch.ts
  • tests/chat-settings.test.ts
  • tests/chat-workspaces.test.ts
  • tests/client.test.ts
  • tests/displayed_attributes.test.ts
  • tests/distinct_attribute.test.ts
  • tests/documents.test.ts
  • tests/dump.test.ts
  • tests/embedders.test.ts
  • tests/errors.test.ts
  • tests/experimental-features.test.ts
  • tests/facet_search_settings.test.ts
  • tests/faceting.test.ts
  • tests/fields.test.ts
  • tests/filterable_attributes.test.ts
  • tests/get_search.test.ts
  • tests/http-requests.test.ts
  • tests/index.test.ts
  • tests/keys.test.ts
  • tests/localized_attributes.test.ts
  • tests/multi_modal_search.test.ts
  • tests/pagination.test.ts
  • tests/prefix_search_settings.test.ts
  • tests/ranking_rules.test.ts
  • tests/raw_document.test.ts
  • tests/search.test.ts
  • tests/search_cutoff_ms.test.ts
  • tests/searchable_attributes.test.ts
  • tests/settings.test.ts
  • tests/setup/index.ts
  • tests/snapshots.test.ts
  • tests/sortable_attributes.test.ts
  • tests/stop_words.test.ts
  • tests/synonyms.test.ts
  • tests/task.test.ts
  • tests/tasks-and-batches.test.ts
  • tests/token.test.ts
  • tests/typed_search.test.ts
  • tests/typo_tolerance.test.ts
  • tests/utils/assertions/error.ts
  • tests/utils/assertions/tasks-and-batches.ts
  • tests/utils/meilisearch-test-utils.ts
  • tests/webhooks.test.ts
  • vite.config.ts

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/pre-release-tests.yml:
- Around line 33-35: The docker compose step currently runs `docker compose up
-d` without passing the resolved pre-release version, so it may start the wrong
Meilisearch image; update the workflow to inject the resolved version into the
compose environment (e.g., set an env entry like TARGET_VERSION: ${{
needs.resolve_version.outputs.target_version }} on the job or step, or restore
the version-resolving job and consume its output) and ensure the `docker compose
up -d` step reads TARGET_VERSION (or uses an overridden .env) so compose starts
the correct Meilisearch image; reference the `docker compose up -d` step and the
version-resolving job/output when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7c4afc3c-b861-41a2-a3ae-4bb34362f5c9

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6ce65 and 7eb8213.

📒 Files selected for processing (1)
  • .github/workflows/pre-release-tests.yml

@flevi29
Copy link
Copy Markdown
Collaborator Author

flevi29 commented Mar 21, 2026

@Strift I decided to give it one last shot with a more code agnostic solution 🤞.

@flevi29 flevi29 mentioned this pull request Mar 24, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Issue about maintenance (CI, tests, refacto...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant