Use UV instead of PIP in the CI (#113051)

This commit is contained in:
Robert Resch 2024-03-11 12:18:29 +01:00 committed by GitHub
parent 57e6c8e07a
commit 7fd5c3ed61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 19 deletions

View File

@ -34,7 +34,7 @@ on:
env:
CACHE_VERSION: 5
PIP_CACHE_VERSION: 4
UV_CACHE_VERSION: 1
MYPY_CACHE_VERSION: 8
HA_SHORT_VERSION: "2024.4"
DEFAULT_PYTHON: "3.12"
@ -56,7 +56,7 @@ env:
# - 15.2 is the latest (as of 9 Feb 2023)
POSTGRESQL_VERSIONS: "['postgres:12.14','postgres:15.2']"
PRE_COMMIT_CACHE: ~/.cache/pre-commit
PIP_CACHE: /tmp/pip-cache
UV_CACHE_DIR: /tmp/uv-cache
SQLALCHEMY_WARN_20: 1
PYTHONASYNCIODEBUG: 1
HASS_CI: 1
@ -243,7 +243,8 @@ jobs:
python -m venv venv
. venv/bin/activate
python --version
pip install "$(cat requirements_test.txt | grep pre-commit)"
pip install "$(cat requirements_test.txt | grep uv)"
uv pip install "$(cat requirements_test.txt | grep pre-commit)"
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v4.0.1
@ -447,10 +448,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Generate partial pip restore key
id: generate-pip-key
- name: Generate partial uv restore key
id: generate-uv-key
run: >-
echo "key=pip-${{ env.PIP_CACHE_VERSION }}-${{
echo "key=uv-${{ env.UV_CACHE_VERSION }}-${{
env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" >> $GITHUB_OUTPUT
- name: Restore base Python virtual environment
id: cache-venv
@ -461,16 +462,16 @@ jobs:
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
needs.info.outputs.python_cache_key }}
- name: Restore pip wheel cache
- name: Restore uv wheel cache
if: steps.cache-venv.outputs.cache-hit != 'true'
uses: actions/cache@v4.0.1
with:
path: ${{ env.PIP_CACHE }}
path: ${{ env.UV_CACHE }}
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
steps.generate-pip-key.outputs.key }}
steps.generate-uv-key.outputs.key }}
restore-keys: |
${{ runner.os }}-${{ steps.python.outputs.python-version }}-pip-${{ env.PIP_CACHE_VERSION }}-${{ env.HA_SHORT_VERSION }}-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-uv-${{ env.UV_CACHE_VERSION }}-${{ env.HA_SHORT_VERSION }}-
- name: Install additional OS dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
@ -492,10 +493,11 @@ jobs:
python -m venv venv
. venv/bin/activate
python --version
PIP_CACHE_DIR=$PIP_CACHE pip install -U "pip>=21.3.1" setuptools wheel
PIP_CACHE_DIR=$PIP_CACHE pip install -r requirements_all.txt
PIP_CACHE_DIR=$PIP_CACHE pip install -r requirements_test.txt
pip install -e . --config-settings editable_mode=compat
pip install "$(cat requirements_test.txt | grep uv)"
uv pip install -U "pip>=21.3.1" setuptools wheel
uv pip install -r requirements_all.txt
uv pip install -r requirements_test.txt
uv pip install -e . --config-settings editable_mode=compat
hassfest:
name: Check hassfest
@ -723,7 +725,8 @@ jobs:
# Ideally this should be part of our dependencies
# However this plugin is fairly new and doesn't run correctly
# on a non-GitHub environment.
pip install pytest-github-actions-annotate-failures==0.1.3
pip install "$(cat requirements_test.txt | grep uv)"
uv pip install pytest-github-actions-annotate-failures==0.1.3
- name: Register pytest slow test problem matcher
run: |
echo "::add-matcher::.github/workflows/matchers/pytest-slow.json"
@ -876,14 +879,15 @@ jobs:
# Ideally this should be part of our dependencies
# However this plugin is fairly new and doesn't run correctly
# on a non-GitHub environment.
pip install pytest-github-actions-annotate-failures==0.1.3
pip install "$(cat requirements_test.txt | grep uv)"
uv pip install pytest-github-actions-annotate-failures==0.1.3
- name: Register pytest slow test problem matcher
run: |
echo "::add-matcher::.github/workflows/matchers/pytest-slow.json"
- name: Install SQL Python libraries
run: |
. venv/bin/activate
pip install mysqlclient sqlalchemy_utils
uv pip install mysqlclient sqlalchemy_utils
- name: Compile English translations
run: |
. venv/bin/activate
@ -1003,14 +1007,15 @@ jobs:
# Ideally this should be part of our dependencies
# However this plugin is fairly new and doesn't run correctly
# on a non-GitHub environment.
pip install pytest-github-actions-annotate-failures==0.1.3
pip install "$(cat requirements_test.txt | grep uv)"
uv pip install pytest-github-actions-annotate-failures==0.1.3
- name: Register pytest slow test problem matcher
run: |
echo "::add-matcher::.github/workflows/matchers/pytest-slow.json"
- name: Install SQL Python libraries
run: |
. venv/bin/activate
pip install psycopg2 sqlalchemy_utils
uv pip install psycopg2 sqlalchemy_utils
- name: Compile English translations
run: |
. venv/bin/activate

View File

@ -50,3 +50,4 @@ types-pytz==2023.3.1.1
types-PyYAML==6.0.12.12
types-requests==2.31.0.3
types-xmltodict==0.13.0.3
uv==0.1.17