diff --git a/.github/actions/uv_setup/action.yml b/.github/actions/uv_setup/action.yml index 3b9db69e7a2..bf4a8689cd5 100644 --- a/.github/actions/uv_setup/action.yml +++ b/.github/actions/uv_setup/action.yml @@ -1,12 +1,22 @@ -# TODO: https://docs.astral.sh/uv/guides/integration/github/#caching - name: uv-install -description: Set up Python and uv +description: Set up Python and uv with caching inputs: python-version: description: Python version, supporting MAJOR.MINOR only required: true + enable-cache: + description: Enable caching for uv dependencies + required: false + default: 'true' + cache-suffix: + description: Custom cache key suffix for cache invalidation + required: false + default: '' + working-directory: + description: Working directory for cache glob scoping + required: false + default: '**' env: UV_VERSION: "0.5.25" @@ -15,7 +25,13 @@ runs: using: composite steps: - name: Install uv and set the python version - uses: astral-sh/setup-uv@v5 + uses: astral-sh/setup-uv@v6 with: version: ${{ env.UV_VERSION }} python-version: ${{ inputs.python-version }} + enable-cache: ${{ inputs.enable-cache }} + cache-dependency-glob: | + ${{ inputs.working-directory }}/pyproject.toml + ${{ inputs.working-directory }}/uv.lock + ${{ inputs.working-directory }}/requirements*.txt + cache-suffix: ${{ inputs.cache-suffix }} diff --git a/.github/workflows/_compile_integration_test.yml b/.github/workflows/_compile_integration_test.yml index 334da4d141f..4e4a1ac3bac 100644 --- a/.github/workflows/_compile_integration_test.yml +++ b/.github/workflows/_compile_integration_test.yml @@ -33,6 +33,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ inputs.python-version }} + cache-suffix: compile-integration-tests-${{ inputs.working-directory }} + working-directory: ${{ inputs.working-directory }} - name: '📦 Install Integration Dependencies' shell: bash diff --git a/.github/workflows/_integration_test.yml b/.github/workflows/_integration_test.yml index c5b2362a6ae..0579c2e7300 100644 --- a/.github/workflows/_integration_test.yml +++ b/.github/workflows/_integration_test.yml @@ -34,6 +34,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ inputs.python-version }} + cache-suffix: integration-tests-${{ inputs.working-directory }} + working-directory: ${{ inputs.working-directory }} - name: '📦 Install Integration Dependencies' shell: bash diff --git a/.github/workflows/_lint.yml b/.github/workflows/_lint.yml index dba94f9f44c..817e15de856 100644 --- a/.github/workflows/_lint.yml +++ b/.github/workflows/_lint.yml @@ -39,6 +39,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ inputs.python-version }} + cache-suffix: lint-${{ inputs.working-directory }} + working-directory: ${{ inputs.working-directory }} - name: '📦 Install Lint & Typing Dependencies' # Also installs dev/lint/test/typing dependencies, to ensure we have diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index dc48456b3ca..b49cb5440bd 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -39,6 +39,9 @@ jobs: id: setup-python with: python-version: ${{ inputs.python-version }} + cache-suffix: test-${{ inputs.working-directory }} + working-directory: ${{ inputs.working-directory }} + - name: '📦 Install Test Dependencies' shell: bash run: uv sync --group test --dev diff --git a/.github/workflows/_test_doc_imports.yml b/.github/workflows/_test_doc_imports.yml index 5207a9ca227..5347c4d7c47 100644 --- a/.github/workflows/_test_doc_imports.yml +++ b/.github/workflows/_test_doc_imports.yml @@ -27,6 +27,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ inputs.python-version }} + cache-suffix: test-doc-imports-${{ inputs.working-directory }} + working-directory: ${{ inputs.working-directory }} - name: '📦 Install Test Dependencies' shell: bash diff --git a/.github/workflows/_test_pydantic.yml b/.github/workflows/_test_pydantic.yml index 3a5f8d03ed7..89e4f0dae11 100644 --- a/.github/workflows/_test_pydantic.yml +++ b/.github/workflows/_test_pydantic.yml @@ -40,6 +40,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ inputs.python-version }} + cache-suffix: test-pydantic-${{ inputs.working-directory }} + working-directory: ${{ inputs.working-directory }} - name: '📦 Install Test Dependencies' shell: bash diff --git a/.github/workflows/check_diffs.yml b/.github/workflows/check_diffs.yml index 667eda3dd2f..ff6a90130f5 100644 --- a/.github/workflows/check_diffs.yml +++ b/.github/workflows/check_diffs.yml @@ -145,6 +145,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ matrix.job-configs.python-version }} + cache-suffix: extended-tests-${{ matrix.job-configs.working-directory }} + working-directory: ${{ matrix.job-configs.working-directory }} - name: '📦 Install Dependencies & Run Extended Tests' shell: bash diff --git a/.github/workflows/run_notebooks.yml b/.github/workflows/run_notebooks.yml index ba7278cd042..5649d37e6f7 100644 --- a/.github/workflows/run_notebooks.yml +++ b/.github/workflows/run_notebooks.yml @@ -32,6 +32,8 @@ jobs: uses: "./.github/actions/uv_setup" with: python-version: ${{ github.event.inputs.python_version || '3.11' }} + cache-suffix: run-notebooks-${{ github.event.inputs.working-directory || 'all' }} + working-directory: ${{ github.event.inputs.working-directory || '**' }} - name: '🔐 Authenticate to Google Cloud' id: 'auth'