Skip to content

Commit

Permalink
Merge pull request #17 from glotzerlab/implement-update-uv-lockfiles
Browse files Browse the repository at this point in the history
Implement update uv lockfiles
  • Loading branch information
joaander authored Oct 28, 2024
2 parents 8d3ef30 + 125a62c commit e130dd2
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Test

on:
pull_request:
types: [opened, labeled, reopened, synchronize]

workflow_dispatch:

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/update-uv-lockfiles.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,29 @@ To automatically update conda lock files monthly:
with:
branch: <name of default 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: <name of default branch>
```
1 change: 1 addition & 0 deletions test/update-uv-lockfile/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
8 changes: 8 additions & 0 deletions test/update-uv-lockfile/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/update-uv-lockfile/update-lockfiles.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e130dd2

Please sign in to comment.