Skip to content

Commit cd06e95

Browse files
committed
feat: Setup uv
1 parent e53d4bd commit cd06e95

22 files changed

Lines changed: 3425 additions & 228 deletions

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
/.github/workflows/docs-localization-download.yml @Pycord-Development/maintain-translations
1212
/.github/workflows/docs-localization-upload.yml @Pycord-Development/maintain-translations
1313
/crowdin.yml @Pycord-Development/maintain-translations
14-
/requirements/_locale.txt @Pycord-Development/maintain-translations
1514
/CHANGELOG.md @Pycord-Development/squiddo-typo-check

.github/actions/setup-python-dev/action.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: "Setup repository"
2+
description: "Check out the repository, install uv, and sync the environment from uv.lock."
3+
4+
inputs:
5+
groups:
6+
description: "Dependency groups to sync, comma- or space-separated. Empty syncs no groups."
7+
required: false
8+
default: ""
9+
extras:
10+
description: "Extras to sync, comma- or space-separated. Empty syncs no extras."
11+
required: false
12+
default: ""
13+
frozen:
14+
description: "Sync straight from uv.lock without re-resolving."
15+
required: false
16+
default: "true"
17+
cache:
18+
description: "Cache the uv download and its dependency cache."
19+
required: false
20+
default: "true"
21+
python-version:
22+
description: "Python version to sync against. Defaults to the project's .python-version."
23+
required: false
24+
default: ""
25+
fetch-depth:
26+
description: >-
27+
Checkout depth. Defaults to full history because hatch-vcs derives the
28+
package version from the nearest git tag, and a shallow clone has none.
29+
required: false
30+
default: "0"
31+
32+
runs:
33+
using: "composite"
34+
steps:
35+
- name: "Checkout repository"
36+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
37+
with:
38+
fetch-depth: ${{ inputs.fetch-depth }}
39+
fetch-tags: true
40+
41+
- name: "Install uv"
42+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
43+
with:
44+
enable-cache: ${{ inputs.cache }}
45+
cache-dependency-glob: "uv.lock"
46+
python-version: ${{ inputs.python-version }}
47+
48+
- name: "Sync environment"
49+
shell: bash
50+
env:
51+
INPUT_GROUPS: ${{ inputs.groups }}
52+
INPUT_EXTRAS: ${{ inputs.extras }}
53+
INPUT_FROZEN: ${{ inputs.frozen }}
54+
run: |
55+
set -euo pipefail
56+
57+
args=(--no-default-groups)
58+
if [[ "$INPUT_FROZEN" == "true" ]]; then
59+
args+=(--frozen)
60+
fi
61+
for group in ${INPUT_GROUPS//,/ }; do
62+
args+=(--group "$group")
63+
done
64+
for extra in ${INPUT_EXTRAS//,/ }; do
65+
args+=(--extra "$extra")
66+
done
67+
68+
echo "::notice::uv sync ${args[*]}"
69+
uv sync "${args[@]}"
70+
71+
- name: "Put the synced environment on PATH"
72+
shell: bash
73+
run: |
74+
set -euo pipefail
75+
if [[ "$RUNNER_OS" == "Windows" ]]; then
76+
echo "$GITHUB_WORKSPACE/.venv/Scripts" >> "$GITHUB_PATH"
77+
else
78+
echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
79+
fi

.github/workflows/docs-checks.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ on:
55
paths:
66
- "discord/**"
77
- "docs/**"
8-
- "requirements/**"
8+
- "uv.lock"
99
- ".github/workflows/docs-checks.yml"
1010
- ".readthedocs.yml"
1111
- "LICENSE"
12-
- "MANIFEST.in"
1312
- "README.rst"
1413
- "*.toml"
1514
- "*.py"
@@ -57,11 +56,10 @@ jobs:
5756
const matches = (file) => (
5857
file.startsWith('discord/') ||
5958
file.startsWith('docs/') ||
60-
file.startsWith('requirements/') ||
59+
file === 'uv.lock' ||
6160
file === '.github/workflows/docs-checks.yml' ||
6261
file === '.readthedocs.yml' ||
6362
file === 'LICENSE' ||
64-
file === 'MANIFEST.in' ||
6563
file === 'README.rst' ||
6664
(!file.includes('/') && file.endsWith('.toml')) ||
6765
(!file.includes('/') && file.endsWith('.py'))
@@ -83,19 +81,12 @@ jobs:
8381
if: ${{ needs.changes.outputs.docs == 'true' }}
8482
runs-on: ubuntu-latest
8583
steps:
86-
- name: "Checkout Repository"
87-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
88-
- name: "Setup Python"
89-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
84+
- name: "Setup repository"
85+
uses: ./.github/actions/setup-repo
9086
with:
9187
python-version: "3.14"
92-
cache: "pip"
93-
cache-dependency-path: "requirements/docs.txt"
94-
check-latest: true
95-
- name: Install dependencies
96-
run: |
97-
python -m pip install -U pip
98-
pip install ".[docs,voice]"
88+
groups: "docs"
89+
extras: "voice"
9990
- name: "Check Links"
10091
if: ${{ github.event_name == 'schedule' || inputs.with_linkcheck }}
10192
run: |

.github/workflows/docs-json-export.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,12 @@ jobs:
1111
name: Export docs.json
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Checkout repository
15-
id: checkout
16-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17-
- name: Set up Python
18-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
19-
id: setup-python
14+
- name: "Setup repository"
15+
uses: ./.github/actions/setup-repo
2016
with:
2117
python-version: "3.14"
22-
cache: "pip"
23-
cache-dependency-path: "requirements/docs.txt"
24-
check-latest: true
25-
- name: Install dependencies
26-
id: install-deps
27-
run: |
28-
python -m pip install -U pip
29-
pip install ".[docs,voice]"
30-
pip install beautifulsoup4
18+
groups: "docs"
19+
extras: "voice"
3120
- name: Build Sphinx HTML docs
3221
id: build-sphinx
3322
run: sphinx-build -b html docs docs/_build/html

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,12 @@ jobs:
1515
pr_ref: ${{ steps.convert_outputs.outputs.pr_ref }}
1616
pr_id: ${{ steps.convert_outputs.outputs.pr_id }}
1717
steps:
18-
- name: "Checkout Repository"
19-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20-
with:
21-
fetch-tags: true
22-
- name: "Install Python"
23-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
18+
- name: "Setup repository"
19+
uses: ./.github/actions/setup-repo
2420
with:
2521
python-version: "3.14"
26-
cache: "pip"
27-
cache-dependency-path: "requirements/_locale.txt"
28-
- name: "Install Dependencies"
29-
run: |
30-
python -m pip install --upgrade pip setuptools wheel
31-
pip install -r requirements/_locale.txt
32-
pip install .[speed,voice,docs]
22+
groups: "docs"
23+
extras: "speed,voice"
3324
- name: "Get locales"
3425
run: |
3526
make html

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,12 @@ jobs:
2020
if: ${{ contains(github.event.head_commit.message, '!crowdin upload') || github.event_name == 'workflow_dispatch' }}
2121
environment: translations
2222
steps:
23-
- name: "Checkout Repository"
24-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25-
with:
26-
fetch-tags: true
27-
- name: "Install Python"
28-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
23+
- name: "Setup repository"
24+
uses: ./.github/actions/setup-repo
2925
with:
3026
python-version: "3.14"
31-
cache: "pip"
32-
cache-dependency-path: "requirements/_locale.txt"
33-
- name: "Install Dependencies"
34-
run: |
35-
python -m pip install --upgrade pip setuptools wheel
36-
pip install -r requirements/_locale.txt
37-
pip install .[speed,voice,docs]
27+
groups: "docs"
28+
extras: "speed,voice"
3829
- name: "Get locales"
3930
run: |
4031
make html

.github/workflows/lib-checks.yml

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ on:
55
paths:
66
- "discord/**"
77
- "examples/**"
8-
- "requirements/**"
8+
- "uv.lock"
99
- "tests/**"
1010
- ".github/actions/**"
1111
- ".github/workflows/lib-checks.yml"
1212
- "LICENSE"
13-
- "MANIFEST.in"
1413
- "README.rst"
1514
- "*.toml"
1615
- "*.py"
@@ -54,12 +53,11 @@ jobs:
5453
const matches = (file) => (
5554
file.startsWith('discord/') ||
5655
file.startsWith('examples/') ||
57-
file.startsWith('requirements/') ||
56+
file === 'uv.lock' ||
5857
file.startsWith('tests/') ||
5958
file.startsWith('.github/actions/') ||
6059
file === '.github/workflows/lib-checks.yml' ||
6160
file === 'LICENSE' ||
62-
file === 'MANIFEST.in' ||
6361
file === 'README.rst' ||
6462
(!file.includes('/') && file.endsWith('.toml')) ||
6563
(!file.includes('/') && file.endsWith('.py')) ||
@@ -82,12 +80,11 @@ jobs:
8280
if: ${{ needs.changes.outputs.lib == 'true' && github.event_name != 'schedule' }}
8381
runs-on: ubuntu-latest
8482
steps:
85-
- name: "Checkout Repository"
86-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
87-
- name: "Setup Python dev environment"
88-
uses: ./.github/actions/setup-python-dev
83+
- name: "Setup repository"
84+
uses: ./.github/actions/setup-repo
8985
with:
9086
python-version: "3.14"
87+
groups: "dev"
9188
- name: "Run codespell"
9289
run:
9390
codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \
@@ -97,25 +94,23 @@ jobs:
9794
if: ${{ needs.changes.outputs.lib == 'true' && github.event_name != 'schedule' }}
9895
runs-on: ubuntu-latest
9996
steps:
100-
- name: "Checkout Repository"
101-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
102-
- name: "Setup Python dev environment"
103-
uses: ./.github/actions/setup-python-dev
97+
- name: "Setup repository"
98+
uses: ./.github/actions/setup-repo
10499
with:
105100
python-version: "3.14"
101+
groups: "dev"
106102
- name: "Run bandit"
107103
run: bandit --recursive --skip B101,B104,B105,B110,B307,B311,B404,B603,B607 .
108104
pylint:
109105
needs: [ changes ]
110106
if: ${{ needs.changes.outputs.lib == 'true' && github.event_name != 'schedule' }}
111107
runs-on: ubuntu-latest
112108
steps:
113-
- name: "Checkout Repository"
114-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
115-
- name: "Setup Python dev environment"
116-
uses: ./.github/actions/setup-python-dev
109+
- name: "Setup repository"
110+
uses: ./.github/actions/setup-repo
117111
with:
118112
python-version: "3.14"
113+
groups: "dev"
119114
- name: "Setup cache"
120115
id: cache-pylint
121116
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -131,12 +126,11 @@ jobs:
131126
if: ${{ needs.changes.outputs.lib == 'true' && github.event_name != 'schedule' }}
132127
runs-on: ubuntu-latest
133128
steps:
134-
- name: "Checkout Repository"
135-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
136-
- name: "Setup Python dev environment"
137-
uses: ./.github/actions/setup-python-dev
129+
- name: "Setup repository"
130+
uses: ./.github/actions/setup-repo
138131
with:
139132
python-version: "3.14"
133+
groups: "dev"
140134
- name: "Setup cache"
141135
id: cache-mypy
142136
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -155,12 +149,11 @@ jobs:
155149
if: ${{ needs.changes.outputs.lib == 'true' }}
156150
runs-on: ubuntu-latest
157151
steps:
158-
- name: "Checkout Repository"
159-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
160-
- name: "Setup Python dev environment"
161-
uses: ./.github/actions/setup-python-dev
152+
- name: "Setup repository"
153+
uses: ./.github/actions/setup-repo
162154
with:
163155
python-version: "3.14"
156+
groups: "dev"
164157
- name: "Lint with flake8"
165158
run: |
166159
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
@@ -174,13 +167,11 @@ jobs:
174167
os: [ ubuntu-latest, windows-latest, macos-latest ]
175168
python-version: [ "3.10", "3.14" ]
176169
steps:
177-
- name: "Checkout Repository"
178-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
179-
- name: "Setup Python dev environment"
180-
uses: ./.github/actions/setup-python-dev
170+
- name: "Setup repository"
171+
uses: ./.github/actions/setup-repo
181172
with:
182173
python-version: ${{ matrix.python-version }}
183-
install-voice: "true"
174+
groups: "dev"
184175

185176
- name: "Run tests"
186177
run: tox
@@ -193,13 +184,11 @@ jobs:
193184
os: [ ubuntu-latest, windows-latest, macos-latest ]
194185
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
195186
steps:
196-
- name: "Checkout Repository"
197-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
198-
- name: "Setup Python dev environment"
199-
uses: ./.github/actions/setup-python-dev
187+
- name: "Setup repository"
188+
uses: ./.github/actions/setup-repo
200189
with:
201190
python-version: ${{ matrix.python-version }}
202-
install-voice: "true"
191+
groups: "dev"
203192

204193
- name: "Run tests"
205194
run: tox

0 commit comments

Comments
 (0)