Generate UV Lockfile #21
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 only | |
| jobs: | |
| generate-lockfile: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Free up massive disk space BEFORE pulling container | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h | |
| # Remove EVERYTHING unnecessary from the runner | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo rm -rf /usr/local/share/boost | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*' azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true | |
| sudo apt-get autoremove -y | |
| sudo apt-get clean | |
| sudo docker system prune -a -f | |
| echo "Disk space after cleanup:" | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Generate lockfile in NGC container | |
| run: | | |
| docker run --rm \ | |
| -v $PWD:/workspace \ | |
| -w /workspace \ | |
| nvcr.io/nvidia/pytorch:25.09-py3 \ | |
| bash -c ' | |
| # Install uv | |
| curl -LsSf https://astral.sh/uv/0.8.22/install.sh | sh | |
| export PATH="$HOME/.local/bin:$PATH" | |
| # Create venv with system packages (this makes container torch available) | |
| uv venv /opt/venv --system-site-packages | |
| export UV_PROJECT_ENVIRONMENT=/opt/venv | |
| # Pre-install build dependencies before any sync/lock operation | |
| uv pip install setuptools wheel pybind11 "Cython>=3.0.0" "numpy<2.0.0" ninja packaging | |
| # Generate lockfile with the EXACT configuration from pyproject.toml | |
| # No modifications! This ensures lockfile matches what Dockerfile will use | |
| uv lock --no-build-isolation | |
| # Show disk usage | |
| df -h | |
| ' | |
| - 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: Upload lockfile artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: uv-lockfile | |
| path: uv.lock | |
| retention-days: 7 | |
| - 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 | |
| }); |