Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

ci: auto-regenerate poetry.lock when pyproject.toml changes on main

Julio Quinteros Prod7d651dfeb1e
diff --git a/.github/workflows/regenerate-poetry-lock.yml b/.github/workflows/regenerate-poetry-lock.yml
new file mode 100644
index 00000000000..b9747676cee
--- /dev/null
+++ b/.github/workflows/regenerate-poetry-lock.yml
@@ -0,0 +1,69 @@
+name: Regenerate poetry.lock
+
+# Runs whenever pyproject.toml is merged into main (the most common cause of
+# the "pyproject.toml changed significantly since poetry.lock was last generated"
+# CI failure). Can also be triggered manually.
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - pyproject.toml
+ workflow_dispatch:
+
+jobs:
+ regenerate-lock:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: Install Poetry
+ run: pip install poetry
+
+ - name: Regenerate poetry.lock
+ # --no-update: re-solve only what pyproject.toml requires without
+ # upgrading packages that are already in the lock file.
+ run: poetry lock --no-update
+
+ - name: Check whether poetry.lock actually changed
+ id: diff
+ run: |
+ if git diff --quiet poetry.lock; then
+ echo "changed=false" >> "$GITHUB_OUTPUT"
+ else
+ echo "changed=true" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Open PR with the refreshed lock file
+ if: steps.diff.outputs.changed == 'true'
+ run: |
+ BRANCH="auto/regenerate-poetry-lock-$(date +'%Y%m%d%H%M%S')"
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git checkout -b "$BRANCH"
+ git add poetry.lock
+ git commit -m "chore: regenerate poetry.lock to match pyproject.toml"
+ git push origin "$BRANCH"
+ gh pr create \
+ --title "chore: regenerate poetry.lock to match pyproject.toml" \
+ --body "$(cat <<'EOF'
+Automated regeneration of \`poetry.lock\` after \`pyproject.toml\` was updated on \`main\`.
+
+Fixes the recurring CI failure:
+\`\`\`
+pyproject.toml changed significantly since poetry.lock was last generated.
+Run \`poetry lock\` to fix the lock file.
+\`\`\`
+
+Regenerated with \`poetry lock --no-update\` (existing package versions are preserved; only the lock file metadata is updated to match the new constraints).
+EOF
+)" \
+ --head "$BRANCH" \
+ --base main
+ env:
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}