diff --git a/.github/workflows/uv-renewal.yaml b/.github/workflows/uv-renewal.yaml new file mode 100644 index 0000000000..21ca3b9401 --- /dev/null +++ b/.github/workflows/uv-renewal.yaml @@ -0,0 +1,71 @@ +--- +# This GitHub action is meant to update the pipfile.locks +name: uv.locks Renewal Action + +on: # yamllint disable-line rule:truthy + # Triggers the workflow every Wednesday at 1am UTC + schedule: + - cron: "0 1 * * 3" + workflow_dispatch: # for manual trigger workflow from GH Web UI + inputs: + branch: + description: 'Specify branch' + required: false + default: 'main' + python_version: + description: 'Select Python version to update uv.lock' + required: false + default: '3.11' + type: choice + options: + - '3.12' + - '3.11' + update_optional_dirs: + description: 'Include optional directories in update' + required: false + default: 'false' + type: choice + options: + - 'true' + - 'false' + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + env: + BRANCH: ${{ github.event.inputs.branch || 'main' }} + PYTHON_VERSION: ${{ github.event.inputs.python_version || '3.11' }} + INCLUDE_OPT_DIRS: ${{ github.event.inputs.update_optional_dirs || 'false' }} + steps: + # Checkout the specified branch from the specified organization + - name: Checkout code from the specified branch + uses: actions/checkout@v4 + with: + ref: ${{ env.BRANCH }} + token: ${{ secrets.GITHUB_TOKEN }} + + # Configure Git + - name: Configure Git + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Actions" + + # Setup Python environment with the specified version (or default to '3.11') + - name: Setup Python environment + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + # Install uv + - name: Install uv + run: pip install uv + + # Run makefile recipe to refresh uv.lock and push changes back to the branch + - name: Run make refresh-pipfilelock-files and push the changes back to the branch + run: | + uv lock --python ${{ env.PYTHON_VERSION }} + git add uv.lock + git commit -m "Update uv.lock files by uvlock-renewal.yaml action" + git push origin ${{ env.BRANCH }} diff --git a/scripts/sync-requirements-txt.sh b/scripts/sync-requirements-txt.sh index d085dd7a9a..829fd23549 100755 --- a/scripts/sync-requirements-txt.sh +++ b/scripts/sync-requirements-txt.sh @@ -5,8 +5,24 @@ set -Eeuxo pipefail # Namely, Konflux (https://konflux-ci.dev/), and Cachi2 (https://github.com/containerbuildsystem/cachi2). # The following will create an extra requirement.txt file for every Pipfile.lock we have. -micropipenv --version || pip install micropipenv -find . -name Pipfile.lock -execdir bash -c ' - echo "# Generated by /scripts/sync-requirements-txt.sh from Pipfile.lock" > requirements.txt && - echo >> requirements.txt && - micropipenv requirements >> requirements.txt' \; +uv --version || pip install uv +cd jupyter +find . -name "requirements.txt" -type f > files.txt +cd .. +while read -r file; do + + echo "Processing $file" + path="${file#./*}" + image_name="${path%/*/*}" + python_version="${path%/*}" + python_version="${python_version##*-}" + + if [[ "$path" == *"rocm/"* ]]; then + image_name="${image_name#*/}-rocm" + fi + + uv pip compile --format requirements.txt --python ${python_version} -o jupyter/${path} --generate-hashes --group jupyter-${image_name}-image --python-platform linux --no-annotate -q + +done < jupyter/files.txt + +rm jupyter/files.txt