Skip to content

Commit 931e888

Browse files
Paillat-devLulalaby
authored andcommitted
👷 Create a reusable workflow for UV and make UV lockfile frozen
1 parent d58ea74 commit 931e888

File tree

6 files changed

+91
-39
lines changed

6 files changed

+91
-39
lines changed

.github/workflows/docs-checks.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ jobs:
4141
uses: actions/setup-python@v5
4242
with:
4343
python-version: "3.13"
44-
- name: "Install uv"
45-
uses: astral-sh/setup-uv@v6
44+
- name: "Setup UV"
45+
uses: ./.github/workflows/sync-uv.yml
4646
with:
47-
enable-cache: true
48-
- name: Sync dependencies
49-
run: uv sync --no-python-downloads --group dev --group docs
47+
groups: 'dev,docs'
5048
- name: "Check Links"
5149
env:
5250
SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build

.github/workflows/docs-localization-download.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ jobs:
2020
uses: actions/setup-python@v5
2121
with:
2222
python-version: "3.13"
23-
- name: "Install uv"
24-
uses: astral-sh/setup-uv@v6
23+
- name: "Setup UV"
24+
uses: ./.github/workflows/sync-uv.yml
2525
with:
26-
enable-cache: true
27-
- name: Sync dependencies
28-
run: uv sync --no-python-downloads --group dev --group docs --extra speed --extra voice
26+
groups: 'dev,docs'
27+
extras: 'speed,voice'
2928
- name: "Get locales"
3029
env:
3130
SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build

.github/workflows/docs-localization-upload.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ jobs:
2525
uses: actions/setup-python@v5
2626
with:
2727
python-version: "3.13"
28-
- name: "Install uv"
29-
uses: astral-sh/setup-uv@v6
28+
- name: "Setup UV"
29+
uses: ./.github/workflows/sync-uv.yml
3030
with:
31-
enable-cache: true
32-
- name: Sync dependencies
33-
run: uv sync --no-python-downloads --group dev --group docs --extra speed --extra voice
31+
groups: 'dev,docs'
32+
extras: 'speed,voice'
3433
- name: "Get locales"
3534
env:
3635
SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build

.github/workflows/lib-checks.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,10 @@ jobs:
3333
steps:
3434
- name: "Checkout Repository"
3535
uses: actions/checkout@v5
36-
- name: "Setup Python"
37-
uses: actions/setup-python@v5
38-
with:
39-
python-version: "3.13"
40-
- name: "Install uv"
41-
uses: astral-sh/setup-uv@v6
36+
- name: "Setup UV"
37+
uses: ./.github/workflows/sync-uv.yml
4238
with:
43-
enable-cache: true
44-
- name: Sync dependencies
45-
run: uv sync --no-python-downloads --group dev
39+
groups: 'dev'
4640
- name: "Run codespell"
4741
run:
4842
uv run codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \
@@ -56,12 +50,10 @@ jobs:
5650
uses: actions/setup-python@v5
5751
with:
5852
python-version: "3.13"
59-
- name: "Install uv"
60-
uses: astral-sh/setup-uv@v6
53+
- name: "Setup UV"
54+
uses: ./.github/workflows/sync-uv.yml
6155
with:
62-
enable-cache: true
63-
- name: Sync dependencies
64-
run: uv sync --no-python-downloads --group dev
56+
groups: 'dev'
6557
- name: "Run ruff linter check"
6658
run: uv run ruff check discord/
6759
- name: "Run ruff formatter check"
@@ -76,12 +68,10 @@ jobs:
7668
uses: actions/setup-python@v5
7769
with:
7870
python-version: "3.13"
79-
- name: "Install uv"
80-
uses: astral-sh/setup-uv@v6
71+
- name: "Setup UV"
72+
uses: ./.github/workflows/sync-uv.yml
8173
with:
82-
enable-cache: true
83-
- name: Sync dependencies
84-
run: uv sync --no-python-downloads --group dev
74+
groups: 'dev'
8575
- name: "Setup cache"
8676
id: cache-mypy
8777
uses: actions/cache@v4

.github/workflows/sync-guild-features.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ jobs:
2424
uses: actions/setup-python@v5
2525
with:
2626
python-version: "3.13"
27-
- name: "Install uv"
28-
uses: astral-sh/setup-uv@v6
27+
- name: "Setup UV"
28+
uses: ./.github/workflows/sync-uv.yml
2929
with:
30-
enable-cache: true
31-
- name: Sync dependencies
32-
run: uv sync --no-python-downloads --group dev --group ci
30+
groups: 'dev,ci'
3331
- name: "Run guild features sync"
3432
run: uv run python -m scripts.sync_guild_features
3533
env:

.github/workflows/sync-uv.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Sync UV
2+
on:
3+
workflow_call:
4+
inputs:
5+
groups:
6+
description: "Comma-separated list of groups to sync"
7+
required: false
8+
type: string
9+
default: ''
10+
extras:
11+
description: "Comma-separated list of extras to sync"
12+
required: false
13+
type: string
14+
default: ''
15+
frozen:
16+
description: "Whether to sync with frozen dependencies"
17+
required: false
18+
type: boolean
19+
default: true
20+
no_python_downloads:
21+
description: "Whether to avoid downloading Python versions"
22+
required: false
23+
type: boolean
24+
default: true
25+
26+
jobs:
27+
sync:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: "Install uv"
31+
uses: astral-sh/setup-uv@v6
32+
with:
33+
enable-cache: true
34+
35+
- name: "Build groups args"
36+
id: groups
37+
run: |
38+
args=""
39+
if [ -n "${{ inputs.groups }}" ]; then
40+
IFS=',' read -ra GROUPS <<< "${{ inputs.groups }}"
41+
for group in "${GROUPS[@]}"; do
42+
group=$(echo "$group" | xargs)
43+
[ -n "$group" ] && args="$args --group $(printf %q "$group")"
44+
done
45+
fi
46+
echo "value=$args" >> $GITHUB_OUTPUT
47+
48+
- name: "Build extras args"
49+
id: extras
50+
run: |
51+
args=""
52+
if [ -n "${{ inputs.extras }}" ]; then
53+
IFS=',' read -ra EXTRAS <<< "${{ inputs.extras }}"
54+
for extra in "${EXTRAS[@]}"; do
55+
extra=$(echo "$extra" | xargs)
56+
[ -n "$extra" ] && args="$args --extra $(printf %q "$extra")"
57+
done
58+
fi
59+
echo "value=$args" >> $GITHUB_OUTPUT
60+
61+
- name: "Run UV sync"
62+
run: |
63+
cmd="uv sync${{ steps.groups.outputs.value }}${{ steps.extras.outputs.value }}"
64+
echo "Executing: $cmd"
65+
eval "$cmd"
66+
env:
67+
UV_NO_PYTHON_DOWNLOADS: ${{ inputs.no_python_downloads && '1' || '' }}
68+
UV_FROZEN: ${{ inputs.frozen && '1' || '' }}

0 commit comments

Comments
 (0)