mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
name: Restore Python
|
|
inputs:
|
|
python-version:
|
|
description: Python version to restore
|
|
required: true
|
|
type: string
|
|
cache-key:
|
|
description: Cache key to use
|
|
required: true
|
|
type: string
|
|
outputs:
|
|
python-version:
|
|
description: Python version restored
|
|
value: ${{ steps.python.outputs.python-version }}
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Set up Python ${{ inputs.python-version }}
|
|
id: python
|
|
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
- name: Restore Python virtual environment
|
|
id: cache-venv
|
|
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
with:
|
|
path: venv
|
|
# yamllint disable-line rule:line-length
|
|
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ inputs.cache-key }}
|
|
- name: Set up uv
|
|
# Only needed on cache miss to populate the venv. ``uv pip install``
|
|
# detects the activated venv via ``VIRTUAL_ENV`` so the venv layout
|
|
# downstream jobs rely on is preserved.
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
|
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
with:
|
|
enable-cache: true
|
|
# Pull request saves land in per-PR scopes nothing else can
|
|
# reuse; dev pushes seed the shared copy instead.
|
|
save-cache: ${{ github.event_name != 'pull_request' }}
|
|
# Pin uv version so the action does not have to fetch the
|
|
# manifest from raw.githubusercontent.com on every cache
|
|
# miss; that fetch flakes on Windows runners.
|
|
version: "0.11.15"
|
|
- name: Create Python virtual environment
|
|
if: steps.cache-venv.outputs.cache-hit != 'true' && runner.os != 'Windows'
|
|
shell: bash
|
|
run: |
|
|
python -m venv venv
|
|
source venv/bin/activate
|
|
python --version
|
|
uv pip install -r requirements.txt -r requirements_test.txt
|
|
uv pip install -e .
|
|
- name: Create Python virtual environment
|
|
if: steps.cache-venv.outputs.cache-hit != 'true' && runner.os == 'Windows'
|
|
shell: bash
|
|
run: |
|
|
python -m venv venv
|
|
source ./venv/Scripts/activate
|
|
python --version
|
|
uv pip install -r requirements.txt -r requirements_test.txt
|
|
uv pip install -e .
|