|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | + |
| 13 | +name: Codex Update Lance Dependency |
| 14 | + |
| 15 | +on: |
| 16 | + workflow_call: |
| 17 | + inputs: |
| 18 | + tag: |
| 19 | + description: "Tag name from Lance (e.g., v2.0.0)" |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + workflow_dispatch: |
| 23 | + inputs: |
| 24 | + tag: |
| 25 | + description: "Tag name from Lance (e.g., v2.0.0)" |
| 26 | + required: true |
| 27 | + type: string |
| 28 | + |
| 29 | +permissions: |
| 30 | + contents: write |
| 31 | + pull-requests: write |
| 32 | + actions: read |
| 33 | + |
| 34 | +jobs: |
| 35 | + update: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Show inputs |
| 39 | + run: | |
| 40 | + echo "tag = ${{ inputs.tag }}" |
| 41 | +
|
| 42 | + - name: Checkout Repo |
| 43 | + uses: actions/checkout@v5 |
| 44 | + with: |
| 45 | + fetch-depth: 0 |
| 46 | + persist-credentials: true |
| 47 | + |
| 48 | + - name: Set up Node.js |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: 20 |
| 52 | + |
| 53 | + - name: Install Codex CLI |
| 54 | + run: npm install -g @openai/codex |
| 55 | + |
| 56 | + - name: Set up Python |
| 57 | + uses: actions/setup-python@v5 |
| 58 | + with: |
| 59 | + python-version: "3.11" |
| 60 | + |
| 61 | + - name: Set up Rust toolchain |
| 62 | + uses: dtolnay/rust-toolchain@stable |
| 63 | + with: |
| 64 | + components: rustfmt, clippy |
| 65 | + |
| 66 | + - name: Configure git user |
| 67 | + run: | |
| 68 | + git config user.name "lance-community" |
| 69 | + git config user.email "community@lance.org" |
| 70 | +
|
| 71 | + - name: Run Codex to update Lance dependency |
| 72 | + env: |
| 73 | + TAG: ${{ inputs.tag }} |
| 74 | + GITHUB_TOKEN: ${{ secrets.LANCE_RELEASE_TOKEN }} |
| 75 | + GH_TOKEN: ${{ secrets.LANCE_RELEASE_TOKEN }} |
| 76 | + OPENAI_API_KEY: ${{ secrets.CODEX_TOKEN }} |
| 77 | + run: | |
| 78 | + set -euo pipefail |
| 79 | + VERSION="${TAG#refs/tags/}" |
| 80 | + VERSION="${VERSION#v}" |
| 81 | + BRANCH_NAME="codex/update-lance-${VERSION//[^a-zA-Z0-9]/-}" |
| 82 | +
|
| 83 | + cat <<EOF >/tmp/codex-prompt.txt |
| 84 | + You are running inside the lance-duckdb repository on a GitHub Actions runner. |
| 85 | + Update the Lance Rust dependencies to version ${VERSION} (semver format) and prepare a pull request for maintainers to review. |
| 86 | +
|
| 87 | + Follow these steps exactly: |
| 88 | + 1. Update versions in Cargo.toml: |
| 89 | + - In the [dependencies] section, update the versions for these crates to "${VERSION}": |
| 90 | + lance, lance-arrow, lance-core, lance-index, lance-linalg, lance-namespace, lance-namespace-impls, lance-table. |
| 91 | + - Keep existing features/flags unchanged. |
| 92 | + 2. Update Cargo.lock to match the new versions. |
| 93 | + - Prefer precise updates like: |
| 94 | + cargo update -p lance --precise ${VERSION} |
| 95 | + cargo update -p lance-arrow --precise ${VERSION} |
| 96 | + ... (repeat for each of the crates above) |
| 97 | + - If Cargo complains about incompatible Arrow/DataFusion versions, update the pinned Arrow/DataFusion versions in Cargo.toml to match the Lance ${VERSION} dependency requirements, then update Cargo.lock again. |
| 98 | + 3. Run these checks: |
| 99 | + - cargo fmt --all |
| 100 | + - cargo check --manifest-path Cargo.toml |
| 101 | + - cargo clippy --manifest-path Cargo.toml --all-targets |
| 102 | + 4. Inspect "git status --short" and "git diff" to confirm the dependency update and any required fixes. |
| 103 | + 5. Create and switch to a new branch named "${BRANCH_NAME}" (replace any duplicated hyphens if necessary). |
| 104 | + 6. Stage all relevant files with "git add -A". Commit using the message "chore: update lance dependency to v${VERSION}". |
| 105 | + 7. Push the branch to origin. If the branch already exists, force-push your changes. |
| 106 | + 8. env "GH_TOKEN" is available; use "gh" tools for GitHub operations like creating pull requests. |
| 107 | + 9. Create a pull request targeting "main" with title "chore: update lance dependency to v${VERSION}". |
| 108 | + - First, write the PR body to /tmp/pr-body.md using a heredoc (cat <<'EOF' > /tmp/pr-body.md). |
| 109 | + - The body should summarize the dependency bump, key resolver changes (if any), the commands run in step 3, and link the triggering tag (${TAG}). |
| 110 | + - Then run "gh pr create --body-file /tmp/pr-body.md". |
| 111 | + 10. Display the PR URL, "git status --short", and a concise summary of the commands run and their results. |
| 112 | +
|
| 113 | + Constraints: |
| 114 | + - Use bash commands. |
| 115 | + - Do not merge the PR. |
| 116 | + - If any command fails, diagnose and fix the issue instead of aborting. |
| 117 | + - For compatibility issues, consult lance-format/lance at tag v${VERSION} for the expected Rust dependency versions. |
| 118 | + EOF |
| 119 | +
|
| 120 | + printenv OPENAI_API_KEY | codex login --with-api-key |
| 121 | + codex --config shell_environment_policy.ignore_default_excludes=true exec --dangerously-bypass-approvals-and-sandbox "$(cat /tmp/codex-prompt.txt)" |
| 122 | +
|
0 commit comments