Skip to content

Commit 40ba971

Browse files
committed
Refactor UV sync to composite GitHub Action
Replaces the workflow-based sync-uv implementation with a reusable composite action in .github/actions/sync-uv/action.yml. Updates all workflows to use the new action for dependency synchronization, improving maintainability and modularity.
1 parent 219bee1 commit 40ba971

File tree

7 files changed

+73
-75
lines changed

7 files changed

+73
-75
lines changed

.github/actions/sync-uv/action.yml

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

.github/workflows/docs-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
with:
4343
python-version: "3.13"
4444
- name: "Setup UV"
45-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
45+
uses: ./.github/actions/sync-uv
4646
with:
4747
groups: 'dev,docs'
4848
- name: "Check Links"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
python-version: "3.13"
2323
- name: "Setup UV"
24-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
24+
uses: ./.github/actions/sync-uv
2525
with:
2626
groups: 'dev,docs'
2727
extras: 'speed,voice'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
python-version: "3.13"
2828
- name: "Setup UV"
29-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
29+
uses: ./.github/actions/sync-uv
3030
with:
3131
groups: 'dev,docs'
3232
extras: 'speed,voice'

.github/workflows/lib-checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: "Checkout Repository"
3535
uses: actions/checkout@v5
3636
- name: "Setup UV"
37-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
37+
uses: ./.github/actions/sync-uv
3838
with:
3939
groups: 'dev'
4040
- name: "Run codespell"
@@ -51,7 +51,7 @@ jobs:
5151
with:
5252
python-version: "3.13"
5353
- name: "Setup UV"
54-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
54+
uses: ./.github/actions/sync-uv
5555
with:
5656
groups: 'dev'
5757
- name: "Run ruff linter check"
@@ -69,7 +69,7 @@ jobs:
6969
with:
7070
python-version: "3.13"
7171
- name: "Setup UV"
72-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
72+
uses: ./.github/actions/sync-uv
7373
with:
7474
groups: 'dev'
7575
- name: "Setup cache"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
with:
2626
python-version: "3.13"
2727
- name: "Setup UV"
28-
uses: pycord-development/pycord-next/.github/workflows/sync-uv.yml@master
28+
uses: ./.github/actions/sync-uv
2929
with:
3030
groups: 'dev,ci'
3131
- name: "Run guild features sync"

.github/workflows/sync-uv.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)