Update PyMilvus in Milvus #146
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update PyMilvus in Milvus | |
| on: | |
| schedule: | |
| - cron: "5 2 * * *" # daily at 02:05 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| bump: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false # Continue with other branches even if one fails | |
| matrix: | |
| branch: [master, '2.5', '2.6'] | |
| steps: | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Configure Git Identity | |
| run: | | |
| echo "Configuring git identity" | |
| echo "Author name: ${{ secrets.GIT_AUTHOR_NAME }}" | |
| echo "Author email: ${{ secrets.GIT_AUTHOR_EMAIL }}" | |
| git config --global user.name "${{ secrets.GIT_AUTHOR_NAME }}" | |
| git config --global user.email "${{ secrets.GIT_AUTHOR_EMAIL }}" | |
| - name: Checkout pymilvus (repo root for workflow) | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| persist-credentials: false | |
| - name: Get history and tags for SCM versioning | |
| run: | | |
| git fetch --prune --unshallow | |
| git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
| - name: Checkout Milvus (upstream) | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: milvus-io/milvus | |
| ref: ${{ matrix.branch }} | |
| path: milvus-upstream | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Determine latest dev version | |
| id: version | |
| run: | | |
| python -m pip install setuptools_scm --user | |
| VERSION=$(python -c "import _version_helper; print(_version_helper.version)") | |
| echo "latest=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected version: $VERSION" | |
| - name: Read current pinned version in Milvus | |
| id: current | |
| run: | | |
| set -euo pipefail | |
| file="milvus-upstream/tests/python_client/requirements.txt" | |
| if [ ! -f "$file" ]; then | |
| echo "Requirements file not found: $file" | |
| echo "current=not-found" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| curr="$(grep -E '^pymilvus(\[bulk_writer\])?==' "$file" | head -n1 | awk -F'==' '{print $2}')" || curr="not-found" | |
| echo "found=$curr" | |
| echo "current=$curr" >> $GITHUB_OUTPUT | |
| - name: Skip if up-to-date | |
| if: steps.current.outputs.current == steps.version.outputs.latest | |
| run: echo "Already up-to-date. Skipping." | |
| - name: Check for existing PR | |
| if: steps.current.outputs.current != steps.version.outputs.latest | |
| id: check_pr | |
| env: | |
| GH_TOKEN: ${{ secrets.MILVUS_UPDATE_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| TARGET_VERSION="${{ steps.version.outputs.latest }}" | |
| TARGET_BRANCH="${{ matrix.branch }}" | |
| # Search for open PRs with matching title pattern | |
| PR_TITLE_PATTERN="test: Increase PyMilvus version to ${TARGET_VERSION} for ${TARGET_BRANCH} branch" | |
| echo "Checking for existing PRs with title pattern: $PR_TITLE_PATTERN" | |
| # List open PRs and check if any match our criteria | |
| EXISTING_PR=$(gh pr list --repo milvus-io/milvus --base "${TARGET_BRANCH}" --state open --json number,title,author --jq ".[] | select(.title == \"${PR_TITLE_PATTERN}\") | .number" || echo "") | |
| if [ -n "$EXISTING_PR" ]; then | |
| echo "Found existing PR #$EXISTING_PR with same version update" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "pr_number=$EXISTING_PR" >> $GITHUB_OUTPUT | |
| else | |
| echo "No existing PR found for this version update" | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Skip if PR already exists | |
| if: steps.current.outputs.current != steps.version.outputs.latest && steps.check_pr.outputs.exists == 'true' | |
| run: | | |
| echo "PR #${{ steps.check_pr.outputs.pr_number }} already exists for updating to version ${{ steps.version.outputs.latest }}" | |
| echo "Skipping PR creation to avoid duplicate." | |
| - name: Prepare branch | |
| if: steps.current.outputs.current != steps.version.outputs.latest && steps.check_pr.outputs.exists != 'true' | |
| run: | | |
| set -euo pipefail | |
| cd milvus-upstream | |
| # Create unique branch name with target branch reference | |
| TARGET_BRANCH="$(echo '${{ matrix.branch }}' | sed 's/\./-/g')" | |
| BR="bot/pymilvus-update-for-${TARGET_BRANCH}-${{ steps.version.outputs.latest }}-$(date -u +%Y%m%d%H%M%S)" | |
| echo "BRANCH=$BR" >> $GITHUB_ENV | |
| git switch -c "$BR" | |
| - name: Update requirements.txt | |
| if: steps.current.outputs.current != steps.version.outputs.latest && steps.check_pr.outputs.exists != 'true' | |
| run: | | |
| set -euo pipefail | |
| file="milvus-upstream/tests/python_client/requirements.txt" | |
| ver="${{ steps.version.outputs.latest }}" | |
| # Replace exact pins for both lines | |
| sed -i -E "s/^pymilvus==[0-9A-Za-z\.\-]+/pymilvus==${ver}/" "$file" | |
| sed -i -E "s/^pymilvus\[bulk_writer\]==[0-9A-Za-z\.\-]+/pymilvus[bulk_writer]==${ver}/" "$file" | |
| echo "Updated to $ver" | |
| grep -nE '^pymilvus(\[bulk_writer\])?==' "$file" || true | |
| - name: Commit | |
| if: steps.current.outputs.current != steps.version.outputs.latest && steps.check_pr.outputs.exists != 'true' | |
| run: | | |
| set -euo pipefail | |
| cd milvus-upstream | |
| git add tests/python_client/requirements.txt | |
| git commit -sm "test: Increase PyMilvus version to ${{ steps.version.outputs.latest }}" | |
| - name: Push to fork | |
| if: steps.current.outputs.current != steps.version.outputs.latest && steps.check_pr.outputs.exists != 'true' | |
| run: | | |
| set -euo pipefail | |
| cd milvus-upstream | |
| cat ~/.git-credentials || echo "no cached creds" | |
| git remote -v | |
| echo "BRANCH=${{ env.BRANCH }}" | |
| echo "REPO_FORK=${{ vars.REPO_FORK }}" | |
| remote="https://x-access-token:${{ secrets.MILVUS_UPDATE_TOKEN }}@github.com/${{ vars.REPO_FORK }}.git" | |
| git remote add fork "$remote" || git remote set-url fork "$remote" | |
| GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push -u fork "$BRANCH" | |
| - name: Open PR to milvus-io/milvus | |
| if: steps.current.outputs.current != steps.version.outputs.latest && steps.check_pr.outputs.exists != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.MILVUS_UPDATE_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| title="test: Increase PyMilvus version to ${{ steps.version.outputs.latest }} for ${{ matrix.branch }} branch" | |
| body="Automated daily bump from pymilvus ${{ matrix.branch }} branch. Updates tests/python_client/requirements.txt." | |
| head="$(echo ${{ vars.REPO_FORK }} | cut -d'/' -f1):${BRANCH}" | |
| base="${{ matrix.branch }}" | |
| echo "title=$title" | |
| echo "body=$body" | |
| echo "head=$head" | |
| echo "base=$base" | |
| gh pr create --repo milvus-io/milvus --title "$title" --body "$body" --head "$head" --base "$base" |