Skip to content

Commit 153b148

Browse files
ci: add check for uv lockfile consistency with pyproject.toml
1 parent 7b84f8c commit 153b148

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/uv-lock-checks.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Check the `uv` lockfile for consistency with `pyproject.toml`.
2+
3+
name: 'uv lock checks'
4+
5+
on:
6+
push:
7+
branches:
8+
- 'main'
9+
pull_request:
10+
types:
11+
- 'ready_for_review'
12+
- 'opened'
13+
- 'synchronize'
14+
merge_group:
15+
workflow_dispatch:
16+
inputs:
17+
always_run:
18+
description: 'Always run the checks'
19+
required: true
20+
type: boolean
21+
default: true
22+
workflow_call:
23+
inputs:
24+
always_run:
25+
description: 'Always run the checks'
26+
required: true
27+
type: boolean
28+
default: true
29+
30+
jobs:
31+
python-checks:
32+
env:
33+
# uv requires a venv by default - but for this, we can simply use the system python
34+
UV_SYSTEM_PYTHON: 1
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 5 # expected run time: <1 min
37+
steps:
38+
- name: checkout
39+
uses: actions/checkout@v4
40+
41+
- name: check for changed python files
42+
if: ${{ inputs.always_run != true }}
43+
id: changed-files
44+
# Pinned to the _hash_ for v45.0.9 to prevent supply-chain attacks.
45+
# See:
46+
# - CVE-2025-30066
47+
# - https://www.stepsecurity.io/blog/harden-runner-detection-tj-actions-changed-files-action-is-compromised
48+
# - https://github.com/tj-actions/changed-files/issues/2463
49+
uses: tj-actions/changed-files@a284dc1814e3fd07f2e34267fc8f81227ed29fb8
50+
with:
51+
files_yaml: |
52+
uvlock-pyprojecttoml:
53+
- 'pyproject.toml'
54+
- 'uv.lock'
55+
56+
- name: setup uv
57+
if: ${{ steps.changed-files.outputs.uvlock-pyprojecttoml_any_changed == 'true' || inputs.always_run == true }}
58+
uses: astral-sh/setup-uv@v5
59+
with:
60+
version: '0.6.10'
61+
enable-cache: true
62+
63+
- name: check lockfile
64+
if: ${{ steps.changed-files.outputs.uvlock-pyprojecttoml_any_changed == 'true' || inputs.always_run == true }}
65+
run: uv lock --locked # this will exit with 1 if the lockfile is not consistent with pyproject.toml
66+
shell: bash

0 commit comments

Comments
 (0)