Skip to content

Conversation

Strift
Copy link
Collaborator

@Strift Strift commented Sep 18, 2025

Pull Request

Related issue

Prepare for #749

What does this PR do?

Update CI configuration to handle both main and v1.x branches:

  • Update update_release_draft job
  • Update update-version job
  • Update dependabot.yml

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • Chores

    • Expanded dependency update automation with branch-specific targets (main and v1.x), standardized schedules, labels, and PR limits for Composer and Actions.
    • Added a v1 release-draft template and refined the main template (clearer categories, updated styling/emojis, improved changelog links and replacers).
    • Release-drafter now selects the appropriate template by branch.
    • Version-update workflow lets you choose the target branch when run manually.
  • Bug Fixes

    • Fixed CI workflow references to the PHP matrix so tests run reliably across supported PHP versions.

@Strift Strift added this to the Meilisearch PHP v2 milestone Sep 18, 2025
@Strift Strift added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Sep 18, 2025
Copy link

coderabbitai bot commented Sep 18, 2025

Walkthrough

Adds branch-targeted Dependabot updates; introduces a v1-specific release draft template; updates the main release draft template; makes Release Drafter select template based on ref; fixes PHP matrix key in two workflows; and adds a target_branch input to update-version workflow to control PR base.

Changes

Cohort / File(s) Summary of changes
Dependabot configuration
.github/dependabot.yml
Split updates by branch (main, v1.x) for GitHub Actions and Composer; added target-branch, schedule time, open-pull-requests-limit; standardized quoting; annotated blocks; rebase-strategy set as quoted "disabled".
Release drafter templates
.github/release-draft-template.yml, .github/release-draft-template-v1.yml
Added new v1 template with version resolver, categories, replacers, and templated notes; updated main template formatting/emojis/initial v2 version and replacers to use double quotes.
Release drafter workflow
.github/workflows/release-drafter.yml
Switched with.config-name from static "release-draft-template.yml" to conditional expression selecting "release-draft-template-v1.yml" when github.ref_name == 'v1.x'.
Workflow matrix key fixes
.github/workflows/meilisearch-beta-tests.yml, .github/workflows/pre-release-tests.yml
Fixed incorrect matrix references: replaced matrix.php-versions with matrix.php-version in job name and Install PHP step.
Update-version workflow
.github/workflows/update-version.yml
Added workflow_dispatch input target_branch (choices: main, v1.x); checkout now uses selected ref; PR creation and step names updated to target the chosen base branch.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Maintainer
  participant GH as GitHub Actions
  participant RD as Release Drafter

  Dev->>GH: Push/PR on branch
  GH->>RD: Run release-drafter with config-name
  alt github.ref_name == "v1.x"
    Note over GH,RD: Use `release-draft-template-v1.yml`
  else
    Note over GH,RD: Use `release-draft-template.yml`
  end
  RD->>GH: Generate/Update release draft
Loading
sequenceDiagram
  autonumber
  actor Op as Operator
  participant GH as GitHub Actions
  participant Repo as Repository
  participant GHCLI as gh CLI

  Op->>GH: workflow_dispatch(update-version) with target_branch={main|v1.x}
  GH->>Repo: Checkout `ref: ${{ github.event.inputs.target_branch }}` and update files
  GH->>Repo: Push NEW_BRANCH
  GH->>GHCLI: gh pr create --base ${{ github.event.inputs.target_branch }}
  GHCLI-->>Op: PR opened targeting selected base
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • curquiza
  • norkunas

Poem

A rabbit taps YAML with gentle care,
Branches split neatly, configs in pair.
Drafts now choose their rightful scroll,
V1 or main—each plays its role.
PHP matrix hops in line, PRs aimed true—hippity-hop, woo! 🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "chore: update ci for v2" correctly signals a CI-related maintenance change, but it is slightly misleading: the PR and diffs focus on adding support for both the main and v1.x branches (new v1 release-draft template, dependabot targets, workflow inputs/refs) rather than explicitly targeting a "v2" branch or release.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/update-ci-for-v2

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.

@Strift
Copy link
Collaborator Author

Strift commented Sep 18, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Sep 18, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@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: 0

Caution

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

⚠️ Outside diff range comments (1)
.github/workflows/update-version.yml (1)

38-45: Create branch from the selected target_branch (prevent cross-branch diffs)

