Pin Meilisearch version and add workflow to automate upgrade#2148
Pin Meilisearch version and add workflow to automate upgrade#2148
Conversation
📝 WalkthroughWalkthroughIntroduces automation infrastructure for bumping Meilisearch versions in the repository. A new Bash script detects the latest stable release, determines if an update is needed, and conditionally updates configuration files. A corresponding GitHub Actions workflow runs daily and on demand, executing the script and creating pull requests when version bumps are detected. Changes
Sequence DiagramsequenceDiagram
actor GitHub Actions
participant Bash Script
participant File System
participant GitHub API
GitHub Actions->>Bash Script: Execute bump-meilisearch-version.sh
Bash Script->>GitHub API: Fetch latest Meilisearch release tag
Bash Script->>Bash Script: Validate tag format, compute TARGET_TAG
Bash Script->>File System: Read docker-compose.yml
Bash Script->>Bash Script: Compare CURRENT_MM vs TARGET_TAG
alt Update needed and no existing PR
Bash Script->>File System: Update docker-compose.yml with TARGET_TAG
Bash Script->>File System: Update .github/workflows/tests.yml with TARGET_TAG
Bash Script->>File System: Commit changes via git
Bash Script->>GitHub API: Create pull request with release details
Bash Script->>GitHub Actions: Output success status
else No update needed or PR exists
Bash Script->>GitHub Actions: Output skip status
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
67e1213 to
8cdf05a
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (3)
.github/scripts/bump-meilisearch-version.sh (2)
78-85: Verification grep commands could be more robust.The verification on lines 84-85 will cause the script to exit with error (due to
set -e) if the pattern isn't found, which is the desired behavior. However, ifsedsilently fails to make replacements (e.g., due to pattern mismatch), the error message won't be descriptive.Consider adding explicit error messages for easier debugging.
♻️ Add descriptive error messages
-grep "${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG}" "${DOCKER_COMPOSE_FILE}" >/dev/null -grep "${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG}" "${TESTS_WORKFLOW_FILE}" >/dev/null +if ! grep -q "${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG}" "${DOCKER_COMPOSE_FILE}"; then + echo "ERROR: Failed to update ${DOCKER_COMPOSE_FILE}" >&2 + exit 1 +fi +if ! grep -q "${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG}" "${TESTS_WORKFLOW_FILE}"; then + echo "ERROR: Failed to update ${TESTS_WORKFLOW_FILE}" >&2 + exit 1 +fi🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/scripts/bump-meilisearch-version.sh around lines 78 - 85, The verification greps for ${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG} are not descriptive when they fail; update the checks around the grep invocations (the two lines that call grep against "${DOCKER_COMPOSE_FILE}" and "${TESTS_WORKFLOW_FILE}") to perform an explicit conditional test (e.g., if ! grep ... >/dev/null; then echo a clear error mentioning which file failed and the expected pattern ${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG}; exit 1; fi) so that when sed made no replacement you get a helpful error message referencing DOCKER_COMPOSE_FILE and TESTS_WORKFLOW_FILE and the TARGET_TAG.
47-52: Sed regex may not extract the tag correctly.The sed pattern
s|.*${MEILISEARCH_DOCKER_IMAGE}:(v[0-9]+\.[0-9]+(\.[0-9]+)?)|\1|pcaptures the version tag in group 1, but.*at the start consumes everything up to the image name, and then the replacement\1only outputs the captured version group. However, if there's any trailing content on the line (e.g., quotes or other characters), it won't be removed since the pattern doesn't match the rest of the line.For the current docker-compose.yml format (
image: getmeili/meilisearch-enterprise:v1.37), this works because the tag is at the end of the line, but it's fragile.♻️ More robust extraction
-CURRENT_TAG="$(sed -nE "s|.*${MEILISEARCH_DOCKER_IMAGE}:(v[0-9]+\.[0-9]+(\.[0-9]+)?)|\1|p" "${DOCKER_COMPOSE_FILE}" | head -n 1 || true)" +CURRENT_TAG="$(sed -nE "s|.*${MEILISEARCH_DOCKER_IMAGE}:(v[0-9]+\.[0-9]+(\.[0-9]+)?).*|\1|p" "${DOCKER_COMPOSE_FILE}" | head -n 1 || true)"Adding
.*after the capture group ensures any trailing characters are consumed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/scripts/bump-meilisearch-version.sh around lines 47 - 52, The sed extraction in the CURRENT_TAG assignment is fragile because it doesn't consume trailing characters after the captured version; update the sed regex used with CURRENT_TAG (the one referencing MEILISEARCH_DOCKER_IMAGE and DOCKER_COMPOSE_FILE) to append a pattern that consumes any remaining characters after the version capture so only the version (vX.Y or vX.Y.Z) is output into CURRENT_TAG, then keep the existing logic that derives CURRENT_VERSION and CURRENT_MM from that value..github/workflows/bump-meilisearch-version.yml (1)
52-56: Redundant PR existence check.This check duplicates the logic already present in the bump script (lines 71-76 in
bump-meilisearch-version.sh). If an open PR exists, the script setsshould_update=falseand exits, so this step won't execute.The redundancy is harmless but adds unnecessary code. Consider removing it or documenting why the double-check is intentional (e.g., race condition protection).
♻️ Suggested simplification
- name: Create PR if: steps.bump.outputs.should_update == 'true' env: TARGET_TAG: ${{ steps.bump.outputs.target_tag }} NEW_BRANCH: ${{ steps.bump.outputs.new_branch }} LATEST_TAG: ${{ steps.bump.outputs.latest_tag }} run: | - OPEN_COUNT=$(gh pr list --state open --head "$NEW_BRANCH" --base "$BASE_BRANCH" --json number --jq 'length') - if [ "$OPEN_COUNT" -gt 0 ]; then - echo "PR already exists for branch $NEW_BRANCH" - exit 0 - fi - gh pr create \🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/bump-meilisearch-version.yml around lines 52 - 56, The block that computes OPEN_COUNT using gh pr list and exits if a PR exists is redundant with the existing check in the bump script (which already sets should_update=false when an open PR exists); either remove the entire OPEN_COUNT/if block (the three lines referencing OPEN_COUNT, NEW_BRANCH and BASE_BRANCH) or replace it with a short comment explaining it's an intentional double-check for race-condition protection so reviewers understand why the duplicate exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/scripts/bump-meilisearch-version.sh:
- Around line 78-85: The verification greps for
${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG} are not descriptive when they fail;
update the checks around the grep invocations (the two lines that call grep
against "${DOCKER_COMPOSE_FILE}" and "${TESTS_WORKFLOW_FILE}") to perform an
explicit conditional test (e.g., if ! grep ... >/dev/null; then echo a clear
error mentioning which file failed and the expected pattern
${MEILISEARCH_DOCKER_IMAGE}:${TARGET_TAG}; exit 1; fi) so that when sed made no
replacement you get a helpful error message referencing DOCKER_COMPOSE_FILE and
TESTS_WORKFLOW_FILE and the TARGET_TAG.
- Around line 47-52: The sed extraction in the CURRENT_TAG assignment is fragile
because it doesn't consume trailing characters after the captured version;
update the sed regex used with CURRENT_TAG (the one referencing
MEILISEARCH_DOCKER_IMAGE and DOCKER_COMPOSE_FILE) to append a pattern that
consumes any remaining characters after the version capture so only the version
(vX.Y or vX.Y.Z) is output into CURRENT_TAG, then keep the existing logic that
derives CURRENT_VERSION and CURRENT_MM from that value.
In @.github/workflows/bump-meilisearch-version.yml:
- Around line 52-56: The block that computes OPEN_COUNT using gh pr list and
exits if a PR exists is redundant with the existing check in the bump script
(which already sets should_update=false when an open PR exists); either remove
the entire OPEN_COUNT/if block (the three lines referencing OPEN_COUNT,
NEW_BRANCH and BASE_BRANCH) or replace it with a short comment explaining it's
an intentional double-check for race-condition protection so reviewers
understand why the duplicate exists.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 663bdddd-3488-4daf-9438-cd7ae698937e
📒 Files selected for processing (4)
.github/scripts/bump-meilisearch-version.sh.github/workflows/bump-meilisearch-version.yml.github/workflows/tests.ymldocker-compose.yml
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2148 +/- ##
=======================================
Coverage 97.95% 97.95%
=======================================
Files 15 15
Lines 635 635
Branches 104 104
=======================================
Hits 622 622
Misses 12 12
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Alright, although I do feel it might be overkill to spin up a CI every day just to check if our target meilisearch is the latest. I would prefer a simple file or a config file that contains the target version, which we can update when we're implementing new features manually. I'll look into a more universal way to do this. But until then this looks fine at first sight. |
Pull Request
Motivation
We want to pin the Meilisearch version to make CI deterministic.
Benefits:
Note
For practical reasons, we'll accept a slight version drift by only pinning the minor, not the patch version.
What does this PR do?
docker-compose.ymlandtests.ymlto make local + CI more consistentdocker-compose.ymlandtests.ymlAI disclosure
Cursor with
gpt-5.1-highandgpt-5.3-codexmodelsPR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!