diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3993cc2..311718b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,6 +2,7 @@ name: Test on: pull_request: + types: [opened, labeled, reopened, synchronize] workflow_dispatch: @@ -10,6 +11,12 @@ on: - trunk jobs: + debug: + name: Show debugging information + runs-on: ubuntu-latest + steps: + - run: echo '${{ toJSON(github) }}' + setup_uv_default: name: setup-uv [default] runs-on: ubuntu-latest @@ -96,13 +103,21 @@ jobs: - run: cargo bundle-licenses --version update_conda_lockfiles: - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'update-conda-lockfiles' && contains(github.event.pull_request.labels.*.name, 'test-conda-lockfiles') }} + if: ${{ github.event_name == 'pull_request' && github.head_ref != 'update-conda-lockfiles' && contains(github.event.pull_request.labels.*.name, 'test-conda-lockfiles') }} uses: ./.github/workflows/update-conda-lockfiles.yaml secrets: inherit with: - branch: ${{ github.event.pull_request.head.ref }} + branch: ${{ github.head_ref }} path: test/update-conda-lockfile + update_uv_lockfiles: + if: ${{ github.event_name == 'pull_request' && github.head_ref != 'update-uv-lockfiles' && contains(github.event.pull_request.labels.*.name, 'test-uv-lockfiles') }} + uses: ./.github/workflows/update-uv-lockfiles.yaml + secrets: inherit + with: + branch: ${{ github.head_ref }} + path: test/update-uv-lockfile + setup_row: name: setup-row [default] runs-on: ubuntu-latest diff --git a/.github/workflows/update-uv-lockfiles.yaml b/.github/workflows/update-uv-lockfiles.yaml new file mode 100644 index 0000000..0c8015e --- /dev/null +++ b/.github/workflows/update-uv-lockfiles.yaml @@ -0,0 +1,62 @@ +name: Update uv lockfiles + +on: + workflow_call: + inputs: + branch: + required: true + type: string + command: + default: ./update-lockfiles.sh + required: false + type: string + path: + default: .github/workflows/environments + required: false + type: string + +jobs: + update: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + with: + path: code + ref: ${{ inputs.branch }} + + - uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 + id: generate-token + with: + app-id: ${{ secrets.PR_SUBMITTER_APP_ID }} + private-key: ${{ secrets.PR_SUBMITTER_PRIVATE_KEY }} + + - name: Create python environment + uses: mamba-org/setup-micromamba@617811f69075e3fd3ae68ca64220ad065877f246 # v2.0.0 + with: + micromamba-version: '1.5.8-0' + environment-name: update + create-args: >- + python=3.12 + uv + micromamba-root-path: ${{ github.workspace }}/micromamba + + - name: Configure conda environment variables + run: | + echo "$MAMBA_ROOT_PREFIX/envs/update/bin" >> $GITHUB_PATH + + - name: Update lockfiles + run: ${{ inputs.command }} + working-directory: code/${{ inputs.path }} + + - name: Create pull request + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 + with: + base: ${{ inputs.branch }} + path: code + commit-message: "Update uv lockfiles" + branch: update-uv-lockfiles + delete-branch: true + title: Update uv lockfiles on ${{ inputs.branch }} + body: Automated changes by `${{ inputs.command }}`. + token: ${{ steps.generate-token.outputs.token }} diff --git a/README.md b/README.md index 31520c6..376ff82 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,29 @@ To automatically update conda lock files monthly: with: branch: ``` + +## update-uv-lockfiles + +To automatically update uv lock files monthly: +1. Prepare a directory with the base `requirements-*.in` files and a script that updates + all lock files (see + https://github.com/glotzerlab/rowan/tree/master/.github/workflows for an example). +2. Ask an organization admin to install the pull request submitter bot. +3. Create a workflow `update-uv-lockfiles.yaml` with the contents: + + ```yaml + name: Update uv lockfiles + + on: + schedule: + - cron: '0 12 1 * *' + + workflow_dispatch: + + jobs: + update: + uses: glotzerlab/workflows/.github/workflows/update-uv-lockfiles.yaml@0d90feacda686e08bfecc451fc04a8596bd295f5 # 0.4.0 + secrets: inherit + with: + branch: + ``` diff --git a/test/update-uv-lockfile/requirements.in b/test/update-uv-lockfile/requirements.in new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/test/update-uv-lockfile/requirements.in @@ -0,0 +1 @@ +build diff --git a/test/update-uv-lockfile/requirements.txt b/test/update-uv-lockfile/requirements.txt new file mode 100644 index 0000000..9c344d0 --- /dev/null +++ b/test/update-uv-lockfile/requirements.txt @@ -0,0 +1,8 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile --python-version 3.13 --python-platform linux requirements.in +build==1.1.1 + # via -r requirements.in +packaging==24.1 + # via build +pyproject-hooks==1.2.0 + # via build diff --git a/test/update-uv-lockfile/update-lockfiles.sh b/test/update-uv-lockfile/update-lockfiles.sh new file mode 100755 index 0000000..a37c865 --- /dev/null +++ b/test/update-uv-lockfile/update-lockfiles.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Execute this script to update all lock files to the latest versions of dependencies. + +rm -f requirements*.txt + +uv pip compile --python-version 3.13 --python-platform linux requirements.in > requirements.txt