generate lockfile update #5
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
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | |
| # | |
| # 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: Generate UV Lockfile | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| push: | |
| branches: | |
| - main | |
| - 'pull-request/**' | |
| paths: | |
| - 'pyproject.toml' | |
| - '.github/workflows/generate-lockfile.yml' | |
| pull_request: | |
| paths: | |
| - 'pyproject.toml' | |
| - '.github/workflows/generate-lockfile.yml' | |
| jobs: | |
| generate-lockfile: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Free up disk space | |
| run: | | |
| # Remove unnecessary packages to free up space | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/boost | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| sudo apt-get clean | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/0.8.22/install.sh | sh | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Install build dependencies | |
| run: | | |
| # Install minimal dependencies needed for lockfile generation | |
| # Using CPU-only torch is sufficient - we're only resolving versions, not running CUDA code | |
| uv pip install --system setuptools torch --index-url https://download.pytorch.org/whl/cpu | |
| uv pip install --system packaging ninja pybind11 Cython "numpy<2.0.0" | |
| - name: Generate lockfile | |
| run: | | |
| uv lock | |
| - name: Upload lockfile artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: uv-lockfile | |
| path: uv.lock | |
| retention-days: 7 | |
| - name: Check for lockfile changes | |
| id: check_changes | |
| run: | | |
| if git diff --quiet uv.lock; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit lockfile (if changed) | |
| if: steps.check_changes.outputs.changed == 'true' && github.event_name == 'workflow_dispatch' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add uv.lock | |
| git commit -m "Update uv.lock [skip ci]" | |
| git push origin HEAD:${{ github.ref_name }} | |
| - name: Comment on PR with lockfile status | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const changed = '${{ steps.check_changes.outputs.changed }}'; | |
| const message = changed === 'true' | |
| ? '⚠️ **uv.lock needs to be regenerated**\n\nThe lockfile is out of sync with pyproject.toml. Please run the "Generate UV Lockfile" workflow manually or regenerate locally on Linux.' | |
| : '✅ **uv.lock is up to date**\n\nThe lockfile is in sync with pyproject.toml.'; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: message | |
| }); |