Checkout the chosen target_branch before editing/committing so the created branch is based on it; also explicitly set the PR head.
File: .github/workflows/update-version.yml — checkout step (line 27) and PR creation step (lines ~38–45)

-      - uses: actions/checkout@v4
+      - uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.inputs.target_branch }}
          gh pr create \
            --title "Update version for the next release ($NEW_VERSION)" \
            --body '⚠️ This PR is automatically generated. Check the new version is the expected one.' \
            --label 'skip-changelog' \
-            --base ${{ github.event.inputs.target_branch }}
+            --base ${{ github.event.inputs.target_branch }} \
+            --head ${{ env.NEW_BRANCH }}
🧹 Nitpick comments (6)
.github/release-draft-template-v1.yml (2)

22-25: Use "labels" when providing multiple labels in categories.

Release Drafter expects "labels" (plural) for arrays; using "label" with a list may be ignored.

Apply this diff:

-  - title: "⚙️ Maintenance/misc"
-    label:
-      - "maintenance"
-      - "documentation"
+  - title: "⚙️ Maintenance/misc"
+    labels:
+      - "maintenance"
+      - "documentation"

38-38: Consider descending sort for changelog readability.

Most projects list newest first. Optional: switch to "descending".

-sort-direction: "ascending"
+sort-direction: "descending"
.github/workflows/update-version.yml (1)

9-15: Inputs look good; consider defaulting target_branch.

Optional: set a default (e.g., main) to speed dispatch.

       target_branch:
         description: 'Target branch for the version update'
         required: true
         type: choice
         options:
           - main
           - v1.x
+        default: main
.github/release-draft-template.yml (1)

24-27: Use "labels" for multiple category labels.

Same schema concern as the v1 template.

-  - title: "⚙️ Maintenance/misc"
-    label:
-      - "maintenance"
-      - "documentation"
+  - title: "⚙️ Maintenance/misc"
+    labels:
+      - "maintenance"
+      - "documentation"
.github/dependabot.yml (2)

25-37: Composer (main) block looks good; add timezone for deterministic run time.

Dependabot times default to UTC. Add timezone if you prefer a specific local time.

     schedule:
       interval: "monthly"
       time: "04:00"
+      timezone: "UTC"

38-50: Composer (v1.x) block mirrors main; same timezone suggestion.

Keeps the flows symmetrical.

     schedule:
       interval: "monthly"
       time: "04:00"
+      timezone: "UTC"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8de313 and 5ba06b3.

📒 Files selected for processing (7)
  • .github/dependabot.yml (1 hunks)
  • .github/release-draft-template-v1.yml (1 hunks)
  • .github/release-draft-template.yml (1 hunks)
  • .github/workflows/meilisearch-beta-tests.yml (1 hunks)
  • .github/workflows/pre-release-tests.yml (2 hunks)
  • .github/workflows/release-drafter.yml (1 hunks)
  • .github/workflows/update-version.yml (2 hunks)
🔇 Additional comments (6)
.github/workflows/meilisearch-beta-tests.yml (1)

50-50: Matrix key fix looks correct.

Using matrix.php-version matches the defined strategy key. No further issues.

Please confirm setup-php@v2 supports PHP 8.4 on ubuntu-latest in your runners.

.github/workflows/pre-release-tests.yml (2)

30-30: Job name variable fix LGTM.

Switching to matrix.php-version aligns with the matrix key.


50-50: Install PHP step fix LGTM.

php-version now correctly references matrix.php-version.

Confirm that all configured PHP versions (including 8.4) are available in shivammathur/setup-php@v2.

.github/release-draft-template.yml (1)

13-14: Version template note.

If this repo already has v2 tags, a fixed "2.0.0" may be unnecessary; otherwise fine as an initial seed. No action if intentional.

.github/workflows/release-drafter.yml (1)

15-15: Dynamic template selection LGTM.

Conditional config-name for v1.x vs default is valid.

Ensure both template files exist at .github/ and that release-drafter@v6 reads config-name from that path.

.github/dependabot.yml (1)

3-24: Per-branch GitHub Actions updates LGTM.

Explicit target-branch for main and v1.x is clear.

Confirm that "time" is honored for monthly schedules by Dependabot; if not, consider weekly with time.

@Strift Strift marked this pull request as ready for review September 18, 2025 07:54
Copy link

@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: 0

Caution

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

