@@ -25,6 +25,10 @@ defaults:
25
25
shell : bash
26
26
27
27
env :
28
+ # https://docs.astral.sh/uv/reference/environment/
29
+ UV_LOCKED : 1
30
+ UV_NO_SYNC : 1
31
+ UV_PYTHON_DOWNLOADS : never
28
32
GITHUB_STEP_SUMMARY_HEADER : " <details><summary>#name#</summary>\n <pre>"
29
33
GITHUB_STEP_SUMMARY_FOOTER : " </pre></details>\n "
30
34
@@ -36,15 +40,48 @@ jobs:
36
40
# while still not needing to commit a lockfile to the repo, which is discouraged for libraries as per
37
41
# https://pdm-project.org/en/latest/usage/lockfile/
38
42
runs-on : ubuntu-latest
43
+ env :
44
+ UV_RESOLUTION : highest
39
45
steps :
40
46
- uses : actions/checkout@v4
41
47
42
- # Instead of setup-env, we call the cache-pdm action here directly.
43
- # This avoids having to install PDM, only to find out the cache is already up to date sometimes.
44
- - name : Configure cache
45
- uses : ./.github/actions/cache-pdm
48
+ - name : Set up environment
49
+ id : setup-env
50
+ uses : ./.github/actions/setup-env
51
+ with :
52
+ use-cached-uv-lock : ' false' # we don't need the lock here, we will automatically download it below
53
+
54
+ - name : Restore uv lock
55
+ uses : actions/cache/restore@v4
56
+ id : cache-uv-lock
46
57
with :
47
- env-already-initialized : false
58
+ key : uv-lock-resolved-${{ env.UV_RESOLUTION }}
59
+ restore-keys : |
60
+ uv-lock-resolved-${{ env.UV_RESOLUTION }}
61
+ path : uv.lock
62
+ enableCrossOsArchive : true
63
+
64
+ - name : Check if uv.lock changed
65
+ id : uv-lock-changed
66
+ continue-on-error : true
67
+ if : steps.cache-uv-lock.outputs.cache-hit == 'true' || steps.cache-uv-lock.outputs.cache-hit == 'false'
68
+ run : |
69
+ uv lock --check
70
+
71
+ - name : Lock dependencies
72
+ if : steps.uv-lock-changed.outcome == 'failure' || steps.cache-uv-lock.outputs.cache-hit != 'true' && steps.cache-uv-lock.outputs.cache-hit != 'false'
73
+ id : lock-uv-deps
74
+ env :
75
+ UV_LOCKED : 0
76
+ run : uv lock --refresh
77
+
78
+ - uses : actions/cache/save@v4
79
+ if : steps.lock-uv-deps.outcome == 'success'
80
+ name : upload-uv-lock
81
+ with :
82
+ key : uv-lock-resolved-${{ env.UV_RESOLUTION }}-${{ hashFiles('uv.lock') }}
83
+ path : uv.lock
84
+ enableCrossOsArchive : true
48
85
49
86
# Used to determine which python versions to test against.
50
87
# noxfile.py is the source of truth, which in turn draws from
62
99
- name : Set up environment
63
100
uses : ./.github/actions/setup-env
64
101
with :
65
- python-version : 3.8
102
+ use-cached-uv-lock : ' false ' # we don't need the lock here
66
103
67
104
- name : Determine Python versions to test and lint against
68
105
id : set-matrix
@@ -120,7 +157,6 @@ jobs:
120
157
- lint
121
158
strategy :
122
159
matrix :
123
- # TODO: add 3.14 once we switch to uv
124
160
session : ${{ fromJson(needs.python-versions.outputs.pyright-sessions) }}
125
161
fail-fast : false
126
162
continue-on-error : ${{ matrix.session.experimental }}
@@ -136,9 +172,9 @@ jobs:
136
172
- name : Add .venv/bin to PATH
137
173
id : venv-bin
138
174
run : |
139
- pdm venv create
140
- dirname "$(pdm info -- python)" >> $GITHUB_PATH
141
- echo python="$(pdm info -- python)" >> $GITHUB_OUTPUT
175
+ uv venv .venv
176
+ dirname "$(uv python find )" >> $GITHUB_PATH
177
+ echo python="$(uv python find )" >> $GITHUB_OUTPUT
142
178
143
179
- name : Install dependencies
144
180
# `--no-venv` to install in the main pdm venv instead of nox's pyright-specific one
@@ -196,21 +232,15 @@ jobs:
196
232
run : |
197
233
nox -s slotscheck
198
234
199
- - name : Run check-manifest
200
- if : (success() || failure()) && steps.setup.outcome == 'success'
201
- run : nox -s check-manifest
202
-
203
- # This only runs if the previous steps were successful, no point in running it otherwise
204
235
- name : Try building package
236
+ if : (success() || failure()) && steps.setup.outcome == 'success'
205
237
run : |
206
- pdm install -dG build
207
-
208
- pdm run python -m build
238
+ nox -s build
209
239
ls -la dist/
210
240
211
241
- name : Check README.md renders properly on PyPI
212
242
run : |
213
- pdm run twine check --strict dist/*
243
+ uvx twine~=6.1 check --strict dist/*
214
244
215
245
codemod :
216
246
runs-on : ubuntu-latest
@@ -237,7 +267,7 @@ jobs:
237
267
if [ -n "$(git status --porcelain)" ]; then
238
268
echo "::error::Please run 'nox -s codemod -- run-all' locally and commit the changes." >&2;
239
269
echo "$GITHUB_STEP_SUMMARY_HEADER" | sed "s/#name#/LibCST Codemod/" >> $GITHUB_STEP_SUMMARY
240
- echo "The libcst codemod made changes to the codebase. Please run 'nox -s codemod -- run-all' locally and commit the changes." >> $GITHUB_STEP_SUMMARY
270
+ echo "The libcst codemod made changes to the codebase. Please run 'uv run nox -s codemod -- run-all' locally and commit the changes." >> $GITHUB_STEP_SUMMARY
241
271
echo "::group::git diff"
242
272
git diff |& tee -a $GITHUB_STEP_SUMMARY
243
273
echo "::endgroup::"
@@ -256,7 +286,6 @@ jobs:
256
286
strategy :
257
287
matrix :
258
288
os : ["windows-latest", "ubuntu-latest", "macos-latest"]
259
- # TODO: add 3.14 once we switch to uv
260
289
session : ${{ fromJson(needs.python-versions.outputs.test-sessions) }}
261
290
fail-fast : true
262
291
continue-on-error : ${{ matrix.session.experimental }}
@@ -288,6 +317,7 @@ jobs:
288
317
- name : Print Coverage Output
289
318
if : always() && (steps.run_tests.outcome == 'success' || steps.run_tests.outcome == 'failure')
290
319
env :
320
+ UV_NO_SYNC : 0
291
321
NOXSESSION : coverage
292
322
run : |
293
323
echo "$GITHUB_STEP_SUMMARY_HEADER" | sed "s/#name#/Coverage Summary/" >> $GITHUB_STEP_SUMMARY
0 commit comments