]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
👷 Use uv in CI (#12281)
authorSebastián Ramírez <tiangolo@gmail.com>
Sat, 12 Oct 2024 12:27:19 +0000 (14:27 +0200)
committerGitHub <noreply@github.com>
Sat, 12 Oct 2024 12:27:19 +0000 (14:27 +0200)
.github/workflows/build-docs.yml
.github/workflows/deploy-docs.yml
.github/workflows/label-approved.yml
.github/workflows/notify-translations.yml
.github/workflows/smokeshow.yml
.github/workflows/test.yml
requirements-github-actions.txt

index 52c34a49ea6bad69b1218297d14e57dbb0ae9dd3..dd11727c7396038e7baff8341460e9e99b78f329 100644 (file)
@@ -7,6 +7,10 @@ on:
     types:
       - opened
       - synchronize
+
+env:
+  UV_SYSTEM_PYTHON: 1
+
 jobs:
   changes:
     runs-on: ubuntu-latest
@@ -48,18 +52,20 @@ jobs:
         uses: actions/setup-python@v5
         with:
           python-version: "3.11"
-      - uses: actions/cache@v4
-        id: cache
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
         with:
-          path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-insiders.txt', 'requirements-docs-tests.txt') }}-v08
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
       - name: Install docs extras
-        if: steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-docs.txt
+        run: uv pip install -r requirements-docs.txt
       # Install MkDocs Material Insiders here just to put it in the cache for the rest of the steps
       - name: Install Material for MkDocs Insiders
-        if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-docs-insiders.txt
+        if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
+        run: uv pip install -r requirements-docs-insiders.txt
         env:
           TOKEN: ${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}
       - name: Verify Docs
@@ -88,17 +94,19 @@ jobs:
         uses: actions/setup-python@v5
         with:
           python-version: "3.11"
-      - uses: actions/cache@v4
-        id: cache
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
         with:
-          path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-insiders.txt', 'requirements-docs-tests.txt') }}-v08
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
       - name: Install docs extras
-        if: steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-docs.txt
+        run: uv pip install -r requirements-docs.txt
       - name: Install Material for MkDocs Insiders
-        if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-docs-insiders.txt
+        if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
+        run: uv pip install -r requirements-docs-insiders.txt
         env:
           TOKEN: ${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}
       - name: Update Languages
index 22dc89dff4a4f462e8fef8afe0887ae898e53d86..2fd46df6be7e1bc6bd081e4860f6083aac9f2468 100644 (file)
@@ -12,6 +12,9 @@ permissions:
   pull-requests: write
   statuses: write
 
+env:
+  UV_SYSTEM_PYTHON: 1
+
 jobs:
   deploy-docs:
     runs-on: ubuntu-latest
@@ -25,21 +28,22 @@ jobs:
         uses: actions/setup-python@v5
         with:
           python-version: "3.11"
-      - uses: actions/cache@v4
-        id: cache
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
         with:
-          path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-github-actions-${{ env.pythonLocation }}-${{ hashFiles('requirements-github-actions.txt') }}-v01
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
       - name: Install GitHub Actions dependencies
-        if: steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-github-actions.txt
+        run: uv pip install -r requirements-github-actions.txt
       - name: Deploy Docs Status Pending
         run: python ./scripts/deploy_docs_status.py
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
           RUN_ID: ${{ github.run_id }}
-
       - name: Clean site
         run: |
           rm -rf ./site
index 0470fb60645c0ba16bb111b513747110f9f42797..e44584cf151f41801c244a103e2420f895963e79 100644 (file)
@@ -8,6 +8,9 @@ on:
 permissions:
   pull-requests: write
 
+env:
+  UV_SYSTEM_PYTHON: 1
+
 jobs:
   label-approved:
     if: github.repository_owner == 'fastapi'
@@ -19,8 +22,22 @@ jobs:
       run: echo "$GITHUB_CONTEXT"
     - uses: docker://tiangolo/label-approved:0.0.4
       with:
-        token: ${{ secrets.GITHUB_TOKEN }}
-        config: >
+        python-version: "3.11"
+    - name: Setup uv
+      uses: astral-sh/setup-uv@v3
+      with:
+        version: "0.4.15"
+        enable-cache: true
+        cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
+    - name: Install GitHub Actions dependencies
+      run: uv pip install -r requirements-github-actions.txt
+    - name: Label Approved
+      run: python ./scripts/label_approved.py
+      env:
+        TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        CONFIG: >
           {
             "approved-1":
               {
index 4787f3ddd608ec56a1e69202088ba30d28a8218b..98aa41e5aa8d5830672ccb0bf8d42c06407cb9fc 100644 (file)
@@ -18,6 +18,9 @@ on:
 permissions:
   discussions: write
 
+env:
+  UV_SYSTEM_PYTHON: 1
+
 jobs:
   notify-translations:
     runs-on: ubuntu-latest
@@ -27,6 +30,19 @@ jobs:
           GITHUB_CONTEXT: ${{ toJson(github) }}
         run: echo "$GITHUB_CONTEXT"
       - uses: actions/checkout@v4
+      - uses: actions/checkout@v4
+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: "3.11"
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
+        with:
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
       # Allow debugging with tmate
       - name: Setup tmate session
         uses: mxschmitt/action-tmate@v3
index d3a975df58ad6b4192c00d8f4a1c7d1fd45640ac..e9aa1093f24d09f863e7f2193ed45f3a945ceba7 100644 (file)
@@ -8,6 +8,9 @@ on:
 permissions:
   statuses: write
 
+env:
+  UV_SYSTEM_PYTHON: 1
+
 jobs:
   smokeshow:
     if: ${{ github.event.workflow_run.conclusion == 'success' }}
@@ -21,16 +24,21 @@ jobs:
       - uses: actions/setup-python@v5
         with:
           python-version: '3.9'
-
-      - run: pip install smokeshow
-
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
+        with:
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
+      - run: uv pip install -r requirements-github-actions.txt
       - uses: actions/download-artifact@v4
         with:
           name: coverage-html
           path: htmlcov
           github-token: ${{ secrets.GITHUB_TOKEN }}
           run-id: ${{ github.event.workflow_run.id }}
-
       - run: smokeshow upload htmlcov
         env:
           SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
index fb4b083c4e0c1875d5deebce5622843bbdb37809..643037a12b9e54362d99112834b3a029b696f9db 100644 (file)
@@ -12,6 +12,9 @@ on:
     # cron every week on monday
     - cron: "0 0 * * 1"
 
+env:
+  UV_SYSTEM_PYTHON: 1
+
 jobs:
   lint:
     runs-on: ubuntu-latest
@@ -25,19 +28,18 @@ jobs:
         uses: actions/setup-python@v5
         with:
           python-version: "3.11"
-          # Issue ref: https://github.com/actions/setup-python/issues/436
-          # cache: "pip"
-          # cache-dependency-path: pyproject.toml
-      - uses: actions/cache@v4
-        id: cache
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
         with:
-          path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v08
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
       - name: Install Dependencies
-        if: steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-tests.txt
+        run: uv pip install -r requirements-tests.txt
       - name: Install Pydantic v2
-        run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
+        run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
       - name: Lint
         run: bash scripts/lint.sh
 
@@ -63,23 +65,22 @@ jobs:
         uses: actions/setup-python@v5
         with:
           python-version: ${{ matrix.python-version }}
-          # Issue ref: https://github.com/actions/setup-python/issues/436
-          # cache: "pip"
-          # cache-dependency-path: pyproject.toml
-      - uses: actions/cache@v4
-        id: cache
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
         with:
-          path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v08
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
       - name: Install Dependencies
-        if: steps.cache.outputs.cache-hit != 'true'
-        run: pip install -r requirements-tests.txt
+        run: uv pip install -r requirements-tests.txt
       - name: Install Pydantic v1
         if: matrix.pydantic-version == 'pydantic-v1'
-        run: pip install "pydantic>=1.10.0,<2.0.0"
+        run: uv pip install "pydantic>=1.10.0,<2.0.0"
       - name: Install Pydantic v2
         if: matrix.pydantic-version == 'pydantic-v2'
-        run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
+        run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
       - run: mkdir coverage
       - name: Test
         run: bash scripts/test.sh
@@ -105,16 +106,22 @@ jobs:
       - uses: actions/setup-python@v5
         with:
           python-version: '3.8'
-          # Issue ref: https://github.com/actions/setup-python/issues/436
-          # cache: "pip"
-          # cache-dependency-path: pyproject.toml
+      - name: Setup uv
+        uses: astral-sh/setup-uv@v3
+        with:
+          version: "0.4.15"
+          enable-cache: true
+          cache-dependency-glob: |
+            requirements**.txt
+            pyproject.toml
+      - name: Install Dependencies
+        run: uv pip install -r requirements-tests.txt
       - name: Get coverage files
         uses: actions/download-artifact@v4
         with:
           pattern: coverage-*
           path: coverage
           merge-multiple: true
-      - run: pip install coverage[toml]
       - run: ls -la coverage
       - run: coverage combine coverage
       - run: coverage report
index 559dc06fb2dd7280bdde52fd0962c86786f8bedf..a6dace544fb53dff511698890f6ba0bf5882a70e 100644 (file)
@@ -2,3 +2,4 @@ PyGithub>=2.3.0,<3.0.0
 pydantic>=2.5.3,<3.0.0
 pydantic-settings>=2.1.0,<3.0.0
 httpx>=0.27.0,<0.28.0
+smokeshow