⚠️ Outside diff range comments (1)
.github/workflows/update-version.yml (1)

3-5: Set explicit workflow permissions for reliability.

Be explicit to avoid org defaults breaking pushes/PR edits, especially when mixing GITHUB_TOKEN and a PAT.

Apply near the top (after name:):

 name: Update library version
+
+permissions:
+  contents: write
+  pull-requests: write
🧹 Nitpick comments (5)
.github/workflows/update-version.yml (5)

9-15: Input looks good; consider a default for UX and keep options in sync.

Adding target_branch is correct. Consider setting a default (e.g., main) to reduce manual errors, and ensure this list stays aligned with actual long‑lived branches and Release Drafter logic.

Would you like a quick script to verify that both main and v1.x exist on the remote and that Release Drafter selects the right template for each?


28-29: Checkout by ref is correct; add fetch-depth and disable persisted creds.

To avoid shallow‑clone surprises and to prevent mixing checkout creds with the bot PAT later, add fetch-depth: 0 and persist-credentials: false.

Apply:

 -      - uses: actions/checkout@v4
-        with:
-          ref: ${{ github.event.inputs.target_branch }}
+      - uses: actions/checkout@v4
+        with:
+          ref: ${{ github.event.inputs.target_branch }}
+          fetch-depth: 0
+          persist-credentials: false

35-39: Ensure pushes use the bot PAT for consistency and protected branches.

EndBug/add-and-commit defaults to GITHUB_TOKEN. If branch protections or cross‑branch pushes require the bot PAT, pass it explicitly so the author/actor is consistent across main and v1.x.

Apply:

       - name: Commit and push the changes to the ${{ env.NEW_BRANCH }} branch
         uses: EndBug/add-and-commit@v9
         with:
           message: "Update version for the next release (${{ env.NEW_VERSION }}) in Meilisearch.php"
           new_branch: ${{ env.NEW_BRANCH }}
+          token: ${{ secrets.MEILI_BOT_GH_PAT }}

46-47: Make PR creation idempotent to avoid failures on re-runs.

gh pr create will fail if a PR from the same head already exists (e.g., re‑runs). Guard it by checking for an existing PR and editing/updating as needed.

Apply:

-          gh pr create \
-            --title "Update version for the next release ($NEW_VERSION)" \
-            --body '⚠️ This PR is automatically generated. Check the new version is the expected one.' \
-            --label 'skip-changelog' \
-            --base ${{ github.event.inputs.target_branch }} \
-            --head ${{ env.NEW_BRANCH }}
+          existing_pr=$(gh pr list --head "${NEW_BRANCH}" --state open --json number --jq '.[0].number')
+          if [ -n "$existing_pr" ]; then
+            gh pr edit "$existing_pr" \
+              --base "${{ github.event.inputs.target_branch }}" \
+              --title "Update version for the next release ($NEW_VERSION)" \
+              --add-label 'skip-changelog' \
+              --body '⚠️ This PR is automatically updated. Check the new version is the expected one.'
+          else
+            gh pr create \
+              --title "Update version for the next release ($NEW_VERSION)" \
+              --body '⚠️ This PR is automatically generated. Check the new version is the expected one.' \
+              --label 'skip-changelog' \
+              --base "${{ github.event.inputs.target_branch }}" \
+              --head "${{ env.NEW_BRANCH }}"
+          fi

31-35: Optional: validate input format before mutating files.

Guard against a missing leading v to avoid writing an invalid VERSION.

Apply:

       run: |
-          raw_new_version=$(echo $NEW_VERSION | cut -d 'v' -f 2)
+          if ! echo "$NEW_VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
+            echo "NEW_VERSION must follow vX.Y.Z (got: $NEW_VERSION)"; exit 1;
+          fi
+          raw_new_version="${NEW_VERSION#v}"
           new_string="VERSION = '$raw_new_version';"
           sed -i "s/VERSION = .*/$new_string/" src/Meilisearch.php
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba06b3 and 36e0503.

📒 Files selected for processing (1)
  • .github/workflows/update-version.yml (3 hunks)
🔇 Additional comments (1)
.github/workflows/update-version.yml (1)

40-40: Rename is accurate and improves clarity.

@Strift Strift merged commit f7c30a7 into main Sep 18, 2025
11 checks passed
@Strift Strift deleted the chore/update-ci-for-v2 branch September 18, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants