Skip to content

Commit a30eb6f

Browse files
authored
👷 Use uv in CI (fastapi#12281)
1 parent 3347f0d commit a30eb6f

File tree

7 files changed

+115
-54
lines changed

7 files changed

+115
-54
lines changed

.github/workflows/build-docs.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
types:
88
- opened
99
- synchronize
10+
11+
env:
12+
UV_SYSTEM_PYTHON: 1
13+
1014
jobs:
1115
changes:
1216
runs-on: ubuntu-latest
@@ -48,18 +52,20 @@ jobs:
4852
uses: actions/setup-python@v5
4953
with:
5054
python-version: "3.11"
51-
- uses: actions/cache@v4
52-
id: cache
55+
- name: Setup uv
56+
uses: astral-sh/setup-uv@v3
5357
with:
54-
path: ${{ env.pythonLocation }}
55-
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-insiders.txt', 'requirements-docs-tests.txt') }}-v08
58+
version: "0.4.15"
59+
enable-cache: true
60+
cache-dependency-glob: |
61+
requirements**.txt
62+
pyproject.toml
5663
- name: Install docs extras
57-
if: steps.cache.outputs.cache-hit != 'true'
58-
run: pip install -r requirements-docs.txt
64+
run: uv pip install -r requirements-docs.txt
5965
# Install MkDocs Material Insiders here just to put it in the cache for the rest of the steps
6066
- name: Install Material for MkDocs Insiders
61-
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
62-
run: pip install -r requirements-docs-insiders.txt
67+
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
68+
run: uv pip install -r requirements-docs-insiders.txt
6369
env:
6470
TOKEN: ${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}
6571
- name: Verify Docs
@@ -88,17 +94,19 @@ jobs:
8894
uses: actions/setup-python@v5
8995
with:
9096
python-version: "3.11"
91-
- uses: actions/cache@v4
92-
id: cache
97+
- name: Setup uv
98+
uses: astral-sh/setup-uv@v3
9399
with:
94-
path: ${{ env.pythonLocation }}
95-
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-insiders.txt', 'requirements-docs-tests.txt') }}-v08
100+
version: "0.4.15"
101+
enable-cache: true
102+
cache-dependency-glob: |
103+
requirements**.txt
104+
pyproject.toml
96105
- name: Install docs extras
97-
if: steps.cache.outputs.cache-hit != 'true'
98-
run: pip install -r requirements-docs.txt
106+
run: uv pip install -r requirements-docs.txt
99107
- name: Install Material for MkDocs Insiders
100-
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
101-
run: pip install -r requirements-docs-insiders.txt
108+
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
109+
run: uv pip install -r requirements-docs-insiders.txt
102110
env:
103111
TOKEN: ${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}
104112
- name: Update Languages

.github/workflows/deploy-docs.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ permissions:
1212
pull-requests: write
1313
statuses: write
1414

15+
env:
16+
UV_SYSTEM_PYTHON: 1
17+
1518
jobs:
1619
deploy-docs:
1720
runs-on: ubuntu-latest
@@ -25,21 +28,22 @@ jobs:
2528
uses: actions/setup-python@v5
2629
with:
2730
python-version: "3.11"
28-
- uses: actions/cache@v4
29-
id: cache
31+
- name: Setup uv
32+
uses: astral-sh/setup-uv@v3
3033
with:
31-
path: ${{ env.pythonLocation }}
32-
key: ${{ runner.os }}-python-github-actions-${{ env.pythonLocation }}-${{ hashFiles('requirements-github-actions.txt') }}-v01
34+
version: "0.4.15"
35+
enable-cache: true
36+
cache-dependency-glob: |
37+
requirements**.txt
38+
pyproject.toml
3339
- name: Install GitHub Actions dependencies
34-
if: steps.cache.outputs.cache-hit != 'true'
35-
run: pip install -r requirements-github-actions.txt
40+
run: uv pip install -r requirements-github-actions.txt
3641
- name: Deploy Docs Status Pending
3742
run: python ./scripts/deploy_docs_status.py
3843
env:
3944
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4045
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
4146
RUN_ID: ${{ github.run_id }}
42-
4347
- name: Clean site
4448
run: |
4549
rm -rf ./site

.github/workflows/label-approved.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
permissions:
99
pull-requests: write
1010

11+
env:
12+
UV_SYSTEM_PYTHON: 1
13+
1114
jobs:
1215
label-approved:
1316
if: github.repository_owner == 'fastapi'
@@ -19,8 +22,22 @@ jobs:
1922
run: echo "$GITHUB_CONTEXT"
2023
- uses: docker://tiangolo/label-approved:0.0.4
2124
with:
22-
token: ${{ secrets.GITHUB_TOKEN }}
23-
config: >
25+
python-version: "3.11"
26+
- name: Setup uv
27+
uses: astral-sh/setup-uv@v3
28+
with:
29+
version: "0.4.15"
30+
enable-cache: true
31+
cache-dependency-glob: |
32+
requirements**.txt
33+
pyproject.toml
34+
- name: Install GitHub Actions dependencies
35+
run: uv pip install -r requirements-github-actions.txt
36+
- name: Label Approved
37+
run: python ./scripts/label_approved.py
38+
env:
39+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
CONFIG: >
2441
{
2542
"approved-1":
2643
{

.github/workflows/notify-translations.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
permissions:
1919
discussions: write
2020

21+
env:
22+
UV_SYSTEM_PYTHON: 1
23+
2124
jobs:
2225
notify-translations:
2326
runs-on: ubuntu-latest
@@ -27,6 +30,19 @@ jobs:
2730
GITHUB_CONTEXT: ${{ toJson(github) }}
2831
run: echo "$GITHUB_CONTEXT"
2932
- uses: actions/checkout@v4
33+
- uses: actions/checkout@v4
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: "3.11"
38+
- name: Setup uv
39+
uses: astral-sh/setup-uv@v3
40+
with:
41+
version: "0.4.15"
42+
enable-cache: true
43+
cache-dependency-glob: |
44+
requirements**.txt
45+
pyproject.toml
3046
# Allow debugging with tmate
3147
- name: Setup tmate session
3248
uses: mxschmitt/action-tmate@v3

.github/workflows/smokeshow.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
permissions:
99
statuses: write
1010

11+
env:
12+
UV_SYSTEM_PYTHON: 1
13+
1114
jobs:
1215
smokeshow:
1316
if: ${{ github.event.workflow_run.conclusion == 'success' }}
@@ -21,16 +24,21 @@ jobs:
2124
- uses: actions/setup-python@v5
2225
with:
2326
python-version: '3.9'
24-
25-
- run: pip install smokeshow
26-
27+
- name: Setup uv
28+
uses: astral-sh/setup-uv@v3
29+
with:
30+
version: "0.4.15"
31+
enable-cache: true
32+
cache-dependency-glob: |
33+
requirements**.txt
34+
pyproject.toml
35+
- run: uv pip install -r requirements-github-actions.txt
2736
- uses: actions/download-artifact@v4
2837
with:
2938
name: coverage-html
3039
path: htmlcov
3140
github-token: ${{ secrets.GITHUB_TOKEN }}
3241
run-id: ${{ github.event.workflow_run.id }}
33-
3442
- run: smokeshow upload htmlcov
3543
env:
3644
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}

.github/workflows/test.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
# cron every week on monday
1313
- cron: "0 0 * * 1"
1414

15+
env:
16+
UV_SYSTEM_PYTHON: 1
17+
1518
jobs:
1619
lint:
1720
runs-on: ubuntu-latest
@@ -25,19 +28,18 @@ jobs:
2528
uses: actions/setup-python@v5
2629
with:
2730
python-version: "3.11"
28-
# Issue ref: https://github.com/actions/setup-python/issues/436
29-
# cache: "pip"
30-
# cache-dependency-path: pyproject.toml
31-
- uses: actions/cache@v4
32-
id: cache
31+
- name: Setup uv
32+
uses: astral-sh/setup-uv@v3
3333
with:
34-
path: ${{ env.pythonLocation }}
35-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v08
34+
version: "0.4.15"
35+
enable-cache: true
36+
cache-dependency-glob: |
37+
requirements**.txt
38+
pyproject.toml
3639
- name: Install Dependencies
37-
if: steps.cache.outputs.cache-hit != 'true'
38-
run: pip install -r requirements-tests.txt
40+
run: uv pip install -r requirements-tests.txt
3941
- name: Install Pydantic v2
40-
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
42+
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
4143
- name: Lint
4244
run: bash scripts/lint.sh
4345

@@ -63,23 +65,22 @@ jobs:
6365
uses: actions/setup-python@v5
6466
with:
6567
python-version: ${{ matrix.python-version }}
66-
# Issue ref: https://github.com/actions/setup-python/issues/436
67-
# cache: "pip"
68-
# cache-dependency-path: pyproject.toml
69-
- uses: actions/cache@v4
70-
id: cache
68+
- name: Setup uv
69+
uses: astral-sh/setup-uv@v3
7170
with:
72-
path: ${{ env.pythonLocation }}
73-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v08
71+
version: "0.4.15"
72+
enable-cache: true
73+
cache-dependency-glob: |
74+
requirements**.txt
75+
pyproject.toml
7476
- name: Install Dependencies
75-
if: steps.cache.outputs.cache-hit != 'true'
76-
run: pip install -r requirements-tests.txt
77+
run: uv pip install -r requirements-tests.txt
7778
- name: Install Pydantic v1
7879
if: matrix.pydantic-version == 'pydantic-v1'
79-
run: pip install "pydantic>=1.10.0,<2.0.0"
80+
run: uv pip install "pydantic>=1.10.0,<2.0.0"
8081
- name: Install Pydantic v2
8182
if: matrix.pydantic-version == 'pydantic-v2'
82-
run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
83+
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
8384
- run: mkdir coverage
8485
- name: Test
8586
run: bash scripts/test.sh
@@ -105,16 +106,22 @@ jobs:
105106
- uses: actions/setup-python@v5
106107
with:
107108
python-version: '3.8'
108-
# Issue ref: https://github.com/actions/setup-python/issues/436
109-
# cache: "pip"
110-
# cache-dependency-path: pyproject.toml
109+
- name: Setup uv
110+
uses: astral-sh/setup-uv@v3
111+
with:
112+
version: "0.4.15"
113+
enable-cache: true
114+
cache-dependency-glob: |
115+
requirements**.txt
116+
pyproject.toml
117+
- name: Install Dependencies
118+
run: uv pip install -r requirements-tests.txt
111119
- name: Get coverage files
112120
uses: actions/download-artifact@v4
113121
with:
114122
pattern: coverage-*
115123
path: coverage
116124
merge-multiple: true
117-
- run: pip install coverage[toml]
118125
- run: ls -la coverage
119126
- run: coverage combine coverage
120127
- run: coverage report

requirements-github-actions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ PyGithub>=2.3.0,<3.0.0
22
pydantic>=2.5.3,<3.0.0
33
pydantic-settings>=2.1.0,<3.0.0
44
httpx>=0.27.0,<0.28.0
5+
smokeshow

0 commit comments

Comments
 (0)