mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Add black caching [ci] (#99967)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
483e9c92bd
commit
c77eb70886
25
.github/workflows/ci.yaml
vendored
25
.github/workflows/ci.yaml
vendored
@ -36,6 +36,7 @@ env:
|
|||||||
CACHE_VERSION: 5
|
CACHE_VERSION: 5
|
||||||
PIP_CACHE_VERSION: 4
|
PIP_CACHE_VERSION: 4
|
||||||
MYPY_CACHE_VERSION: 4
|
MYPY_CACHE_VERSION: 4
|
||||||
|
BLACK_CACHE_VERSION: 1
|
||||||
HA_SHORT_VERSION: "2023.10"
|
HA_SHORT_VERSION: "2023.10"
|
||||||
DEFAULT_PYTHON: "3.11"
|
DEFAULT_PYTHON: "3.11"
|
||||||
ALL_PYTHON_VERSIONS: "['3.11']"
|
ALL_PYTHON_VERSIONS: "['3.11']"
|
||||||
@ -55,6 +56,7 @@ env:
|
|||||||
POSTGRESQL_VERSIONS: "['postgres:12.14','postgres:15.2']"
|
POSTGRESQL_VERSIONS: "['postgres:12.14','postgres:15.2']"
|
||||||
PRE_COMMIT_CACHE: ~/.cache/pre-commit
|
PRE_COMMIT_CACHE: ~/.cache/pre-commit
|
||||||
PIP_CACHE: /tmp/pip-cache
|
PIP_CACHE: /tmp/pip-cache
|
||||||
|
BLACK_CACHE: /tmp/black-cache
|
||||||
SQLALCHEMY_WARN_20: 1
|
SQLALCHEMY_WARN_20: 1
|
||||||
PYTHONASYNCIODEBUG: 1
|
PYTHONASYNCIODEBUG: 1
|
||||||
HASS_CI: 1
|
HASS_CI: 1
|
||||||
@ -272,6 +274,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: ${{ env.DEFAULT_PYTHON }}
|
python-version: ${{ env.DEFAULT_PYTHON }}
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
- name: Generate partial black restore key
|
||||||
|
id: generate-black-key
|
||||||
|
run: |
|
||||||
|
black_version=$(cat requirements_test_pre_commit.txt | grep black | cut -d '=' -f 3)
|
||||||
|
echo "version=$black_version" >> $GITHUB_OUTPUT
|
||||||
|
echo "key=black-${{ env.BLACK_CACHE_VERSION }}-$black_version-${{
|
||||||
|
env.HA_SHORT_VERSION }}-$(date -u '+%Y-%m-%dT%H:%M:%s')" >> $GITHUB_OUTPUT
|
||||||
- name: Restore base Python virtual environment
|
- name: Restore base Python virtual environment
|
||||||
id: cache-venv
|
id: cache-venv
|
||||||
uses: actions/cache/restore@v3.3.2
|
uses: actions/cache/restore@v3.3.2
|
||||||
@ -290,14 +299,28 @@ jobs:
|
|||||||
key: >-
|
key: >-
|
||||||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
|
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
|
||||||
needs.info.outputs.pre-commit_cache_key }}
|
needs.info.outputs.pre-commit_cache_key }}
|
||||||
|
- name: Restore black cache
|
||||||
|
uses: actions/cache@v3.3.2
|
||||||
|
with:
|
||||||
|
path: ${{ env.BLACK_CACHE }}
|
||||||
|
key: >-
|
||||||
|
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
|
||||||
|
steps.generate-black-key.outputs.key }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-${{ steps.python.outputs.python-version }}-black-${{
|
||||||
|
env.BLACK_CACHE_VERSION }}-${{ steps.generate-black-key.outputs.version }}-${{
|
||||||
|
env.HA_SHORT_VERSION }}-
|
||||||
- name: Run black (fully)
|
- name: Run black (fully)
|
||||||
if: needs.info.outputs.test_full_suite == 'true'
|
env:
|
||||||
|
BLACK_CACHE_DIR: ${{ env.BLACK_CACHE }}
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
pre-commit run --hook-stage manual black --all-files --show-diff-on-failure
|
pre-commit run --hook-stage manual black --all-files --show-diff-on-failure
|
||||||
- name: Run black (partially)
|
- name: Run black (partially)
|
||||||
if: needs.info.outputs.test_full_suite == 'false'
|
if: needs.info.outputs.test_full_suite == 'false'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
BLACK_CACHE_DIR: ${{ env.BLACK_CACHE }}
|
||||||
run: |
|
run: |
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user