Codex Update Pylance Dependency #846
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
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| name: Codex Update Pylance Dependency | |
| on: | |
| workflow_call: | |
| inputs: | |
| tag: | |
| description: "Tag name from Pylance (e.g., v2.0.0)" | |
| required: true | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag name from Pylance (e.g., v2.0.0)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: read | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Show inputs | |
| run: | | |
| echo "tag = ${{ inputs.tag }}" | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install Codex CLI | |
| run: npm install -g @openai/codex | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Configure git user | |
| run: | | |
| git config user.name "lance-community" | |
| git config user.email "[email protected]" | |
| - name: Run Codex to update Pylance dependency | |
| env: | |
| TAG: ${{ inputs.tag }} | |
| GITHUB_TOKEN: ${{ secrets.LANCE_RELEASE_TOKEN }} | |
| GH_TOKEN: ${{ secrets.LANCE_RELEASE_TOKEN }} | |
| OPENAI_API_KEY: ${{ secrets.CODEX_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| VERSION="${TAG#refs/tags/}" | |
| VERSION="${VERSION#v}" | |
| # Convert semver beta format (2.0.0-beta.10) to PEP 440 format (2.0.0b10) | |
| PEP440_VERSION=$(echo "$VERSION" | sed -E 's/-beta\./b/g; s/-alpha\./a/g; s/-rc\./rc/g') | |
| BRANCH_NAME="codex/update-pylance-${VERSION//[^a-zA-Z0-9]/-}" | |
| cat <<EOF >/tmp/codex-prompt.txt | |
| You are running inside the lance-ray repository on a GitHub Actions runner. Update the Pylance dependency to version ${PEP440_VERSION} (PEP 440 format) and prepare a pull request for maintainers to review. | |
| Follow these steps exactly: | |
| 1. Update the pylance dependency version in pyproject.toml. The dependency line looks like "pylance>=X.Y.Z" - update it to "pylance>=${PEP440_VERSION}". | |
| 2. Run "make lock" to update the lock file with the new dependency version. | |
| 3. Run "make lint" to check for any linting issues. If there are issues, run "make fix" to fix them and rerun "make lint" until it passes. | |
| 4. Inspect "git status --short" and "git diff" to confirm the dependency update and any required fixes. | |
| 5. Create and switch to a new branch named "${BRANCH_NAME}" (replace any duplicated hyphens if necessary). | |
| 6. Stage all relevant files with "git add -A". Commit using the message "chore: update pylance dependency to v${PEP440_VERSION}". | |
| 7. Push the branch to origin. If the branch already exists, force-push your changes. | |
| 8. env "GH_TOKEN" is available, use "gh" tools for github related operations like creating pull request. | |
| 9. Create a pull request targeting "main" with title "chore: update pylance dependency to v${PEP440_VERSION}". First, write the PR body to /tmp/pr-body.md using a heredoc (cat <<'EOF' > /tmp/pr-body.md). The body should summarize the dependency bump, linting verification, and link the triggering tag (${TAG}). Then run "gh pr create --body-file /tmp/pr-body.md". | |
| 10. Display the PR URL, "git status --short", and a concise summary of the commands run and their results. | |
| Constraints: | |
| - Use bash commands; avoid modifying GitHub workflow files other than through the scripted task above. | |
| - Do not merge the PR. | |
| - If any command fails, diagnose and fix the issue instead of aborting. | |
| - For pylance compatibility errors, checkout lance-format/lance for source code reference. | |
| - For lance-namespace compatibility errors, checkout lance-format/lance-namespace for source code reference. | |
| EOF | |
| printenv OPENAI_API_KEY | codex login --with-api-key | |
| codex --config shell_environment_policy.ignore_default_excludes=true exec --dangerously-bypass-approvals-and-sandbox "$(cat /tmp/codex-prompt.txt)" |